CSVArchive Class ReferenceImplementation of Archive interface for csv file format.
More...
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Public Member Functions | |
| void | addMapping (const char *pCSVField, const char *pTable, const char *pField) |
| Add mapping using column name. | |
| void | addMapping (int pCSVField, const char *pTable, const char *pField) |
| Add mapping using column number. | |
| void | clearMappings () |
| Clear all mappings created by addMapping methods. | |
| virtual IStream * | getInputStream () |
| Create input stream. | |
| CSVIStream | getIStream () |
| create and return input stream | |
| CSVOStream | getOStream () |
| create and return output stream | |
| virtual OStream * | getOutputStream () |
| Create output stream. | |
| bool | hasColumnNames () const |
| This flag tells archive if file contains column names as first row or not. | |
| void | hasColumnNames (bool pFlag) |
| This flag tells archive if file contains column names as first row or not. | |
| void | ignoreEmptyLines (bool pFlag) |
| This flag tells internal CSVParser to ignore lines with no data. | |
| virtual bool | isOpen () const |
| Check if archive is open. | |
| virtual void | open (const char *pOpenStr) |
| Open archive. | |
| void | setFieldSeparator (char pSep) |
| Set field separator. | |
| virtual | ~CSVArchive () |
| Destructor. | |
To fetch data or objects from csv files before opening archive you have to set mappings. Mappings are used to make relation between object fields or binded vars and columns in CSV file.
Mappings can be done automatically or manually (see hasColumnNames()). Automatic mapping occurs always when:
Automatic mapping is estabilished between store table entry or binded var and column that have the same name as field. It is not possibile to manually add mappings after automatic mapping was done
Binded Vars.
When binding variables to output stream with automatic mapping order of binding is sigincfant. For example for this bindings:
int a,b; stream.bind(a,"test","a") stream.bind(b,"test","b")
first data for "a" column will be written and then data for "b".
You can add multiple bindings for the same column name - this will result in multiple column names in cvs file in order that variables were binded.
Mappings.
If there is no mapping for column that is not last on list (for example there are mappings for column 1,2,3 and 5 only) that column will be written as empty one if archive does not have setColnames() set to true. In that case DataException will be thrown - driver don't know what column name to write because there is no mapping for it.
You should not create multiple streams from one CSVArchive at one time. Every call to a CSVOStream::open will overwrite existing file. Reading data from a file using a CSVIStream and writing data to it using a CSVOStream simultaneously is not a good idea and can give weird results
|
||||||||||||||||
|
Add mapping using column name. This function will map pTable and pFiled from object's store tables to particular column name.
|
|
||||||||||||||||
|
Add mapping using column number. This function will map pTable and pField to n-th column in cvs file (columns are numbered from 0). It can be called for archives with or without names. Don't use this function if you want to bind variables to fields - in this case only named mappings works.
|
|
|
Create input stream. Returned value must be deleted
Implements Archive. |
|
|
create and return input stream
|
|
|
create and return output stream
|
|
|
Create output stream. Returned value must be deleted
Implements Archive. |
|
|
This flag tells archive if file contains column names as first row or not.
|
|
|
This flag tells archive if file contains column names as first row or not.
|
|
|
This flag tells internal CSVParser to ignore lines with no data.
|
|
|
Check if archive is open.
Implements Archive. |
|
|
Open archive.
Implements Archive. |
|
|
Set field separator. Default is comma
|
| Documentation |
|---|
| Quick start |
| Examples |
| Search |
| API Documentation |
|---|
| Class hierarchy |
| Member index |
| API Reference |
| Store filters |
| Store table macros |