56 explicit Config(
bool multi_value =
false);
62 explicit Config(std::istream& is,
bool multi_value =
false);
81 void SetParam(
const std::string& key,
const T& value,
bool is_string =
false);
89 const std::string&
GetParam(
const std::string& key)
const;
120 class ConfigIterator :
public std::iterator< std::input_iterator_tag, ConfigEntry > {
156 void FindNextIndex();
165 std::vector<std::string> val;
166 std::vector<size_t> insert_index;
169 void Insert(
const std::string& key,
const std::string& value,
bool is_string);
172 std::map<std::string, ConfigValue> config_map_;
173 std::vector<std::pair<std::string, size_t> > order_;
174 const bool multi_value_;
179 std::ostringstream oss;
181 Insert(key, oss.str(), is_string);
186 #endif // DMLC_CONFIG_H_ void LoadFromStream(std::istream &is)
load the contents from the stream
iterator class
Definition: config.h:120
ConfigIterator end() const
get end iterator
bool IsGenuineString(const std::string &key) const
check whether the configure value given by the key should be wrapped by quotes
const std::string & GetParam(const std::string &key) const
get the config under the key; if multiple values exist for the same key, return the last inserted one...
void SetParam(const std::string &key, const T &value, bool is_string=false)
set a key-value pair into the config; if the key already exists in the configure file, it will either replace the old value with the given one (in non-multi value mode) or store it directly (in multi-value mode);
Definition: config.h:178
ConfigIterator & operator++()
uni-increment operators
std::string ToProtoString(void) const
transform all the configuration into string recognizable to protobuf
std::pair< std::string, std::string > ConfigEntry
type when extracting from iterator
Definition: config.h:45
namespace for dmlc
Definition: array_view.h:12
Config(bool multi_value=false)
create empty config
class for config parser
Definition: config.h:40
bool operator==(const ConfigIterator &rhs) const
compare operators
ConfigEntry operator*() const
retrieve value from operator
ConfigIterator begin() const
get begin iterator
bool operator!=(const ConfigIterator &rhs) const
compare operators not equal
void Clear(void)
clear all the values
ConfigIterator(const ConfigIterator &other)
copy constructor