diff --git a/src/utils/conftree.cpp b/src/utils/conftree.cpp index f2cb3714..7457c35c 100644 --- a/src/utils/conftree.cpp +++ b/src/utils/conftree.cpp @@ -274,6 +274,16 @@ int ConfSimple::get(const string& nm, string& value, const string& sk) const return 1; } +int ConfSimple::get(const string& nm, int *value, const string& sk) const +{ + string sval; + if (!get(nm, sval, sk)) { + return 0; + } + *value = atoi(sval.c_str()); + return 1; +} + // Appropriately output a subkey (nm=="") or variable line. // We can't make any assumption about the data except that it does not // contain line breaks. @@ -332,6 +342,12 @@ int ConfSimple::set(const std::string& nm, const std::string& value, } return write(); } +int ConfSimple::set(const string& nm, long long val, + const string& sk) +{ + return this->set(nm, lltodecstr(val), sk); +} + // Internal set variable: no rw checking or file rewriting. If init is // set, we're doing initial parsing, else we are changing a parsed diff --git a/src/utils/conftree.h b/src/utils/conftree.h index 31ddc1ec..58d9600d 100644 --- a/src/utils/conftree.h +++ b/src/utils/conftree.h @@ -165,19 +165,34 @@ public: } /** - * Get value for named parameter, from specified subsection (looks in - * global space if sk is empty). + * Get string value for named parameter, from specified subsection (looks + * in global space if sk is empty). * @return 0 if name not found, 1 else */ virtual int get(const string& name, string& value, const string& sk = string()) const; /** - * Set value for named parameter in specified subsection (or global) + * Get integer value for named parameter, from specified subsection (looks + * in global space if sk is empty). + * @return 0 if name not found, 1 else + */ + virtual int get(const string& name, int* value, + const string& sk = string()) const; + + + /** + * Set value for named string parameter in specified subsection (or global) * @return 0 for error, 1 else */ virtual int set(const string& nm, const string& val, const string& sk = string()); + /** + * Set value for named integer parameter in specified subsection (or global) + * @return 0 for error, 1 else + */ + virtual int set(const string& nm, long long val, + const string& sk = string()); /** * Remove name and value from config