StRoot
1
|
Public Types | |
enum | EDataType { kINVALID =0, kBOOL, kINT, kUINT, kLONG, kULONG, kDOUBLE, kCHAR, kUNIXTIME, kSTRING, kEND } |
Public Member Functions | |
StDbFieldI (const char *name, StDbFieldI::EDataType type, int length=0) | |
StDbFieldI (const char *name, const char *value, StDbFieldI::EDataType type, int length=0) | |
StDbFieldI (const StDbFieldI &) | |
const StDbFieldI & | operator= (const StDbFieldI &) |
virtual | ~StDbFieldI () |
Deconstructor. More... | |
const char * | getName () const |
const char * | fieldAsString () const |
void | setValue (const int &value) |
void | setValue (const unsigned int &value) |
void | setValue (const long &value) |
void | setValue (const unsigned long &value) |
void | setValue (const double &value) |
void | setValue (const char &value) |
int | toInt () const |
unsigned | toUInt () const |
long | toLong () const |
unsigned long | toULong () const |
double | toDouble () const |
char | toChar () const |
void | setValueFromString (const char *strValue) |
EDataType | getType () const |
int | getMaxLength () const |
const char * | getTypeAsString () const |
const char * | getValueAsString () const |
bool | isNull () const |
void | setNull (bool Nil) |
void | setIgnore (bool ignore) |
bool | isIgnore () const |
Protected Member Functions | |
template<class T > | |
StDbFieldI (const char *name, const T &value, int length) | |
template<class T > | |
void | setValue (const T &value) |
template<class T > | |
T | toValue () const |
Friends | |
class | TxLogging::Init_StDbFieldI |
Definition at line 50 of file StDbFieldI.h.
List of types supported by UCM. The INVALID type is provided to set an error state with the data, and is explicitly defined as 0 for use in conditionals (if !INVALID). Used to abstract typeid. TODO: Since values are stored as a string right now, we may need to add BLOB support in some other way if/when required.
Definition at line 60 of file StDbFieldI.h.
StDbFieldI::StDbFieldI | ( | const char * | name, |
StDbFieldI::EDataType | type, | ||
int | length = 0 |
||
) |
Constructor: Creates a field with the specified name and type, but with an empty value.
name | The name of the field. |
type | The field type, as a TxEType. |
length | The field length. Not optional for STRING type. |
Definition at line 52 of file StDbFieldI.cxx.
StDbFieldI::StDbFieldI | ( | const char * | name, |
const char * | value, | ||
StDbFieldI::EDataType | type, | ||
int | length = 0 |
||
) |
Constructor: The constructor takes an argument of type T, and
bool all signed integer types (stored as long) all unsigned integer types (stored as ulong) (signed) float types (stored as double) char
All other types will throw a StDataException and set the variant type as INVALID. Note that once a StDbFieldI has its datatype set, it cannot be changed.
name | The name of the field. |
value | The value to encode in the variant. |
length | Non-optional for strings; sets the max length of the string. Constructor: Creates a complete field. Note that it may not be typesafe. |
name | The name of the field. |
type | The type of the field. Note that in this constructor the user is responsible for ensuring type safety. |
value | The value of the field. |
length | The length of the field. Not optional for STRING type. |
Definition at line 91 of file StDbFieldI.cxx.
References setValueFromString().
StDbFieldI::StDbFieldI | ( | const StDbFieldI & | f | ) |
Copy operators: Copy constructor and operator=.
Definition at line 134 of file StDbFieldI.cxx.
|
virtual |
const char * StDbFieldI::fieldAsString | ( | ) | const |
Returns the field information in the form (name)::(type)::(value). Included for debugging purposes.
Definition at line 173 of file StDbFieldI.cxx.
References getName(), getTypeAsString(), and getValueAsString().
int StDbFieldI::getMaxLength | ( | ) | const |
Returns the max length of the field for those of type STRING.
Definition at line 249 of file StDbFieldI.cxx.
const char * StDbFieldI::getName | ( | ) | const |
Returns the name of the field.
Definition at line 166 of file StDbFieldI.cxx.
Referenced by fieldAsString().
StDbFieldI::EDataType StDbFieldI::getType | ( | ) | const |
Returns the type information of the field. Useful for type safety and returning a true value.
Definition at line 205 of file StDbFieldI.cxx.
Referenced by getTypeAsString().
const char * StDbFieldI::getTypeAsString | ( | ) | const |
Returns the type information of the field as a human-readable string.
Definition at line 241 of file StDbFieldI.cxx.
References getType().
Referenced by fieldAsString().
const char * StDbFieldI::getValueAsString | ( | ) | const |
Returns the value of the field in its encoded string form. Note that this may not be safe in all situations: The store may treat the string "123" differently from the integer 123, although both have the same internal string representation.
Definition at line 213 of file StDbFieldI.cxx.
Referenced by fieldAsString().
bool StDbFieldI::isIgnore | ( | ) | const |
Returns true if the field will be ignored when performing execute operations.
Definition at line 256 of file StDbFieldI.cxx.
bool StDbFieldI::isNull | ( | ) | const |
Returns true if the field represents a NULL value.
Definition at line 220 of file StDbFieldI.cxx.
void StDbFieldI::setIgnore | ( | bool | ignore | ) |
Sets whether or not the field should be ignored when performing execute operations. Alternative to TxRecord's 'removeField'. TODO: Move to TxRecord?
ignore | Whether or not to ignore the field in operations. |
Definition at line 262 of file StDbFieldI.cxx.
void StDbFieldI::setNull | ( | bool | Nil | ) |
Sets whether or not the field is a NULL value. Implicitly sets the IGNORE flag to 'false' (a value has been explicitly set)
null | True if the field is to be set NULL. |
Definition at line 228 of file StDbFieldI.cxx.
void TxLogging::StDbFieldI::setValue | ( | const int & | value | ) |
Sets the value (and type) of the data in the variant. Setting a value implicitly unsets the IGNORE flag.
The | value to encode in the variant. |
StDataException | If there is a type mismatch between the type of T and the stored type information. |
void StDbFieldI::setValueFromString | ( | const char * | strValue | ) |
Sets the value from the provided string. Setting a value implicitly unsets the IGNORE flag. Note that there is NO type safety here, as the user may unwittingly produce a type mismatch between the string value and the existing data type.
strValue | The string to set as value. |
Definition at line 185 of file StDbFieldI.cxx.
Referenced by StDbFieldI().
|
protected |
Returns the 'real' value of the data stored in the object. If the provided type does NOT match the data type stored in the field, a StDataException is thrown.
StDataException | If provided type does not match actual type. |
Definition at line 328 of file StDbFieldI.h.