This class is simply a wrapper around a Dynamic_Array<Data> object, it is mainly used because object of this class can be serialized (with the prepareBuffer() and one of the constructor), and because it can use a name map.
|
Public Member Functions |
void | addField (double f, char tag=0) |
| Push a new Data object with base type DOUBLE in the array.
|
void | addField (long long int i, char tag=0) |
| Push a new Data object with base type BIGINT in the array.
|
void | addField (int i, char tag=0) |
| Push a new Data object with base type INT in the array.
|
void | addField (string s, char tag=0) |
| Push a new Data object with base type STRING in the array.
|
void | addField (Data &d) |
| Wrapper around Dynamic_Array.push.
|
void | addField (Data *d) |
| Wrapper around Dynamic_Array.push.
|
string | asString (string sep="\t") |
| Return record content as a unique string.
|
string | asStringNames (string sep="\t") |
string | asStringTypes (string sep="\t") |
void | clear () |
int | count () |
| Wrapper around Dynamic_Array.count.
|
void | emptyName () |
| Set all Data object's name to an empty string.
|
Data | field (int pos) |
Data | field (string name) |
| Returns the Data object in the vector whose name is "name".
|
unsigned int | objSize () |
| Return how many bytes require the object to be serialized.
|
Record & | operator= (Record &from) |
| Assignment operator, will copy all data objects.
|
Data & | operator[] (int pos) |
Data & | operator[] (string name) |
Data | pop (int x=0) |
int | posWhoseNameIs (string name, enum ThrowExceptions throwexc=THROW) |
| Return the index of the first Data objects whose name is "name".
|
| Record (void *lbuf, bool synchro=false) |
| Build a Record object from a buffer prepared with Record.prepareBuffer().
|
| Record (bool synchro=false) |
| Constructor, build an empty record. The parameter is passed to the underlying Dynamic_Array object.
|
| Record (Record &from) |
| Copy constructor, will copy all data objects.
|
void | setFieldMap (Record &rec) |
| Copy the field map from one record to another.
|
void | setFieldMap (string s="") |
| Creates a new field map from the given string.
|
void | setNull () |
| Set all Data object's name to null values.
|
| ~Record () |
| Destructor.
|
Private Member Functions |
bool | serialize_buffer (char *&from, unsigned int &size) |
| Prepare a buffer with all informations contained in the object.
|
Private Attributes |
Dynamic_Array< Data > | array |
| Array of fields.
|
Dynamic_Array< int > | lmap |
| Array of mapped fields.
|
| MCS_DEBUG_ALLOC |
string | smap |
| String representation of the map.
|
bool mcs::Record::serialize_buffer |
( |
char *& |
from, |
|
|
unsigned int & |
size | |
|
) |
| | [private, virtual] |
Prepare a buffer with all informations contained in the object.
Once the buffer is prepared you can rebuild an identical object using the Record(void*) cosntructor.
If "*lbuf" is NULL then the buffer will be allocated, otherwise "size" must be set to the length of the buffer pointed by "*lbuf";
- Parameters:
-
| lbuf | Address of a pointer to a buffer; |
| size | Size of the buffer if it should not be allocated. |
- Returns:
- Size of the data in the buffer.
- Exceptions:
-
| ERROR | MSG_NOT_ENOUGH_SPACE. |
- Returns:
- Size of the buffer.
Reimplemented from mcs::Serializable.
Definition at line 299 of file Record.cc.
void mcs::Record::setFieldMap |
( |
string |
s = "" |
) |
|
Creates a new field map from the given string.
It often happens that user want to access a record with field names rather than indexes. This can be done with the fieldName() method. On the other hand using this method in a iteration can really slow down the execution of a program. With this method you can remap the list of indexes using field names, then access the fields with the integer provided by the map. You create the map giving a string containing, in the order you wish, the names of the fields. You don't need to citate all the fields in the list, just the ones you want to remap. Fields name must be separated by spaces.
- Parameters:
-
| s | String containing the map. |
An example follows:
Query qry;
qry.prepare(...);
qry.execute();
qry.newFieldMap("Field3 Field2 Field1");
qry.field(0)
qry.field(1)
qry.field(2)
qry.mfield(0)
qry.mfield(1)
qry.mfield(2)
To restore the original order simply call this method without arguments.
Definition at line 480 of file Record.cc.