gSAFE  1.3.8
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
HXBaseFileWriter Class Reference

#include <xbio.h>

Inheritance diagram for HXBaseFileWriter:
HXBaseFileHandler

Public Member Functions

 HXBaseFileWriter (HCodepageConvert *conv, bool deletecobj=false)
 
 ~HXBaseFileWriter (void)
 
int appendRecord (void)
 
int close (void)
 
int create (QString name, int version)
 
void defineField (QString name, HXBaseFieldType type, int length=0, int nofdecimals=0)
 
int open (QString name)
 
int resetRecord (void)
 
int setFieldBool (QString fname, bool logical)
 
int setFieldDate (QString fname, QDate date)
 
int setFieldDecimal (QString fname, long decimal)
 
int setFieldFloat (QString fname, double val)
 
int setFieldStr (QString fname, QString str)
 
- Public Member Functions inherited from HXBaseFileHandler
 HXBaseFileHandler (HCodepageConvert *conv, bool deletecobj=false)
 
 ~HXBaseFileHandler (void)
 
int fieldCount (void)
 
QString fieldName (int n)
 
HXBaseFieldType fieldType (int n)
 
long recordCount (void)
 

Protected Member Functions

void setLastDefinedField (int idx)
 

Protected Attributes

int defined_fnum
 
xbSchema * schema
 
- Protected Attributes inherited from HXBaseFileHandler
char * buffer
 
HCodepageConvertc
 
xbDbf * dbf
 
bool deleteconvertobject
 
bool opened
 
xbXBase * xbase
 

Additional Inherited Members

- Signals inherited from HXBaseFileHandler
void errorSignal (QString error)
 

Detailed Description

You can create and write one XBase files with this class.
- Define the scheme
- Create the file
- Write the records
- Close the file
HXBaseFileWriter writer(new HCodepage852(),true);
writer.defineField("NAME",Char,20);
writer.defineField("MONEY",Numeric,10);
writer.create("OUTPUT.DBF",3); //Opens the file
writer.setFieldStr("NAME","Big Joe");
writer.setFieldDecimal("MONEY",176);
writer.appendRecord();
writer.setFieldStr("NAME","Alice Newmann");
writer.setFieldDecimal("MONEY",3169);
writer.appendRecord();
writer.close();
See Also
HXBaseFileReader

Definition at line 229 of file xbio.h.

Constructor & Destructor Documentation

HXBaseFileWriter::HXBaseFileWriter ( HCodepageConvert conv,
bool  deletecobj = false 
)

Creates a XBase file writer object

Parameters
convThe codepage converter of the class (put a HCodepageConvert descendant object according to the coding of the dbf file)
deletecobjif this parameter true the "conv" object is deleted if not used.

Definition at line 386 of file xbio.cpp.

HXBaseFileWriter::~HXBaseFileWriter ( void  )

Destructor

Definition at line 394 of file xbio.cpp.

Member Function Documentation

int HXBaseFileWriter::appendRecord ( void  )

Append the current record buffer to the end of the file, and empty the buffer.

Definition at line 501 of file xbio.cpp.

int HXBaseFileWriter::close ( void  )

Closes the currently opened XBase file

Definition at line 426 of file xbio.cpp.

int HXBaseFileWriter::create ( QString  name,
int  version 
)

Creates the XBase file. You have to specify the schema before with the defineField() function. After calling this function the dbf is opened. (Do not call the open()!)

Parameters
namethe path and name of the file
versionthe version of the file (eg: 3 or 4)

Definition at line 472 of file xbio.cpp.

void HXBaseFileWriter::defineField ( QString  name,
HXBaseFieldType  type,
int  length = 0,
int  nofdecimals = 0 
)

Define a field in the schema of XBase file. You can only use this function before create() ! The field specified with this function will be appended to the existing field list.

Parameters
namethe name of the field (limited to 10 char. XBase limit)
typethe type of the field. See HXBaseFieldType enum
lengththe length of the field.
nofdecimalsthe number of decimals

Definition at line 438 of file xbio.cpp.

int HXBaseFileWriter::open ( QString  name)

Opens a XBase file to write. Do not call create() if you call this func!

Parameters
namethe path and name of the file
Returns
0 if success

Definition at line 407 of file xbio.cpp.

int HXBaseFileWriter::resetRecord ( void  )

Empty the current record buffer.

Definition at line 493 of file xbio.cpp.

int HXBaseFileWriter::setFieldBool ( QString  fname,
bool  logical 
)

Set a value of a named field in the current record buffer

Definition at line 554 of file xbio.cpp.

int HXBaseFileWriter::setFieldDate ( QString  fname,
QDate  date 
)

Set a value of a named field in the current record buffer

Definition at line 565 of file xbio.cpp.

int HXBaseFileWriter::setFieldDecimal ( QString  fname,
long  decimal 
)

Set a value of a named field in the current record buffer

Definition at line 533 of file xbio.cpp.

int HXBaseFileWriter::setFieldFloat ( QString  fname,
double  val 
)

Set a value of a named field in the current record buffer

Definition at line 543 of file xbio.cpp.

int HXBaseFileWriter::setFieldStr ( QString  fname,
QString  str 
)

Set a value of a named field in the current record buffer

Definition at line 517 of file xbio.cpp.


The documentation for this class was generated from the following files: