X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.databoard%2Fcpp%2FDataBoardTest%2FDataBoard%2FStringValue.cpp;fp=bundles%2Forg.simantics.databoard%2Fcpp%2FDataBoardTest%2FDataBoard%2FStringValue.cpp;h=aeb97ac1853a0b571da7c30c99e471bb3c1cadb9;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=a80c306673641cc91e92f2fad4094797bdb7a8bc;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/StringValue.cpp b/bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/StringValue.cpp index a80c30667..aeb97ac18 100644 --- a/bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/StringValue.cpp +++ b/bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/StringValue.cpp @@ -1,85 +1,85 @@ -#include "StringValue.h" - -#include "Constants.h" -#include "StringType.h" - -//#define SLRE_REGEXP -#ifdef SLRE_REGEXP -#include "..\slre\slre.h" -#endif - -namespace Databoard { - namespace Value { - StringValue::StringValue(Databoard::Type::DataType* dataBoard) : Value(dataBoard) - { - } - - StringValue::~StringValue() - { - } - - void StringValue::setValue(std::string value) - { - this->value = value; - } - - std::string StringValue::getValue() - { - return value; - } - - std::string StringValue::writeOut(int /*indent*/) - { - std::string s; - - s += value; - - return s; - } - - std::string StringValue::isValid() - { - std::string retValue = STR_EMPTY; - -#ifdef SLRE_REGEXP - Databoard::Type::StringType* stringType = (Databoard::Type::StringType*)dataBoard; - - std::string p = stringType->getPattern(); - - if(p.length() > 0) - { - struct slre slre; - struct cap captures[4 + 1]; - - if (!slre_compile(&slre, p.c_str())) - { - retValue = "StringValue: pattern error."; // slre internal error - } - // todo: this is not working completely - else if (!slre_match(&slre, value.c_str(), value.length(), captures)) - { - retValue = "StringValue: value error."; - } - else - { - retValue = STR_EMPTY; - } - } - else - { - retValue = STR_EMPTY; - } -#endif - - return retValue; - } - - bool StringValue::equals(const Value* other) - { - StringValue* o = (StringValue*)other; - - return (this->value < o->value); - - } - } -} +#include "StringValue.h" + +#include "Constants.h" +#include "StringType.h" + +//#define SLRE_REGEXP +#ifdef SLRE_REGEXP +#include "..\slre\slre.h" +#endif + +namespace Databoard { + namespace Value { + StringValue::StringValue(Databoard::Type::DataType* dataBoard) : Value(dataBoard) + { + } + + StringValue::~StringValue() + { + } + + void StringValue::setValue(std::string value) + { + this->value = value; + } + + std::string StringValue::getValue() + { + return value; + } + + std::string StringValue::writeOut(int /*indent*/) + { + std::string s; + + s += value; + + return s; + } + + std::string StringValue::isValid() + { + std::string retValue = STR_EMPTY; + +#ifdef SLRE_REGEXP + Databoard::Type::StringType* stringType = (Databoard::Type::StringType*)dataBoard; + + std::string p = stringType->getPattern(); + + if(p.length() > 0) + { + struct slre slre; + struct cap captures[4 + 1]; + + if (!slre_compile(&slre, p.c_str())) + { + retValue = "StringValue: pattern error."; // slre internal error + } + // todo: this is not working completely + else if (!slre_match(&slre, value.c_str(), value.length(), captures)) + { + retValue = "StringValue: value error."; + } + else + { + retValue = STR_EMPTY; + } + } + else + { + retValue = STR_EMPTY; + } +#endif + + return retValue; + } + + bool StringValue::equals(const Value* other) + { + StringValue* o = (StringValue*)other; + + return (this->value < o->value); + + } + } +}