25 #include <boost/algorithm/string.hpp>
28 #define LOG_CS LOG_STREAM_NAMELESS(err, log_network)
32 typedef std::map<std::string, std::string> plain_string_map;
43 std::string fast_interpolate_variables_into_string(
const std::string &str,
const plain_string_map *
const symbols)
45 std::string res = str;
48 for(
const plain_string_map::value_type& sym : *symbols) {
49 boost::replace_all(res,
"$" + sym.first, sym.second);
67 plain_string_map escaped;
81 const std::string& res =
82 fast_interpolate_variables_into_string(
format, &escaped);
98 config* locale = addon.
find_child(
"translation",
"language", locale_id).ptr();
100 locale = &addon.
add_child(
"translation");
101 (*locale)[
"language"] = locale_id;
103 (*locale)[
"supported"] =
true;
109 const std::string& fn = file[
"name"].str();
117 if(dir[
"name"] ==
"LC_MESSAGES") {
131 LOG_CS <<
"Could not find toplevel [dir] tag";
136 if(dir->find_child(
"file",
"name",
"COPYING.txt")
137 || dir->find_child(
"file",
"name",
"COPYING")
138 || dir->find_child(
"file",
"name",
"copying.txt")
139 || dir->find_child(
"file",
"name",
"Copying.txt")
140 || dir->find_child(
"file",
"name",
"COPYING.TXT"))
147 if (contents.empty()) {
153 copying[
"name"] =
"COPYING.txt";
154 copying[
"contents"] = contents;
159 std::map<version_info, config> version_map;
162 version_map.emplace(
version_info(version[
"version"]), version);
171 data.remove_children(
"file", [&
f](
const config&
d) {
return f[
"name"] ==
d[
"name"]; });
175 auto data_dir =
data.find_child(
"dir",
"name", dir[
"name"]);
178 data.remove_children(
"dir", [&dir](
const config&
d) {
return dir[
"name"] ==
d[
"name"]; });
182 return data.has_child(
"file") ||
data.has_child(
"dir");
189 data.add_child(
"file",
f);
193 config* data_dir =
data.find_child(
"dir",
"name", dir[
"name"]).ptr();
195 data_dir = &
data.add_child(
"dir");
196 (*data_dir)[
"name"] = dir[
"name"];
static lg::log_domain log_network("network")
A config object defines a single node in a WML file, with access to child nodes.
const_attr_itors attribute_range() const
optional_config_impl< config > find_child(config_key_type key, const std::string &name, const std::string &value)
Returns the first child of tag key with a name attribute containing value.
child_itors child_range(config_key_type key)
boost::iterator_range< const_attribute_iterator > const_attr_itors
attribute_map::value_type attribute
optional_config_impl< config > optional_child(config_key_type key, int n=0)
Euivalent to mandatory_child, but returns an empty optional if the nth child was not found.
config & add_child(config_key_type key)
Represents version numbers.
Declarations for File-IO.
Standard logging facilities (interface).
std::string format_addon_feedback_url(const std::string &format, const config ¶ms)
Format a feedback URL for an add-on.
void data_apply_addlist(config &data, const config &addlist)
const std::string illegal_markup_chars
Markup characters recognized by GUI1 code.
void find_translations(const config &base_dir, config &addon)
Scans an add-on archive directory for translations.
bool data_apply_removelist(config &data, const config &removelist)
void support_translation(config &addon, const std::string &locale_id)
std::map< version_info, config > get_version_map(config &addon)
void add_license(config &cfg)
Adds a COPYING.txt file with the full text of the GNU GPL to an add-on.
std::string base_name(const std::string &file, const bool remove_extension)
Returns the base filename of a file, with directory name stripped.
std::string read_file(const std::string &fname)
Basic disk I/O - read file.
bool ends_with(const std::string &str, const std::string &suffix)
std::string urlencode(const std::string &str)
Percent-escape characters in a UTF-8 string intended to be part of a URL.