1 #include "StringValue.h"
\r
3 #include "Constants.h"
\r
4 #include "StringType.h"
\r
6 //#define SLRE_REGEXP
\r
8 #include "..\slre\slre.h"
\r
11 namespace Databoard {
\r
13 StringValue::StringValue(Databoard::Type::DataType* dataBoard) : Value(dataBoard)
\r
17 StringValue::~StringValue()
\r
21 void StringValue::setValue(std::string value)
\r
23 this->value = value;
\r
26 std::string StringValue::getValue()
\r
31 std::string StringValue::writeOut(int /*indent*/)
\r
40 std::string StringValue::isValid()
\r
42 std::string retValue = STR_EMPTY;
\r
45 Databoard::Type::StringType* stringType = (Databoard::Type::StringType*)dataBoard;
\r
47 std::string p = stringType->getPattern();
\r
52 struct cap captures[4 + 1];
\r
54 if (!slre_compile(&slre, p.c_str()))
\r
56 retValue = "StringValue: pattern error."; // slre internal error
\r
58 // todo: this is not working completely
\r
59 else if (!slre_match(&slre, value.c_str(), value.length(), captures))
\r
61 retValue = "StringValue: value error.";
\r
65 retValue = STR_EMPTY;
\r
70 retValue = STR_EMPTY;
\r
77 bool StringValue::equals(const Value* other)
\r
79 StringValue* o = (StringValue*)other;
\r
81 return (this->value < o->value);
\r