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;
config & child(config_key_type key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
void write(const config &cfg)
void clear_children(T... keys)
void append(const config &cfg)
Append data from another config object to this one.
bool delete_file(const std::string &filename)
New lexcical_cast header.
bool has_attribute(config_key_type key) const
bool has_child(config_key_type key) const
Determine whether a config has a child or not.
unsigned child_count(config_key_type key) const
static bool file_exists(const bfs::path &fpath)
filesystem::scoped_istream istream_file(const std::string &fname, bool treat_failure_as_error)
config & child_or_add(config_key_type key)
config pack_scalar(const std::string &name, const t_string &val)
void remove_attribute(config_key_type key)
static bfs::path get_dir(const bfs::path &dirpath)
bool exists(const image::locator &i_locator)
Returns true if the given image actually exists, without loading it.
void read(config &cfg, std::istream &in, abstract_validator *validator)
Class for writing a config out to a file in pieces.
std::string get_user_data_dir()
bool set_var(const std::string &, const config &, bool immediate=false)
bool is_directory(const std::string &fname)
Returns true if the given file is a directory.
std::unique_ptr< std::istream > scoped_istream
static std::string get_persist_cfg_name(const std::string &name_space)
std::unique_ptr< std::ostream > scoped_ostream
persist_file_context(const std::string &name_space)
Declarations for File-IO.
static int writer(lua_State *L, const void *b, size_t size, void *B)
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 & add_child(config_key_type key)
void set_node(const std::string &)
std::string get_node() const
config get_var(const std::string &) const
Standard logging facilities (interface).
A config object defines a single node in a WML file, with access to child nodes.
void remove_child(config_key_type key, unsigned index)
bool clear_var(const std::string &, bool immediate=false)
filesystem::scoped_ostream ostream_file(const std::string &fname, bool create_directory)