Documentation
¶
Overview ¶
dbf package implements functions for working with DBF files.
Index ¶
- type XBase
- func (db *XBase) Add()
- func (db *XBase) AddField(name string, typ string, opts ...int)
- func (db *XBase) BOF() bool
- func (db *XBase) Clear()
- func (db *XBase) CloseFile()
- func (db *XBase) CodePage() int
- func (db *XBase) CreateFile(name string)
- func (db *XBase) Del()
- func (db *XBase) EOF() bool
- func (db *XBase) Error() error
- func (db *XBase) FieldCount() int
- func (db *XBase) FieldInfo(fieldNo int) (name, typ string, length, dec int)
- func (db *XBase) FieldNo(name string) int
- func (db *XBase) FieldValueAsBool(fieldNo int) bool
- func (db *XBase) FieldValueAsDate(fieldNo int) time.Time
- func (db *XBase) FieldValueAsFloat(fieldNo int) float64
- func (db *XBase) FieldValueAsInt(fieldNo int) int64
- func (db *XBase) FieldValueAsString(fieldNo int) string
- func (db *XBase) First()
- func (db *XBase) GoTo(recNo int64)
- func (db *XBase) IsPanic() bool
- func (db *XBase) Last()
- func (db *XBase) ModDate() time.Time
- func (db *XBase) Next()
- func (db *XBase) OpenFile(name string, readOnly bool)
- func (db *XBase) Prev()
- func (db *XBase) RecCount() int64
- func (db *XBase) RecDeleted() bool
- func (db *XBase) RecNo() int64
- func (db *XBase) Recall()
- func (db *XBase) Save()
- func (db *XBase) SetCodePage(cp int)
- func (db *XBase) SetFieldValue(fieldNo int, value interface{})
- func (db *XBase) SetPanic(flag bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type XBase ¶
type XBase struct {
// contains filtered or unexported fields
}
func (*XBase) Add ¶
func (db *XBase) Add()
Add adds a new empty record. To save the changes, you need to call the Save method.
func (*XBase) AddField ¶
AddField adds a field to the structure of the DBF file. This method can only be used before creating a new file.
The following field types are supported: "C", "N", "L", "D".
The opts parameter contains optional parameters: field length and number of decimal places.
Examples:
db.AddField("NAME", "C", 24) db.AddField("COUNT", "N", 8) db.AddField("PRICE", "N", 12, 2) db.AddField("FLAG", "L") db.AddField("DATE", "D")
func (*XBase) Clear ¶
func (db *XBase) Clear()
Clear zeroes the field values of the current record.
func (*XBase) CloseFile ¶
func (db *XBase) CloseFile()
CloseFile closes a previously opened or created DBF file.
func (*XBase) CodePage ¶
CodePage returns the code page of a DBF file. Returns 0 if no code page is specified.
func (*XBase) CreateFile ¶
CreateFile creates a new file in DBF format. If a file with that name exists, it will be overwritten.
func (*XBase) Del ¶
func (db *XBase) Del()
Del marks the current record as "deleted". The record is not physically deleted from the file and can be subsequently restored.
func (*XBase) FieldCount ¶
FieldCount returns the number of fields in the DBF file.
func (*XBase) FieldInfo ¶
FieldInfo returns field attributes by number. Fields are numbered starting from 1.
func (*XBase) FieldNo ¶
FieldNo returns the number of the field by name. If name is not found returns 0. Fields are numbered starting from 1.
func (*XBase) FieldValueAsBool ¶
FieldValueAsBool returns the boolean value of the field of the current record. Field type must be logical ("L"). Fields are numbered starting from 1.
func (*XBase) FieldValueAsDate ¶
FieldValueAsDate returns the date value of the field of the current record. Field type must be date ("D"). Fields are numbered starting from 1.
func (*XBase) FieldValueAsFloat ¶
FieldValueAsFloat returns the float value of the field of the current record. Field type must be numeric ("N"). Fields are numbered starting from 1.
func (*XBase) FieldValueAsInt ¶
FieldValueAsInt returns the integer value of the field of the current record. Field type must be numeric ("N"). Fields are numbered starting from 1.
func (*XBase) FieldValueAsString ¶
FieldValueAsString returns the string value of the field of the current record. Fields are numbered starting from 1.
func (*XBase) GoTo ¶
GoTo allows you to go to a record by its ordinal number. Numbering starts from 1.
func (*XBase) RecDeleted ¶
RecDeleted returns the value of the delete flag for the current record.
func (*XBase) RecNo ¶
RecNo returns the sequence number of the current record. Numbering starts from 1.
func (*XBase) Recall ¶
func (db *XBase) Recall()
Recall removes the deletion mark from the current record.
func (*XBase) Save ¶
func (db *XBase) Save()
Save writes changes to the file. Before calling it, all changes to the object were made only in memory and will be lost when you move to another record or close the file.
func (*XBase) SetCodePage ¶
SetCodePage sets the encoding mode for reading and writing string field values. The default code page is 0.
Supported code pages:
437 - US MS-DOS 850 - International MS-DOS 1252 - Windows ANSI 10000 - Standard Macintosh 852 - Easern European MS-DOS 866 - Russian MS-DOS 865 - Nordic MS-DOS 1255 - Hebrew Windows 1256 - Arabic Windows 10007 - Russian Macintosh 1250 - Eastern European Windows 1251 - Russian Windows 1254 - Turkish Windows 1253 - Greek Windows
func (*XBase) SetFieldValue ¶
SetFieldValue sets the field value of the current record. The value must match the field type. To save the changes, you need to call the Save method.