StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Protected Member Functions | Friends | List of all members
TxLogging::StDbFieldI Class Reference

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 StDbFieldIoperator= (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 >
toValue () const
 

Friends

class TxLogging::Init_StDbFieldI
 

Detailed Description

Definition at line 50 of file StDbFieldI.h.

Member Enumeration Documentation

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.

Constructor & Destructor Documentation

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.

Parameters
nameThe name of the field.
typeThe field type, as a TxEType.
lengthThe 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

converts it to a string. Supported types are:

bool all signed integer types (stored as long) all unsigned integer types (stored as ulong) (signed) float types (stored as double) char

std::string

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.

Parameters
nameThe name of the field.
valueThe value to encode in the variant.
lengthNon-optional for strings; sets the max length of the string. Constructor: Creates a complete field. Note that it may not be typesafe.
nameThe name of the field.
typeThe type of the field. Note that in this constructor the user is responsible for ensuring type safety.
valueThe value of the field.
lengthThe 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.

StDbFieldI::~StDbFieldI ( )
virtual

Deconstructor.

Destructor: No-op.

Definition at line 141 of file StDbFieldI.cxx.

Member Function Documentation

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.

Returns
For string types, returns the maximum length of the string. For non-string types, returns 0.

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?

Parameters
ignoreWhether 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)

Parameters
nullTrue 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.

Parameters
Thevalue to encode in the variant.
Exceptions
StDataExceptionIf 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.

Parameters
strValueThe string to set as value.

Definition at line 185 of file StDbFieldI.cxx.

Referenced by StDbFieldI().

template<class T >
T TxLogging::StDbFieldI::toValue ( ) const
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.

Exceptions
StDataExceptionIf provided type does not match actual type.

Definition at line 328 of file StDbFieldI.h.


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