38 std::ostringstream stream;
40 lua_pushstring(L, stream.str().c_str());
53 std::string file = luaL_checkstring(L, 1);
54 bool preprocess =
true;
56 if(lua_type(L, 2) == LUA_TBOOLEAN) {
58 }
else if(lua_type(L, 2) == LUA_TTABLE || lua_type(L, 2) == LUA_TUSERDATA) {
60 int n = lua_tointeger(L, -1);
62 for(
int i = 0;
i <
n;
i++) {
64 if(!lua_isstring(L, -1)) {
65 return luaL_argerror(L, 2,
"expected bool or array of strings");
67 std::string define = lua_tostring(L, -1);
73 }
else if(!lua_isnoneornil(L, 2)) {
74 return luaL_argerror(L, 2,
"expected bool or array of strings");
76 std::string schema_path = luaL_optstring(L, 3,
"");
77 std::shared_ptr<schema_validation::schema_validator>
validator;
78 if(!schema_path.empty()) {
88 stream.reset(
new std::ifstream(wml_file));
102 std::string wml = luaL_checkstring(L, 1);
103 std::string schema_path = luaL_optstring(L, 2,
"");
104 std::shared_ptr<schema_validation::schema_validator>
validator;
105 if(!schema_path.empty()) {
127 vconfig clone(clone_underlying);
158 lua_pushboolean(L, cfg.
matches(filter));
171 const std::string mode = lua_isstring(L, 3) ? luaL_checkstring(L, 3) :
"merge";
172 if(mode ==
"append") {
176 if(mode ==
"replace") {
180 }
else if(mode !=
"merge") {
181 return luaL_argerror(L, 3,
"invalid merge mode - must be merge, append, or replace");
225 lua_pushboolean(L, left == right);
239 }
else lua_pushboolean(L,
false);
244 auto& lk = lua_kernel_base::get_lua_kernel<lua_kernel_base>(L);
245 lk.add_log(
"Adding wml module...\n");
246 static luaL_Reg
const wml_callbacks[]= {
258 {
nullptr,
nullptr },
261 luaL_setfuncs(L, wml_callbacks, 0);
A config object defines a single node in a WML file, with access to child nodes.
bool matches(const config &filter) const
bool validate_wml() const
Returns true if this object represents valid WML, i.e.
auto all_children_view() const
In-order iteration over all children.
void merge_attributes(const config &)
void clear_children(T... keys)
void merge_with(const config &c)
Merge config 'c' into this config, overwriting this config's values.
void apply_diff(const config &diff, bool track=false)
A function to apply a diff config onto this config object.
config get_diff(const config &c) const
A function to get the differences between this object, and 'c', as another config object.
void append_children(const config &cfg)
Adds children from cfg.
Realization of serialization/validator.hpp abstract validator.
A variable-expanding proxy for the config class.
const config & get_config() const
config get_parsed_config() const
static std::string _(const char *str)
void luaW_pushconfig(lua_State *L, const config &cfg)
Converts a config object to a Lua table pushed at the top of the stack.
config luaW_checkconfig(lua_State *L, int index)
Converts an optional table or vconfig to a config object.
void luaW_pushvconfig(lua_State *L, const vconfig &cfg)
Pushes a vconfig on the top of the stack.
bool luaW_toboolean(lua_State *L, int n)
bool luaW_toconfig(lua_State *L, int index, config &cfg)
Converts an optional table or vconfig to a config object.
utils::optional< std::string > get_wml_location(const std::string &path, const utils::optional< std::string > ¤t_dir)
Returns a translated path to the actual file or directory, if it exists.
std::unique_ptr< std::istream > scoped_istream
static int intf_wml_patch(lua_State *L)
Applies a diff to a WML table Arg 1: base table Arg 2: WML diff.
static int intf_wml_matches_filter(lua_State *L)
Tests if a WML table matches a filter Arg 1: table to test Arg 2: filter.
static int intf_wml_tostring(lua_State *L)
Dumps a wml table or userdata wml object into a pretty string.
static int intf_wml_equal(lua_State *L)
Tests if two WML tables are equal (have the same keys and values, same tags, recursively) Arg 1: left...
int luaW_open(lua_State *L)
static int intf_wml_valid(lua_State *L)
Tests if a table represents a valid WML table Arg 1: table.
static int intf_load_wml(lua_State *L)
Loads a WML file into a config.
static int intf_wml_interpolate(lua_State *L)
Interpolates variables into a WML table, including [insert_tag] Arg 1: WML table to interpolate into ...
static int intf_parse_wml(lua_State *L)
Parses a WML string into a config; does not preprocess or validate.
static int intf_wml_diff(lua_State *L)
Computes a diff of two WML tables Arg 1: left table Arg 2: right table.
static int intf_clone_wml(lua_State *L)
Returns a clone (deep copy) of the passed config, which can be either a normal config or a vconfig If...
static int intf_wml_merge(lua_State *L)
Merges two WML tables Arg 1: base table Arg 2: table to merge in.
filesystem::scoped_istream preprocess_file(const std::string &fname, preproc_map *defines)
Function to use the WML preprocessor on a file.
std::map< std::string, struct preproc_define > preproc_map
One of the realizations of serialization/validator.hpp abstract validator.
void read(config &cfg, std::istream &in, abstract_validator *validator)
void write(std::ostream &out, const configr_of &cfg, unsigned int level)
static map_location::direction n