MCS  0.3.3-alpha7
mcs::Data Class Reference

A general purpose data type. More...

#include <mcs.hh>

+ Inheritance diagram for mcs::Data:

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. More...
 
unsigned int arraySize ()
 Return size of array. More...
 
void * buffer () const
 Return a pointer to the internal buffer, use this at your own risk. More...
 
int cval (char *c, int maxlength) const
 Convert internal data to a NULL terminated string and store it in a buffer. More...
 
 Data ()
 Build Data object of base type STRING and length zero. More...
 
 Data (const Data &from)
 Copy constructor. Note that this will not copy any bind information. More...
 
 Data (Types type, unsigned short int maxLength=0, bool isunsigned=false, string dimSpec="")
 Constructor with specification of base type. More...
 
 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. More...
 
 Data (int v, unsigned char tag=0)
 Build an object with base type INT. More...
 
 Data (long long int v, unsigned char tag=0)
 Build an object with base type BIGINT. More...
 
 Data (double v, unsigned char tag=0)
 Build an object with base type DOUBLE. More...
 
 Data (string v, unsigned char tag=0)
 Build an object with base type STRING. More...
 
 Data (struct tm v, unsigned char tag=0)
 Build an object with base type TIME. More...
 
 Data (time_t v, unsigned char tag=0)
 Build an object with base type TIME. More...
 
 Data (void *lbuf, unsigned int size, unsigned char tag=0)
 Build an object with base type BLOB. More...
 
 Data (void *lbuf)
 Build a Data object from a buffer prepared with Data.prepareBuffer(). More...
 
unsigned short int dim (int d)
 Return length of a dimension. More...
 
double dval () const
 Convert internal data to a double (8 bytes) floating point value. More...
 
void emptyName ()
 Set the object name to an empty string. More...
 
float fval () const
 Convert internal data to a floating point value. More...
 
int getDestID ()
 
int getSourceID ()
 
unsigned char getTag ()
 Retrieve the value of the tag. More...
 
unsigned int howManyDim ()
 Return how many dimensions are in the array. More...
 
bool isAutoIncrement ()
 Tells if the database field is an auto increment field. More...
 
bool isNull ()
 Tells if no value is stored. More...
 
bool isUnsigned ()
 Tell if the object contains unsigned integers. More...
 
int ival () const
 Convert internal data to a integer value. More...
 
unsigned short int length ()
 Return the actual length of the data in the internal buffer. More...
 
long long int lval () const
 Convert internal data to a long long integer value. More...
 
unsigned short int maxLength ()
 Return the size of the internal buffer. More...
 
string name ()
 Return the name of the object. More...
 
unsigned int objSize ()
 Return how many bytes require the object to be serialized. More...
 
 operator const char * () const
 Wrapper cast operator to pval() More...
 
 operator const double () const
 Wrapper cast operator to dval() More...
 
 operator const float () const
 Wrapper cast operator to dval() More...
 
 operator const int () const
 Wrapper cast operator to ival() More...
 
 operator const long long int () const
 Wrapper cast operator to lval() More...
 
 operator const string () const
 Wrapper cast operator to sval() More...
 
 operator const struct tm () const
 Wrapper cast operator to tval(struct tm) More...
 
 operator const time_t () const
 Wrapper cast operator to tval() More...
 
 operator const unsigned int () const
 Wrapper cast operator to uival() More...
 
 operator const unsigned long long int () const
 Wrapper cast operator to ulval() More...
 
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(). More...
 
Dataoperator= (const int v)
 Wrapper assignment operator to setival(int). More...
 
Dataoperator= (const unsigned int v)
 Wrapper assignment operator to setuival(unsigned int). More...
 
Dataoperator= (const long long int v)
 Wrapper assignment operator to setlval(long long int). More...
 
Dataoperator= (const unsigned long long int v)
 Wrapper assignment operator to setulval(unsigned long long int). More...
 
Dataoperator= (const double v)
 Wrapper assignment operator to setdval(double). More...
 
Dataoperator= (const char *v)
 Wrapper assignment operator to setsval(string) More...
 
Dataoperator= (const string v)
 Wrapper assignment operator to setsval(string). More...
 
Dataoperator= (const struct tm v)
 Wrapper assignment operator to settimeval(struct tm) More...
 
Dataoperator= (const time_t v)
 Wrapper assignment operator to settimeval(time_t) More...
 
Dataoperator= (Data &d)
 To assign the value of a Data object to another Data object. More...
 
string print ()
 Returns a string representation of the object, for debug purpose. More...
 
void * pval () const
 
void resize (string dimSpec)
 Create or resize a multi-dimensional array. More...
 
void resizeVaryingDim (unsigned short int newsize)
 Resize variable length dimension. More...
 
void setblob (void *lbuf, unsigned int size)
 Copy "size" bytes from the address given in "lbuf" parameter. More...
 
void setcval (const char *v)
 Convert string value to base type and store in internal buffer. More...
 
void setDestID (int id)
 
void setdval (double v)
 Convert double value to base type and store in internal buffer. More...
 
void setival (int v)
 Convert int value to base type and store in internal buffer. More...
 
void setlval (long long int v)
 Convert long int value to base type and store in internal buffer. More...
 
void setName (string name)
 
void setNull (bool null=true)
 Set null flag. Following call to isNull() returns the value used here as parameter. More...
 
void setpval (void *p)
 
void setSourceID (int id)
 
void setsval (string v)
 Convert string value to base type and store in internal buffer. More...
 
void setTag (unsigned char tag)
 Set a new value to internal tag. More...
 
void setTimeMode (enum TimeMode tm)
 
void settimenow ()
 Convert current time value to base type and store in internal buffer. More...
 
void settimeval (struct tm v)
 Convert "struct tm" value to base type and store in internal buffer. More...
 
void settimeval (time_t v)
 Convert time_t value to base type and store in internal buffer. More...
 
void setuival (unsigned int v)
 Convert unsigned int value to base type and store in internal buffer. More...
 
void setulval (unsigned long long int v)
 Convert unsigned long int value to base type and store in internal buffer. More...
 
string sval (bool addWhiteSpaces=false) const
 Convert internal data to a string object. More...
 
time_t tval () const
 Convert internal data to a time_t value. More...
 
void tval (struct tm *t) const
 Convert internal data to a struct tm and store it in a buffer. More...
 
Types type ()
 Return the base type of the object. More...
 
unsigned int uival () const
 Convert internal data to an unsigned integer value. More...
 
unsigned long long int ulval () const
 Convert internal data to an unsigned long long integer value. More...
 
unsigned int varyingDim ()
 Return the index of the dimension that may vary. More...
 
 ~Data ()
 Destructor Frees internal buffer. More...
 
- Public Member Functions inherited from mcs::Serializable
void * getEntireBuffer (unsigned int &size)
 
bool knowSize ()
 Reinitialize internal data. More...
 
unsigned int maxChunkSize ()
 Return the max size allowed for a chunk. More...
 
unsigned int nChunk ()
 If knowSize() is true, return how many chunks are required to send all data. More...
 
void * nextChunk (unsigned int &chunksize)
 Fills a buffer with next chunk to be sent. More...
 
Serializableoperator= (const Serializable &)
 Declared to avoid using of default assignment operator. More...
 
 Serializable (const Serializable &)
 Declared to avoid using of default copy constructor. More...
 
 Serializable (unsigned int lmaxChunksize=16384)
 Constructor, for custom data (type = SERIAL_UNKNOWN). More...
 
 Serializable (void *from, unsigned int size, bool freeAfterUse, unsigned int lmaxChunksize=16384)
 Constructor, for memory buffers (type = SERIAL_BUFFER). More...
 
 Serializable (string filename, unsigned int lmaxChunksize=16384)
 Constructor, for files (type = SERIAL_FILENAME). More...
 
 Serializable (int type, unsigned int lmaxChunksize=16384)
 
unsigned int size ()
 If knowSize() is true, return the size of the entire block of data. More...
 
virtual ~Serializable ()
 Destructor. More...
 

Static Public Member Functions

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

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. More...
 
void reallocBuffer ()
 
bool serialize_buffer (char *&from, unsigned int &size)
 Prepare a buffer with all informations contained in the object. More...
 

Private Attributes

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

Static Private Attributes

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

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 3092 of file mcs.hh.

Constructor & Destructor Documentation

◆ Data() [1/12]

mcs::Data::Data ( )

Build Data object of base type STRING and length zero.

Definition at line 1056 of file Data.cc.

◆ Data() [2/12]

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

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

Definition at line 1088 of file Data.cc.

◆ Data() [3/12]

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
typeBase type for the object;
maxLengthMax length of the object if "type" is a variable length type;
isunsignedUnsigned flag of the object, default is false (so that the data is signed);

Definition at line 1076 of file Data.cc.

◆ Data() [4/12]

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
bindA bind structure address, retrieved from a Query object. It can be NULL, if the object is not intended for db use;
typeBase type for the object;
nameName 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;
maxLengthSize of internal buffer when base type is STRING;
isunsignedUnsigned flag of the object, default is false (so that the data is signed);
flagsDatabase flags for the field;
tagSet a new value to internal tag.

Definition at line 1064 of file Data.cc.

◆ Data() [5/12]

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

Build an object with base type INT.

Parameters
vValue to be stored in the object;
tagOptional tag for the object.

Definition at line 1112 of file Data.cc.

◆ Data() [6/12]

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

Build an object with base type BIGINT.

Parameters
vValue to be stored in the object;
tagOptional tag for the object.

Definition at line 1122 of file Data.cc.

◆ Data() [7/12]

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

Build an object with base type DOUBLE.

Parameters
vValue to be stored in the object;
tagOptional tag for the object.

Definition at line 1132 of file Data.cc.

◆ Data() [8/12]

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
vValue to be stored in the object;
tagOptional tag for the object.

Definition at line 1142 of file Data.cc.

◆ Data() [9/12]

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

Build an object with base type TIME.

Parameters
vValue to be stored in the object;
tagOptional tag for the object.

Definition at line 1154 of file Data.cc.

◆ Data() [10/12]

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

Build an object with base type TIME.

Parameters
vValue to be stored in the object;
tagOptional tag for the object.

Definition at line 1163 of file Data.cc.

◆ Data() [11/12]

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
lbufPointer to the buffer in memory.
sizeSize of the BLOB.
tagOptional tag for the object.

Definition at line 2506 of file Data.cc.

◆ Data() [12/12]

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 2404 of file Data.cc.

◆ ~Data()

mcs::Data::~Data ( )

Destructor Frees internal buffer.

Definition at line 1174 of file Data.cc.

Member Function Documentation

◆ array()

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 801 of file Data.cc.

◆ arraySize()

unsigned int mcs::Data::arraySize ( )

Return size of array.

That is how many cells are in the array.

Definition at line 905 of file Data.cc.

◆ buffer()

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

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

Definition at line 1202 of file Data.cc.

◆ cval()

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

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

Parameters
cAddress of the buffer.
maxlengthMax 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 1616 of file Data.cc.

◆ dim()

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 893 of file Data.cc.

◆ dval()

double mcs::Data::dval ( ) const

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

Exceptions
ERRORMSG_CONVERSION_STRING_FLOAT;
ERRORMSG_CONVERSION_BLOB_FLOAT.

Definition at line 1465 of file Data.cc.

◆ emptyName()

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 1180 of file Data.cc.

◆ fval()

float mcs::Data::fval ( ) const

Convert internal data to a floating point value.

Exceptions
ERRORMSG_CONVERSION_STRING_FLOAT;
ERRORMSG_CONVERSION_BLOB_FLOAT.

Definition at line 1434 of file Data.cc.

◆ getTag()

unsigned char mcs::Data::getTag ( )

Retrieve the value of the tag.

Definition at line 2549 of file Data.cc.

◆ howManyDim()

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 656 of file Data.cc.

◆ init()

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 956 of file Data.cc.

◆ isAutoIncrement()

bool mcs::Data::isAutoIncrement ( )

Tells if the database field is an auto increment field.

Definition at line 1201 of file Data.cc.

◆ isNull()

bool mcs::Data::isNull ( )

Tells if no value is stored.

Definition at line 1200 of file Data.cc.

◆ isUnsigned()

bool mcs::Data::isUnsigned ( )

Tell if the object contains unsigned integers.

Definition at line 1199 of file Data.cc.

◆ ival()

int mcs::Data::ival ( ) const

Convert internal data to a integer value.

Exceptions
ERRORMSG_CONVERSION_STRING_INT;
ERRORMSG_CONVERSION_BLOB_INT.

Definition at line 1209 of file Data.cc.

◆ length()

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

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

Definition at line 1198 of file Data.cc.

◆ lval()

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

Convert internal data to a long long integer value.

Exceptions
ERRORMSG_CONVERSION_STRING_INT;
ERRORMSG_CONVERSION_BLOB_INT.

Definition at line 1362 of file Data.cc.

◆ maxLength()

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

Return the size of the internal buffer.

Definition at line 1197 of file Data.cc.

◆ MaxValue()

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

Return the maximum integer value for the base type specified.

Parameters
ltypeBase type for which compute the max value.
flunsignedIf 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 2226 of file Data.cc.

◆ MinValue()

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

Return the minimum integer value for the base type specified.

Parameters
ltypeBase type for which compute the min value.
flunsignedIf 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 2202 of file Data.cc.

◆ name()

string mcs::Data::name ( )

Return the name of the object.

Definition at line 1193 of file Data.cc.

◆ objSize()

unsigned int mcs::Data::objSize ( )

Return how many bytes require the object to be serialized.

Definition at line 2305 of file Data.cc.

◆ operator const char *()

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

Wrapper cast operator to pval()

Definition at line 3707 of file mcs.hh.

◆ operator const double()

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

Wrapper cast operator to dval()

Definition at line 3704 of file mcs.hh.

◆ operator const float()

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

Wrapper cast operator to dval()

Definition at line 3701 of file mcs.hh.

◆ operator const int()

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

Wrapper cast operator to ival()

Definition at line 3689 of file mcs.hh.

◆ operator const long long int()

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

Wrapper cast operator to lval()

Definition at line 3695 of file mcs.hh.

◆ operator const string()

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

Wrapper cast operator to sval()

Definition at line 3710 of file mcs.hh.

◆ operator const struct tm()

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

Wrapper cast operator to tval(struct tm)

Definition at line 3713 of file mcs.hh.

◆ operator const time_t()

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

Wrapper cast operator to tval()

Definition at line 3716 of file mcs.hh.

◆ operator const unsigned int()

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

Wrapper cast operator to uival()

Definition at line 3692 of file mcs.hh.

◆ operator const unsigned long long int()

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

Wrapper cast operator to ulval()

Definition at line 3698 of file mcs.hh.

◆ operator()()

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 780 of file Data.cc.

◆ operator=() [1/10]

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

Wrapper assignment operator to setival(int).

Definition at line 3653 of file mcs.hh.

◆ operator=() [2/10]

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

Wrapper assignment operator to setuival(unsigned int).

Definition at line 3657 of file mcs.hh.

◆ operator=() [3/10]

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

Wrapper assignment operator to setlval(long long int).

Definition at line 3661 of file mcs.hh.

◆ operator=() [4/10]

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

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

Definition at line 3665 of file mcs.hh.

◆ operator=() [5/10]

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

Wrapper assignment operator to setdval(double).

Definition at line 3669 of file mcs.hh.

◆ operator=() [6/10]

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

Wrapper assignment operator to setsval(string)

Definition at line 3673 of file mcs.hh.

◆ operator=() [7/10]

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

Wrapper assignment operator to setsval(string).

Definition at line 3677 of file mcs.hh.

◆ operator=() [8/10]

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

Wrapper assignment operator to settimeval(struct tm)

Definition at line 3681 of file mcs.hh.

◆ operator=() [9/10]

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

Wrapper assignment operator to settimeval(time_t)

Definition at line 3685 of file mcs.hh.

◆ operator=() [10/10]

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 2252 of file Data.cc.

◆ parseTime()

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
sString to be parsed.
tsAddress of a struct tm that will be filled with parsed information.
Exceptions
ERRORMSG_CONVERSION_DATETIME.

Definition at line 1742 of file Data.cc.

◆ print()

string mcs::Data::print ( )

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

Definition at line 2520 of file Data.cc.

◆ resize()

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:

  • the number of dimensions for the array;
  • the length of each dimensions;
  • optionally if the last dimension is variable in length.

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:

  • "10", one dimension of length 10;
  • "10x3", two dimensions of length 10 and 3 respectively;
  • "10x3x5*", three dimensions of of length 10, 3 and 5 respectively, but the last one is variable in length.
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 688 of file Data.cc.

◆ resizeVaryingDim()

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 913 of file Data.cc.

◆ serialize_buffer()

bool mcs::Data::serialize_buffer ( char *&  from,
unsigned int &  size 
)
privatevirtual

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
lbufAddress of a pointer to a buffer;
sizeSize of the buffer if it should not be allocated.
Returns
Size of the data in the buffer.
Exceptions
ERRORMSG_NOT_ENOUGH_SPACE.

Reimplemented from mcs::Serializable.

Definition at line 2328 of file Data.cc.

◆ setblob()

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

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

Definition at line 2186 of file Data.cc.

◆ setcval()

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

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

Definition at line 2106 of file Data.cc.

◆ setdval()

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

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

Definition at line 2053 of file Data.cc.

◆ setival()

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

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

Definition at line 1929 of file Data.cc.

◆ setlval()

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

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

Definition at line 1939 of file Data.cc.

◆ setNull()

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

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

Definition at line 1923 of file Data.cc.

◆ setsval()

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

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

Definition at line 2113 of file Data.cc.

◆ setTag()

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

Set a new value to internal tag.

Definition at line 2544 of file Data.cc.

◆ settimenow()

void mcs::Data::settimenow ( )

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

Definition at line 1846 of file Data.cc.

◆ settimeval() [1/2]

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

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

◆ settimeval() [2/2]

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

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

Definition at line 1901 of file Data.cc.

◆ setuival()

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

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

Definition at line 1934 of file Data.cc.

◆ setulval()

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 1995 of file Data.cc.

◆ sval()

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

Convert internal data to a string object.

Parameters
addWhiteSpacesIf true a number of spaces will be added to pad to maxLength bytes.

Definition at line 1555 of file Data.cc.

◆ tval() [1/2]

time_t mcs::Data::tval ( ) const

Convert internal data to a time_t value.

Definition at line 1838 of file Data.cc.

◆ tval() [2/2]

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

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

Parameters
tAddress of the buffer.
Exceptions
ERRORMSG_CONVERSION_BLOB_DATETIME

Definition at line 1818 of file Data.cc.

◆ type()

Types mcs::Data::type ( )

Return the base type of the object.

Definition at line 1196 of file Data.cc.

◆ uival()

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

Convert internal data to an unsigned integer value.

Exceptions
ERRORMSG_CONVERSION_STRING_INT;
ERRORMSG_CONVERSION_BLOB_INT.

Definition at line 1309 of file Data.cc.

◆ ulval()

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

Convert internal data to an unsigned long long integer value.

Exceptions
ERRORMSG_CONVERSION_STRING_INT;
ERRORMSG_CONVERSION_BLOB_INT.

Definition at line 1397 of file Data.cc.

◆ varyingDim()

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 661 of file Data.cc.

Member Data Documentation

◆ arrpos

unsigned int mcs::Data::arrpos
private

Last selected array cell.

Definition at line 3218 of file mcs.hh.

◆ arrsize

unsigned int mcs::Data::arrsize
private

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

Definition at line 3215 of file mcs.hh.

◆ buf

char* mcs::Data::buf
private

Data buffer.

Definition at line 3136 of file mcs.hh.

◆ bufsize

unsigned int mcs::Data::bufsize
private

Size of data buffer.

Definition at line 3139 of file mcs.hh.

◆ dafmt

const char * mcs::Data::dafmt = "%04d-%02d-%02d"
staticprivate

Format to handle date in sprintf/sscanf calls.

Definition at line 3145 of file mcs.hh.

◆ dfmt

const char * mcs::Data::dfmt = "%lf"
staticprivate

Format to handle double float in sprintf/sscanf calls.

Definition at line 3160 of file mcs.hh.

◆ dtfmt

const char * mcs::Data::dtfmt = "%04d-%02d-%02d %02d:%02d:%02g"
staticprivate

Format to handle datetime in sprintf/sscanf calls.

Definition at line 3142 of file mcs.hh.

◆ ffmt

const char * mcs::Data::ffmt = "%f"
staticprivate

Format to handle float in sprintf/sscanf calls.

Definition at line 3157 of file mcs.hh.

◆ id_dest

int mcs::Data::id_dest
private

The userid of the thread that will receive this object.

Definition at line 3199 of file mcs.hh.

◆ id_source

int mcs::Data::id_source
private

The userid of the thread who send this object.

Definition at line 3196 of file mcs.hh.

◆ ifmt

const char * mcs::Data::ifmt = "%d"
staticprivate

Format to handle integers in sprintf/sscanf calls.

Definition at line 3151 of file mcs.hh.

◆ lautoincr

bool mcs::Data::lautoincr
private

If the AUTO_INCREMENT flag is true.

Definition at line 3130 of file mcs.hh.

◆ lbind

MYSQL_BIND* mcs::Data::lbind
private

Internal reference to MYSQL_BIND structure.

Definition at line 3101 of file mcs.hh.

◆ ldim

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

Size of each dimension.

Definition at line 3209 of file mcs.hh.

◆ ldimspec

unsigned char mcs::Data::ldimspec
private

Multi-dimensional array specification.

Higher 4 bits: varyingDim, Lower 4 bits: howManyDim

Definition at line 3206 of file mcs.hh.

◆ lflags

unsigned int mcs::Data::lflags
private

Flags (EXPERIMENTAL).

Definition at line 3111 of file mcs.hh.

◆ lfmt

const char * mcs::Data::lfmt = "%ld"
staticprivate

Format to handle long integers in sprintf/sscanf calls.

Definition at line 3154 of file mcs.hh.

◆ lisnull

my_bool mcs::Data::lisnull
private

The object has a null value.

Definition at line 3127 of file mcs.hh.

◆ lisunsigned

bool mcs::Data::lisunsigned
private

Base type is unsigned.

Definition at line 3124 of file mcs.hh.

◆ llength

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 3121 of file mcs.hh.

◆ lmaxlength

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 3115 of file mcs.hh.

◆ lname

string mcs::Data::lname
private

Object name.

Definition at line 3108 of file mcs.hh.

◆ ltype

Types mcs::Data::ltype
private

Object base type.

Definition at line 3105 of file mcs.hh.

◆ mult

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

Multiplicative coefficients to calculate arrpos.

Definition at line 3212 of file mcs.hh.

◆ tag

unsigned char mcs::Data::tag
private

Tag for user convenience.

Definition at line 3133 of file mcs.hh.

◆ tmfmt

const char * mcs::Data::tmfmt = "%02d:%02d:%02g"
staticprivate

Format to handle time in sprintf/sscanf calls.

Definition at line 3148 of file mcs.hh.


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

mcslogo

MCS (My Customizable Server) ver. 0.3.3-alpha7
Documentation generated on Mon May 28 07:39:41 UTC 2018