147 std::string str_access(
"");
152 str_access =
"constant";
156 str_access =
"persistent";
160 str_access =
"important";
163 otErr <<
"OTVariable::Serialize: ERROR: Bad variable type.\n";
167 std::string str_type;
173 if ((
false == bCalculatingID) &&
175 (m_str_Value.size() > 0))
178 OTString strVal(m_str_Value.c_str());
183 " access=\"%s\" >\n%s</variable>\n\n",
184 m_strName.
Get(),
"exists", str_type.c_str(),
185 str_access.c_str(), ascVal.Get());
191 " access=\"%s\" />\n\n",
192 m_strName.
Get(),
"none",
193 str_type.c_str(), str_access.c_str());
197 str_type =
"integer";
199 "<variable\n name=\"%s\"\n"
202 " access=\"%s\" />\n\n",
204 bCalculatingID ? 0 : m_nValue,
207 str_type.c_str(), str_access.c_str());
212 "<variable\n name=\"%s\"\n"
215 " access=\"%s\" />\n\n",
219 : (m_bValue ?
"true" :
"false"),
228 <<
"OTVariable::Serialize: Error, Wrong Type -- not serializing.\n";
238 , m_bValueBackup(false)
241 , m_Access(Var_Error_Access)
249 : m_strName(str_Name.c_str())
250 , m_str_Value(str_Value)
253 , m_str_ValueBackup(str_Value)
255 , m_bValueBackup(false)
258 , m_Access(theAccess)
261 if (m_str_Value.empty()) m_str_Value =
"";
262 if (m_str_ValueBackup.empty()) m_str_ValueBackup =
"";
268 : m_strName(str_Name.c_str())
271 , m_nValueBackup(nValue)
272 , m_bValueBackup(false)
275 , m_Access(theAccess)
283 : m_strName(str_Name.c_str())
287 , m_bValueBackup(bValue)
290 , m_Access(theAccess)
297 if (
nullptr != m_pScript) {
310 otErr <<
"OTVariable::SetValue(int64_t): Error: This variable ("
311 << m_strName <<
") is not an integer.\n";
315 m_nValue = m_nValueBackup = nValue;
323 otErr <<
"OTVariable::SetValue(bool): Error: This variable ("
324 << m_strName <<
") is not a bool.\n";
328 m_bValue = m_bValueBackup = bValue;
336 otErr <<
"OTVariable::SetValue(std::string): Error: This variable ("
337 << m_strName <<
") is not a string.\n";
341 m_str_Value = m_str_ValueBackup = str_Value;
343 if (m_str_Value.empty()) m_str_Value =
"";
344 if (m_str_ValueBackup.empty()) m_str_ValueBackup =
"";
355 bool bReturnVal =
false;
359 if (0 != m_str_Value.compare(m_str_ValueBackup))
375 otErr <<
"OTVariable::IsDirty: Error: unknown type for variable: "
376 << m_strName <<
"\n";
389 m_str_ValueBackup = m_str_Value;
394 m_nValueBackup = m_nValue;
399 m_bValueBackup = m_bValue;
404 otErr <<
"OTVariable::SetAsClean: Error: unknown type for variable: "
405 << m_strName <<
"\n";
406 m_str_ValueBackup = m_str_Value;
407 m_nValueBackup = m_nValue;
408 m_bValueBackup = m_bValue;
428 const std::string str_var_name = m_strName.
Get();
432 m_pScript = &theScript;
441 otOut <<
"OTVariable::Compare: Names don't match: " <<
GetName()
442 <<
" / " << rhs.
GetName() <<
" \n";
446 otOut <<
"OTVariable::Compare: Type doesn't match: " <<
GetName()
451 otOut <<
"OTVariable::Compare: Access types don't match: " <<
GetName()
469 otErr <<
"OTVariable::Compare: Unknown type in variable " << m_strName
OTVariable_Type GetType() const
EXPORT void RegisterForExecution(OTScript &theScript)
EXPORT void RemoveVariable(OTVariable &theVar)
OTLOG_IMPORT OTLogStream otOut
EXPORT void Concatenate(const char *arg,...)
EXPORT void UnregisterScript()
EXPORT const OTString & GetName() const
bool SetValue(const int32_t &nValue)
void Serialize(OTString &strAppend, bool bCalculatingID=false) const
OTVariable_Access GetAccess() const
EXPORT const char * Get() const
OTLOG_IMPORT OTLogStream otErr
virtual EXPORT ~OTVariable()
EXPORT void AddVariable(std::string str_var_name, OTVariable &theVar)
std::string & GetValueString()
int32_t & GetValueInteger()
bool Compare(OTVariable &rhs)