mcs::Data Class Reference

#include <mcs.hh>

Inheritance diagram for mcs::Data:

Inheritance graph
[legend]

List of all members.


Detailed Description

A general purpose data type.

This class let you create a high-level object that has its own base type, but is able to perform conversion to a different data type. Available base types are those of the mcs::Types enumeration, namely: integers, floating point, string, char*, struct tm*, time_t, memory buffers and pointers. Some base types (STRING, TINY_BLOB and BLOB) are variable length objects, that is their length varies between zero and a maximum specified in the constructor. All other base types are fixed length objects. All integer types can be either signed or unsigned. Conversion between different types follow standard rules (described below). If the conversion cannot be performed an exception is thrown.

This class is widely used inside MCS code due to its ease of use. Some examples follows:

    Data di(INT);        //Data object with base type INT
    Data ds(STRING, 5);  //Data object with base type STRING (max length 5)

    //Store some values
    di = 1;         //store 1
    di = 2.7;       //store 2, note that the value is truncated
    di = "3";       //store 3
    di = "mcs";     //throws an exception because base type is an integer
    ds = "mcs";     //now its ok because base type is STRING
    ds = "giorgio"; //throws an exception because the string is too long

    //Retrieve values into different data type variables
    struct tm tm;
    di.tval(&tm);

    time_t           tt = di.tval();
    int              ii = di.ival();
    unsigned int     ui = di.uival();
    long long int    il = di.lval();
    unsigned long long int ul = di.ulval();
    float            ff = di.fval();
    string           ss = di.sval();

    char cc[10];
    di.cval(cc, 10);

The Data class features several constructors to allow writing "easy to read" code as well as several methods to perform conversion to/from any allowed data types (see all *val, and set*val methods). Also several assignment operators wraps the set*val methods. Furthermore a Data object can contain either a single value (scalar) or a multi-dimensional array of the same base data type values (see resize(), array(), dim()).

Each Data object has auxiliary informations:

The Data object can be used to access value of a database table, in this case the isAutoIncrement() and isNull() methods provide further information about the underlying database field.

Finally, the Data class extends the Serialize class so it can be serialized to be sent through the network or saved on disk.

Definition at line 3107 of file mcs.hh.


Public Member Functions

unsigned int array (unsigned short int i1=0, unsigned short int i2=0, unsigned short int i3=0, unsigned short int i4=0, unsigned short int i5=0, unsigned short int i6=0, unsigned short int i7=0, unsigned short int i8=0, unsigned short int i9=0, unsigned short int i10=0, unsigned short int i11=0, unsigned short int i12=0, unsigned short int i13=0, unsigned short int i14=0, unsigned short int i15=0)
 Select a cell from the array.
unsigned int arraySize ()
 Return size of array.
void * buffer () const
 Return a pointer to the internal buffer, use this at your own risk.
int cval (char *c, int maxlength) const
 Convert internal data to a NULL terminated string and store it in a buffer.
 Data (void *lbuf)
 Build a Data object from a buffer prepared with Data.prepareBuffer().
 Data (void *lbuf, unsigned int size, unsigned char tag=0)
 Build an object with base type BLOB.
 Data (time_t v, unsigned char tag=0)
 Build an object with base type TIME.
 Data (struct tm v, unsigned char tag=0)
 Build an object with base type TIME.
 Data (string v, unsigned char tag=0)
 Build an object with base type STRING.
 Data (double v, unsigned char tag=0)
 Build an object with base type DOUBLE.
 Data (long long int v, unsigned char tag=0)
 Build an object with base type BIGINT.
 Data (int v, unsigned char tag=0)
 Build an object with base type INT.
 Data (MYSQL_BIND *bind=NULL, Types type=STRING, const char *name="", unsigned short int maxLength=0, bool isunsigned=false, unsigned int flags=0, unsigned char tag=0)
 Constructor used to bind the object with database data.
 Data (Types type, unsigned short int maxLength=0, bool isunsigned=false, string dimSpec="")
 Constructor with specification of base type.
 Data (const Data &from)
 Copy constructor. Note that this will not copy any bind information.
 Data ()
 Build Data object of base type STRING and length zero.
unsigned short int dim (int d)
 Return length of a dimension.
double dval () const
 Convert internal data to a double (8 bytes) floating point value.
void emptyName ()
 Set the object name to an empty string.
float fval () const
 Convert internal data to a floating point value.
int getDestID ()
int getSourceID ()
unsigned char getTag ()
 Retrieve the value of the tag.
unsigned int howManyDim ()
 Return how many dimensions are in the array.
bool isAutoIncrement ()
 Tells if the database field is an auto increment field.
bool isNull ()
 Tells if no value is stored.
bool isUnsigned ()
 Tell if the object contains unsigned integers.
int ival () const
 Convert internal data to a integer value.
unsigned short int length ()
 Return the actual length of the data in the internal buffer.
long long int lval () const
 Convert internal data to a long long integer value.
unsigned short int maxLength ()
 Return the size of the internal buffer.
string name ()
 Return the name of the object.
unsigned int objSize ()
 Return how many bytes require the object to be serialized.
 operator const char * () const
 Wrapper cast operator to pval().
 operator const double () const
 Wrapper cast operator to dval().
 operator const float () const
 Wrapper cast operator to dval().
 operator const int () const
 Wrapper cast operator to ival().
 operator const long long int () const
 Wrapper cast operator to lval().
 operator const string () const
 Wrapper cast operator to sval().
 operator const struct tm () const
 Wrapper cast operator to tval(struct tm).
 operator const time_t () const
 Wrapper cast operator to tval().
 operator const unsigned int () const
 Wrapper cast operator to uival().
 operator const unsigned long long int () const
 Wrapper cast operator to ulval().
Dataoperator() (const int i1=0, const int i2=0, const int i3=0, const int i4=0, const int i5=0, const int i6=0, const int i7=0, const int i8=0, const int i9=0, const int i10=0, const int i11=0, const int i12=0, const int i13=0, const int i14=0, const int i15=0)
 Same as array().
Dataoperator= (Data &d)
 To assign the value of a Data object to another Data object.
Dataoperator= (const time_t v)
 Wrapper assignment operator to settimeval(time_t).
Dataoperator= (const struct tm v)
 Wrapper assignment operator to settimeval(struct tm).
Dataoperator= (const string v)
 Wrapper assignment operator to setsval(string).
Dataoperator= (const char *v)
 Wrapper assignment operator to setsval(string).
Dataoperator= (const double v)
 Wrapper assignment operator to setdval(double).
Dataoperator= (const unsigned long long int v)
 Wrapper assignment operator to setulval(unsigned long long int).
Dataoperator= (const long long int v)
 Wrapper assignment operator to setlval(long long int).
Dataoperator= (const unsigned int v)
 Wrapper assignment operator to setuival(unsigned int).
Dataoperator= (const int v)
 Wrapper assignment operator to setival(int).
string print ()
 Returns a string representation of the object, for debug purpose.
void * pval () const
void resize (string dimSpec)
 Create or resize a multi-dimensional array.
void resizeVaryingDim (unsigned short int newsize)
 Resize variable length dimension.
void setblob (void *lbuf, unsigned int size)
 Copy "size" bytes from the address given in "lbuf" parameter.
void setcval (const char *v)
 Convert string value to base type and store in internal buffer.
void setDestID (int id)
void setdval (double v)
 Convert double value to base type and store in internal buffer.
void setival (int v)
 Convert int value to base type and store in internal buffer.
void setlval (long long int v)
 Convert long int value to base type and store in internal buffer.
void setName (string name)
void setNull (bool null=true)
 Set null flag. Following call to isNull() returns the value used here as parameter.
void setpval (void *p)
void setSourceID (int id)
void setsval (string v)
 Convert string value to base type and store in internal buffer.
void setTag (unsigned char tag)
 Set a new value to internal tag.
void setTimeMode (enum TimeMode tm)
void settimenow ()
 Convert current time value to base type and store in internal buffer.
void settimeval (time_t v)
 Convert time_t value to base type and store in internal buffer.
void settimeval (struct tm v)
 Convert "struct tm" value to base type and store in internal buffer.
void setuival (unsigned int v)
 Convert unsigned int value to base type and store in internal buffer.
void setulval (unsigned long long int v)
 Convert unsigned long int value to base type and store in internal buffer.
string sval (bool addWhiteSpaces=false) const
 Convert internal data to a string object.
void tval (struct tm *t) const
 Convert internal data to a struct tm and store it in a buffer.
time_t tval () const
 Convert internal data to a time_t value.
Types type ()
 Return the base type of the object.
unsigned int uival () const
 Convert internal data to an unsigned integer value.
unsigned long long int ulval () const
 Convert internal data to an unsigned long long integer value.
unsigned int varyingDim ()
 Return the index of the dimension that may vary.
 ~Data ()
 Destructor Frees internal buffer.

Static Public Member Functions

static long long int MaxValue (Types ltype, bool flunsigned)
 Return the maximum integer value for the base type specified.
static long long int MinValue (Types ltype, bool flunsigned)
 Return the minimum integer value for the base type specified.
static void parseTime (string s, struct tm *ts)
 Fills the "struct tm*" passed as argument with the current local datetime.

Private Member Functions

void init (MYSQL_BIND *bind, Types type, const char *name="", unsigned short int maxLength=0, bool isunsigned=false, unsigned int flags=0)
 Initialize internal structures.
void reallocBuffer ()
bool serialize_buffer (char *&from, unsigned int &size)
 Prepare a buffer with all informations contained in the object.

Private Attributes

unsigned int arrpos
 Last selected array cell.
unsigned int arrsize
 Array size, i.e. how many cells are in the array.
char * buf
 Data buffer.
unsigned int bufsize
 Size of data buffer.
DateTime dt
int id_dest
 The userid of the thread that will receive this object.
int id_source
 The userid of the thread who send this object.
bool lautoincr
 If the AUTO_INCREMENT flag is true.
MYSQL_BIND * lbind
 Internal reference to MYSQL_BIND structure.
unsigned short int ldim [15]
 Size of each dimension.
unsigned char ldimspec
 Multi-dimensional array specification.
unsigned int lflags
 Flags (EXPERIMENTAL).
my_bool lisnull
 The object has a null value.
bool lisunsigned
 Base type is unsigned.
unsigned long llength
 Actual length of real data in the buffer, useful only when the base type is a variable length type.
unsigned short int lmaxlength
 Max number of bytes that can be stored in the buffer (size of the buffer).
string lname
 Object name.
Types ltype
 Object base type.
 MCS_DEBUG_ALLOC
unsigned short int mult [15]
 Multiplicative coefficients to calculate arrpos.
unsigned char tag
 Tag for user convenience.

Static Private Attributes

static const char * dafmt = "%04d-%02d-%02d"
 Format to handle date in sprintf/sscanf calls.
static const char * dfmt = "%lf"
 Format to handle double float in sprintf/sscanf calls.
static const char * dtfmt = "%04d-%02d-%02d %02d:%02d:%02g"
 Format to handle datetime in sprintf/sscanf calls.
static const char * ffmt = "%f"
 Format to handle float in sprintf/sscanf calls.
static const char * ifmt = "%d"
 Format to handle integers in sprintf/sscanf calls.
static const char * lfmt = "%ld"
 Format to handle long integers in sprintf/sscanf calls.
static const char * tmfmt = "%02d:%02d:%02g"
 Format to handle time in sprintf/sscanf calls.

Constructor & Destructor Documentation

mcs::Data::Data (  ) 

Build Data object of base type STRING and length zero.

Definition at line 1054 of file Data.cc.

mcs::Data::Data ( const Data from  ) 

Copy constructor. Note that this will not copy any bind information.

Definition at line 1086 of file Data.cc.

mcs::Data::Data ( Types  type,
unsigned short int  maxLength = 0,
bool  isunsigned = false,
string  dimSpec = "" 
)

Constructor with specification of base type.

With this constructor the object will have the base type specified in the parameters but won't have any value stored in the internal buffer, and no bind informations.

Parameters:
type Base type for the object;
maxLength Max length of the object if "type" is a variable length type;
isunsigned Unsigned flag of the object, default is false (so that the data is signed);

Definition at line 1074 of file Data.cc.

mcs::Data::Data ( MYSQL_BIND *  bind = NULL,
Types  type = STRING,
const char *  name = "",
unsigned short int  maxLength = 0,
bool  isunsigned = false,
unsigned int  flags = 0,
unsigned char  tag = 0 
)

Constructor used to bind the object with database data.

Parameters:
bind A bind structure address, retrieved from a Query object. It can be NULL, if the object is not intended for db use;
type Base type for the object;
name Name of the object, this can be NULL for all practical use, it becomes important when the object is created inside a Query object because you can specifiy the name of a parameter or a field instead of its positional index;
maxLength Size of internal buffer when base type is STRING;
isunsigned Unsigned flag of the object, default is false (so that the data is signed);
flags Database flags for the field;
tag Set a new value to internal tag.

Definition at line 1062 of file Data.cc.

mcs::Data::Data ( int  v,
unsigned char  tag = 0 
)

Build an object with base type INT.

Parameters:
v Value to be stored in the object;
tag Optional tag for the object.

Definition at line 1110 of file Data.cc.

mcs::Data::Data ( long long int  v,
unsigned char  tag = 0 
)

Build an object with base type BIGINT.

Parameters:
v Value to be stored in the object;
tag Optional tag for the object.

Definition at line 1120 of file Data.cc.

mcs::Data::Data ( double  v,
unsigned char  tag = 0 
)

Build an object with base type DOUBLE.

Parameters:
v Value to be stored in the object;
tag Optional tag for the object.

Definition at line 1130 of file Data.cc.

mcs::Data::Data ( string  v,
unsigned char  tag = 0 
)

Build an object with base type STRING.

The max length is that of the parameter "v".

Parameters:
v Value to be stored in the object;
tag Optional tag for the object.

Definition at line 1140 of file Data.cc.

mcs::Data::Data ( struct tm  v,
unsigned char  tag = 0 
)

Build an object with base type TIME.

Parameters:
v Value to be stored in the object;
tag Optional tag for the object.

Definition at line 1152 of file Data.cc.

mcs::Data::Data ( time_t  v,
unsigned char  tag = 0 
)

Build an object with base type TIME.

Parameters:
v Value to be stored in the object;
tag Optional tag for the object.

Definition at line 1161 of file Data.cc.

mcs::Data::Data ( void *  lbuf,
unsigned int  size,
unsigned char  tag = 0 
)

Build an object with base type BLOB.

The max length is given by the parameter "size". This constructor also copies "size" bytes from the source "lbuf" to the internal buffer.

Parameters:
lbuf Pointer to the buffer in memory.
size Size of the BLOB.
tag Optional tag for the object.

Definition at line 2504 of file Data.cc.

mcs::Data::Data ( void *  lbuf  ) 

Build a Data object from a buffer prepared with Data.prepareBuffer().

If the argument is NULL, an empty Data object will be created, with the isNull flag to true.

Definition at line 2402 of file Data.cc.

mcs::Data::~Data (  ) 

Destructor Frees internal buffer.

Definition at line 1172 of file Data.cc.


Member Function Documentation

unsigned int mcs::Data::array ( unsigned short int  i1 = 0,
unsigned short int  i2 = 0,
unsigned short int  i3 = 0,
unsigned short int  i4 = 0,
unsigned short int  i5 = 0,
unsigned short int  i6 = 0,
unsigned short int  i7 = 0,
unsigned short int  i8 = 0,
unsigned short int  i9 = 0,
unsigned short int  i10 = 0,
unsigned short int  i11 = 0,
unsigned short int  i12 = 0,
unsigned short int  i13 = 0,
unsigned short int  i14 = 0,
unsigned short int  i15 = 0 
)

Select a cell from the array.

Indexes are all 0-based, so each index must be in the range 0..dim(d) where d is the dimension we are considering.

Definition at line 799 of file Data.cc.

unsigned int mcs::Data::arraySize (  ) 

Return size of array.

That is how many cells are in the array.

Definition at line 903 of file Data.cc.

void * mcs::Data::buffer (  )  const

Return a pointer to the internal buffer, use this at your own risk.

Definition at line 1200 of file Data.cc.

int mcs::Data::cval ( char *  c,
int  maxlength 
) const

Convert internal data to a NULL terminated string and store it in a buffer.

Parameters:
c Address of the buffer.
maxlength Max number of bytes that can be copied in the buffer.
Returns:
Number of bytes copied in the buffer, without accounting for the NULL character.

Definition at line 1614 of file Data.cc.

unsigned short int mcs::Data::dim ( int  d  ) 

Return length of a dimension.

The "d" parameter must be in the range 1..MCS_DATA_NDIM.

Definition at line 891 of file Data.cc.

double mcs::Data::dval (  )  const

Convert internal data to a double (8 bytes) floating point value.

Exceptions:
ERROR MSG_CONVERSION_STRING_FLOAT;
ERROR MSG_CONVERSION_BLOB_FLOAT.

Definition at line 1463 of file Data.cc.

void mcs::Data::emptyName (  ) 

Set the object name to an empty string.

When sent through the network the object will carry its name, consuming bandwidth. With this method you can save some bytes during trasmission.

Definition at line 1178 of file Data.cc.

float mcs::Data::fval (  )  const

Convert internal data to a floating point value.

Exceptions:
ERROR MSG_CONVERSION_STRING_FLOAT;
ERROR MSG_CONVERSION_BLOB_FLOAT.

Definition at line 1432 of file Data.cc.

unsigned char mcs::Data::getTag (  ) 

Retrieve the value of the tag.

Definition at line 2547 of file Data.cc.

unsigned int mcs::Data::howManyDim (  ) 

Return how many dimensions are in the array.

0 means a scalar value, 1 means a one dimensional array (simple array), etc...

Definition at line 654 of file Data.cc.

void mcs::Data::init ( MYSQL_BIND *  bind,
Types  type,
const char *  name = "",
unsigned short int  maxLength = 0,
bool  isunsigned = false,
unsigned int  flags = 0 
) [private]

Initialize internal structures.

Definition at line 954 of file Data.cc.

bool mcs::Data::isAutoIncrement (  ) 

Tells if the database field is an auto increment field.

Definition at line 1199 of file Data.cc.

bool mcs::Data::isNull (  ) 

Tells if no value is stored.

Definition at line 1198 of file Data.cc.

bool mcs::Data::isUnsigned (  ) 

Tell if the object contains unsigned integers.

Definition at line 1197 of file Data.cc.

int mcs::Data::ival (  )  const

Convert internal data to a integer value.

Exceptions:
ERROR MSG_CONVERSION_STRING_INT;
ERROR MSG_CONVERSION_BLOB_INT.

Definition at line 1207 of file Data.cc.

unsigned short int mcs::Data::length (  ) 

Return the actual length of the data in the internal buffer.

Definition at line 1196 of file Data.cc.

long long int mcs::Data::lval (  )  const

Convert internal data to a long long integer value.

Exceptions:
ERROR MSG_CONVERSION_STRING_INT;
ERROR MSG_CONVERSION_BLOB_INT.

Definition at line 1360 of file Data.cc.

unsigned short int mcs::Data::maxLength (  ) 

Return the size of the internal buffer.

Definition at line 1195 of file Data.cc.

long long int mcs::Data::MaxValue ( Types  ltype,
bool  flunsigned 
) [static]

Return the maximum integer value for the base type specified.

Parameters:
ltype Base type for which compute the max value.
flunsigned If the value should be considered unsigned.
Returns:
The max value for a Data object of base type ltype and unsignedness equal to flunsigned.
See also:
enum Types.

Definition at line 2224 of file Data.cc.

long long int mcs::Data::MinValue ( Types  ltype,
bool  flunsigned 
) [static]

Return the minimum integer value for the base type specified.

Parameters:
ltype Base type for which compute the min value.
flunsigned If the value should be considered unsigned.
Returns:
The min value for a Data object of base type ltype and unsignedness equal to flunsigned.
If flunsigned is false this function always returns zero.

See also:
enum Types.

Definition at line 2200 of file Data.cc.

string mcs::Data::name (  ) 

Return the name of the object.

Definition at line 1191 of file Data.cc.

unsigned int mcs::Data::objSize (  ) 

Return how many bytes require the object to be serialized.

Definition at line 2303 of file Data.cc.

mcs::Data::operator const char * (  )  const [inline]

Wrapper cast operator to pval().

Definition at line 3721 of file mcs.hh.

mcs::Data::operator const double (  )  const [inline]

Wrapper cast operator to dval().

Definition at line 3718 of file mcs.hh.

mcs::Data::operator const float (  )  const [inline]

Wrapper cast operator to dval().

Definition at line 3715 of file mcs.hh.

mcs::Data::operator const int (  )  const [inline]

Wrapper cast operator to ival().

Definition at line 3703 of file mcs.hh.

mcs::Data::operator const long long int (  )  const [inline]

Wrapper cast operator to lval().

Definition at line 3709 of file mcs.hh.

mcs::Data::operator const string (  )  const [inline]

Wrapper cast operator to sval().

Definition at line 3724 of file mcs.hh.

mcs::Data::operator const struct tm (  )  const [inline]

Wrapper cast operator to tval(struct tm).

Definition at line 3727 of file mcs.hh.

mcs::Data::operator const time_t (  )  const [inline]

Wrapper cast operator to tval().

Definition at line 3730 of file mcs.hh.

mcs::Data::operator const unsigned int (  )  const [inline]

Wrapper cast operator to uival().

Definition at line 3706 of file mcs.hh.

mcs::Data::operator const unsigned long long int (  )  const [inline]

Wrapper cast operator to ulval().

Definition at line 3712 of file mcs.hh.

Data & mcs::Data::operator() ( const int  i1 = 0,
const int  i2 = 0,
const int  i3 = 0,
const int  i4 = 0,
const int  i5 = 0,
const int  i6 = 0,
const int  i7 = 0,
const int  i8 = 0,
const int  i9 = 0,
const int  i10 = 0,
const int  i11 = 0,
const int  i12 = 0,
const int  i13 = 0,
const int  i14 = 0,
const int  i15 = 0 
)

Same as array().

Definition at line 778 of file Data.cc.

Data & mcs::Data::operator= ( Data d  ) 

To assign the value of a Data object to another Data object.

This operator is used to copy the value of a Data object to another Data object. Note that, as in any other use of the assignment operator, only the value is copied, not all the other settings of a Data object. This operator will be called each time you assign a Data object to another Data object. In the particular cas in which you are creating a Data object with an assignment the copy constructor will be called instead of this.

Definition at line 2250 of file Data.cc.

Data& mcs::Data::operator= ( const time_t  v  )  [inline]

Wrapper assignment operator to settimeval(time_t).

Definition at line 3699 of file mcs.hh.

Data& mcs::Data::operator= ( const struct tm  v  )  [inline]

Wrapper assignment operator to settimeval(struct tm).

Definition at line 3695 of file mcs.hh.

Data& mcs::Data::operator= ( const string  v  )  [inline]

Wrapper assignment operator to setsval(string).

Definition at line 3691 of file mcs.hh.

Data& mcs::Data::operator= ( const char *  v  )  [inline]

Wrapper assignment operator to setsval(string).

Definition at line 3687 of file mcs.hh.

Data& mcs::Data::operator= ( const double  v  )  [inline]

Wrapper assignment operator to setdval(double).

Definition at line 3683 of file mcs.hh.

Data& mcs::Data::operator= ( const unsigned long long int  v  )  [inline]

Wrapper assignment operator to setulval(unsigned long long int).

Definition at line 3679 of file mcs.hh.

Data& mcs::Data::operator= ( const long long int  v  )  [inline]

Wrapper assignment operator to setlval(long long int).

Definition at line 3675 of file mcs.hh.

Data& mcs::Data::operator= ( const unsigned int  v  )  [inline]

Wrapper assignment operator to setuival(unsigned int).

Definition at line 3671 of file mcs.hh.

Data& mcs::Data::operator= ( const int  v  )  [inline]

Wrapper assignment operator to setival(int).

Definition at line 3667 of file mcs.hh.

void mcs::Data::parseTime ( string  s,
struct tm *  ts 
) [static]

Fills the "struct tm*" passed as argument with the current local datetime.

Parse string to extract date time information.

The date time format must be one of: YYYY-MM-DD HH:MM:SS YYYY-MM-DD HH:MM:SS otherwise an exception will be thrown.

Parameters:
s String to be parsed.
ts Address of a struct tm that will be filled with parsed information.
Exceptions:
ERROR MSG_CONVERSION_DATETIME.

Definition at line 1740 of file Data.cc.

string mcs::Data::print (  ) 

Returns a string representation of the object, for debug purpose.

Definition at line 2518 of file Data.cc.

void mcs::Data::resize ( string  dimSpec  ) 

Create or resize a multi-dimensional array.

The array can have as much as MCS_DATA_NDIM dimensions (actually 15), and each dimension can have as much as 65535 positions.

When you call this method you must specify:

All this informations are given in a string formatted using the VOTable specifications (http://www.ivoa.net/Documents/latest/VOT.html) for the "arraysize" attribute of a "FIELD" node.

Some examples are:

Note:
If you try to call this method on a Data object bind to a database field (that is a Data object returned by a Query object) an exception will be thrown.

Definition at line 686 of file Data.cc.

void mcs::Data::resizeVaryingDim ( unsigned short int  newsize  ) 

Resize variable length dimension.

If a dimension is allowed to vary in length (see resize()) you can change its length with this method. If you increase the size of the dimension then all values already present in the array will be preserved and new values will be set to zeroes.

If no dimension is allowed to vary then an exception will be thrown.

Definition at line 911 of file Data.cc.

bool mcs::Data::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 (except for the bind information) using the Data(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.

Reimplemented from mcs::Serializable.

Definition at line 2326 of file Data.cc.

void mcs::Data::setblob ( void *  lbuf,
unsigned int  size 
)

Copy "size" bytes from the address given in "lbuf" parameter.

Definition at line 2184 of file Data.cc.

void mcs::Data::setcval ( const char *  v  ) 

Convert string value to base type and store in internal buffer.

Definition at line 2104 of file Data.cc.

void mcs::Data::setdval ( double  v  ) 

Convert double value to base type and store in internal buffer.

Definition at line 2051 of file Data.cc.

void mcs::Data::setival ( int  v  ) 

Convert int value to base type and store in internal buffer.

Definition at line 1927 of file Data.cc.

void mcs::Data::setlval ( long long int  v  ) 

Convert long int value to base type and store in internal buffer.

Definition at line 1937 of file Data.cc.

void mcs::Data::setNull ( bool  null = true  ) 

Set null flag. Following call to isNull() returns the value used here as parameter.

Definition at line 1921 of file Data.cc.

void mcs::Data::setsval ( string  v  ) 

Convert string value to base type and store in internal buffer.

Definition at line 2111 of file Data.cc.

void mcs::Data::setTag ( unsigned char  tag  ) 

Set a new value to internal tag.

Definition at line 2542 of file Data.cc.

void mcs::Data::settimenow (  ) 

Convert current time value to base type and store in internal buffer.

Definition at line 1844 of file Data.cc.

void mcs::Data::settimeval ( time_t  v  ) 

Convert time_t value to base type and store in internal buffer.

Definition at line 1899 of file Data.cc.

void mcs::Data::settimeval ( struct tm  v  ) 

Convert "struct tm" value to base type and store in internal buffer.

void mcs::Data::setuival ( unsigned int  v  ) 

Convert unsigned int value to base type and store in internal buffer.

Definition at line 1932 of file Data.cc.

void mcs::Data::setulval ( unsigned long long int  v  ) 

Convert unsigned long int value to base type and store in internal buffer.

Definition at line 1993 of file Data.cc.

string mcs::Data::sval ( bool  addWhiteSpaces = false  )  const

Convert internal data to a string object.

Parameters:
addWhiteSpaces If true a number of spaces will be added to pad to maxLength bytes.

Definition at line 1553 of file Data.cc.

void mcs::Data::tval ( struct tm *  t  )  const

Convert internal data to a struct tm and store it in a buffer.

Parameters:
t Address of the buffer.
Exceptions:
ERROR MSG_CONVERSION_BLOB_DATETIME

Definition at line 1816 of file Data.cc.

time_t mcs::Data::tval (  )  const

Convert internal data to a time_t value.

Definition at line 1836 of file Data.cc.

Types mcs::Data::type (  ) 

Return the base type of the object.

Definition at line 1194 of file Data.cc.

unsigned int mcs::Data::uival (  )  const

Convert internal data to an unsigned integer value.

Exceptions:
ERROR MSG_CONVERSION_STRING_INT;
ERROR MSG_CONVERSION_BLOB_INT.

Definition at line 1307 of file Data.cc.

unsigned long long int mcs::Data::ulval (  )  const

Convert internal data to an unsigned long long integer value.

Exceptions:
ERROR MSG_CONVERSION_STRING_INT;
ERROR MSG_CONVERSION_BLOB_INT.

Definition at line 1395 of file Data.cc.

unsigned int mcs::Data::varyingDim (  ) 

Return the index of the dimension that may vary.

The last dimension of the multi-dimensional array may vary in length (see resizeVaryingDim()) if it is allowed to do so. This method returns the index of the dimension which is allowed to vary in the 1..MCS_DATA_NDIM range, or 0 if no dimension can change.

Definition at line 659 of file Data.cc.


Member Data Documentation

unsigned int mcs::Data::arrpos [private]

Last selected array cell.

Definition at line 3232 of file mcs.hh.

unsigned int mcs::Data::arrsize [private]

Array size, i.e. how many cells are in the array.

Definition at line 3229 of file mcs.hh.

char* mcs::Data::buf [private]

Data buffer.

Reimplemented from mcs::Serializable.

Definition at line 3150 of file mcs.hh.

unsigned int mcs::Data::bufsize [private]

Size of data buffer.

Definition at line 3153 of file mcs.hh.

const char * mcs::Data::dafmt = "%04d-%02d-%02d" [static, private]

Format to handle date in sprintf/sscanf calls.

Definition at line 3159 of file mcs.hh.

const char * mcs::Data::dfmt = "%lf" [static, private]

Format to handle double float in sprintf/sscanf calls.

Definition at line 3174 of file mcs.hh.

const char * mcs::Data::dtfmt = "%04d-%02d-%02d %02d:%02d:%02g" [static, private]

Format to handle datetime in sprintf/sscanf calls.

Definition at line 3156 of file mcs.hh.

const char * mcs::Data::ffmt = "%f" [static, private]

Format to handle float in sprintf/sscanf calls.

Definition at line 3171 of file mcs.hh.

int mcs::Data::id_dest [private]

The userid of the thread that will receive this object.

Definition at line 3213 of file mcs.hh.

int mcs::Data::id_source [private]

The userid of the thread who send this object.

Definition at line 3210 of file mcs.hh.

const char * mcs::Data::ifmt = "%d" [static, private]

Format to handle integers in sprintf/sscanf calls.

Definition at line 3165 of file mcs.hh.

bool mcs::Data::lautoincr [private]

If the AUTO_INCREMENT flag is true.

Definition at line 3144 of file mcs.hh.

MYSQL_BIND* mcs::Data::lbind [private]

Internal reference to MYSQL_BIND structure.

Definition at line 3116 of file mcs.hh.

unsigned short int mcs::Data::ldim[15] [private]

Size of each dimension.

Definition at line 3223 of file mcs.hh.

unsigned char mcs::Data::ldimspec [private]

Multi-dimensional array specification.

Higher 4 bits: varyingDim, Lower 4 bits: howManyDim

Definition at line 3220 of file mcs.hh.

unsigned int mcs::Data::lflags [private]

Flags (EXPERIMENTAL).

Definition at line 3126 of file mcs.hh.

const char * mcs::Data::lfmt = "%ld" [static, private]

Format to handle long integers in sprintf/sscanf calls.

Definition at line 3168 of file mcs.hh.

my_bool mcs::Data::lisnull [private]

The object has a null value.

Definition at line 3141 of file mcs.hh.

bool mcs::Data::lisunsigned [private]

Base type is unsigned.

Definition at line 3138 of file mcs.hh.

unsigned long mcs::Data::llength [private]

Actual length of real data in the buffer, useful only when the base type is a variable length type.

Definition at line 3135 of file mcs.hh.

unsigned short int mcs::Data::lmaxlength [private]

Max number of bytes that can be stored in the buffer (size of the buffer).

Definition at line 3129 of file mcs.hh.

string mcs::Data::lname [private]

Object name.

Definition at line 3123 of file mcs.hh.

Types mcs::Data::ltype [private]

Object base type.

Definition at line 3120 of file mcs.hh.

unsigned short int mcs::Data::mult[15] [private]

Multiplicative coefficients to calculate arrpos.

Definition at line 3226 of file mcs.hh.

unsigned char mcs::Data::tag [private]

Tag for user convenience.

Definition at line 3147 of file mcs.hh.

const char * mcs::Data::tmfmt = "%02d:%02d:%02g" [static, private]

Format to handle time in sprintf/sscanf calls.

Definition at line 3162 of file mcs.hh.


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

MCS (My Customizable Server) ver. 0.3.3-alpha3
Documentation generated on Thu Mar 22 13:22:23 UTC 2012