39 if (!(file_stream->fail())) {
67 if (active ==
nullptr)
70 bool ret = active->
has_child(
"variables");
77 std::string::const_iterator index_start = std::find(global.begin(),global.end(),
'[');
78 if (index_start != global.end())
80 const std::string::const_iterator index_end = std::find(global.begin(),global.end(),
']');
81 const std::string index_str(index_start+1,index_end);
82 std::size_t
index =
static_cast<std::size_t
>(lexical_cast_default<int>(index_str));
112 else if (immediate) {
116 if (active !=
nullptr) {
119 if (!bactive.
empty())
129 if (active !=
nullptr) {
132 if (!bactive.
empty())
147 if (active ==
nullptr) {
164 if (active && (active->
has_child(
"variables"))) {
168 for (std::size_t
i = 0;
i < arrsize;
i++)
179 bool success =
false;
182 if (!cfg_name.empty()) {
215 if (val[global].empty()) {
218 cfg[global] = val[global];
219 if (immediate) bactive[global] = val[global];
232 else if (immediate) {
247 newspace +=
"." + name;
Class for writing a config out to a file in pieces.
void write(const config &cfg)
A config object defines a single node in a WML file, with access to child nodes.
void append(const config &cfg)
Append data from another config object to this one.
config & mandatory_child(config_key_type key, int n=0)
Returns the nth child with the given key, or throws an error if there is none.
void remove_child(config_key_type key, std::size_t index)
std::size_t child_count(config_key_type key) const
void clear_children(T... keys)
bool has_child(config_key_type key) const
Determine whether a config has a child or not.
bool has_attribute(config_key_type key) const
config & child_or_add(config_key_type key)
Returns a reference to the first child with the given key.
void remove_attribute(config_key_type key)
config & add_child(config_key_type key)
std::string get_node() const
void set_node(const std::string &)
config get_var(const std::string &) const
bool set_var(const std::string &, const config &, bool immediate=false)
persist_file_context(const std::string &name_space)
bool clear_var(const std::string &, bool immediate=false)
Declarations for File-IO.
New lexcical_cast header.
Standard logging facilities (interface).
filesystem::scoped_istream istream_file(const std::string &fname, bool treat_failure_as_error)
const std::string wml_extension
static bfs::path get_dir(const bfs::path &dirpath)
std::string get_user_data_dir()
bool delete_file(const std::string &filename)
static bool file_exists(const bfs::path &fpath)
bool is_directory(const std::string &fname)
Returns true if the given file is a directory.
filesystem::scoped_ostream ostream_file(const std::string &fname, std::ios_base::openmode mode, bool create_directory)
std::unique_ptr< std::istream > scoped_istream
std::unique_ptr< std::ostream > scoped_ostream
bool exists(const image::locator &i_locator)
Returns true if the given image actually exists, without loading it.
std::size_t index(const std::string &str, const std::size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
config pack_scalar(const std::string &name, const t_string &val)
static std::string get_persist_cfg_name(const std::string &name_space)
void read(config &cfg, std::istream &in, abstract_validator *validator)