41 #include "StDataException.h"
42 #include "FieldList.h"
48 class Init_StDbFieldI;
113 StDbFieldI(
const char* name,
const char* value,
147 void setValue(
const unsigned int &value);
149 void setValue(
const unsigned long &value);
155 unsigned toUInt()
const;
157 unsigned long toULong()
const;
158 double toDouble()
const;
226 StDbFieldI(
const char* name,
const T &value,
int length);
254 template<
class T>
void typeMatches()
const;
257 static void MakeTypeMap();
260 std::string fEncodedValue;
264 static std::map<EDataType,std::string> fTypeMap;
265 static std::map<EDataType,std::string> fTypeMapName;
266 static std::map<std::string,EDataType> fTypeMapInv;
285 if (std::string(name).empty()) {
287 StDataException::FIELD,
288 StUCMException::ERROR);
295 template <
class T>
void
301 std::ostringstream encodingStream;
302 encodingStream << value;
305 if ( fType == kSTRING ) {
306 if ( encodingStream.str().length() > fMaxLength ) {
307 std::ostringstream lenStr;
308 lenStr << fMaxLength;
312 +
"': Length of string '" + encodingStream.str()
313 +
"' is longer than variant length '"
314 + lenStr.str() +
"'.",
315 StDataException::FIELD,
316 StUCMException::ERROR);
320 fEncodedValue = encodingStream.str();
332 std::istringstream decodingStream(fEncodedValue);
335 decodingStream >> realValue;
340 template<
class T>
void
341 StDbFieldI::typeMatches()
const
345 std::map<EDataType,std::string>::const_iterator t = fTypeMap.find(
getType());
347 if (t == fTypeMap.end()) {
348 throw StDataException(
"Type mismatch in field '" + fName +
"': Actual type "
351 StDataException::FIELD,
352 StUCMException::ERROR);
EDataType getType() const
virtual ~StDbFieldI()
Deconstructor.
StDbFieldI(const char *name, StDbFieldI::EDataType type, int length=0)
void setIgnore(bool ignore)
const char * getTypeAsString() const
const char * fieldAsString() const
const char * getName() const
const char * getValueAsString() const
void setValue(const int &value)
void setValueFromString(const char *strValue)