The Battle for Wesnoth  1.15.12+dev
addon_utils.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2018 by David White <dave@whitevine.net>
3  2013 - 2015 by Iris Morelle <shadowm2006@gmail.com>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
18 #include <string>
19 #include <map>
20 #include "game_version.hpp"
21 
22 class config;
23 
24 namespace campaignd {
25 
26 /**
27  * Markup characters recognized by GUI1 code.
28  *
29  * These must be the same as the constants defined in marked-up_text.cpp.
30  */
31 extern const std::string illegal_markup_chars;
32 
33 inline bool is_text_markup_char(char c)
34 {
35  return illegal_markup_chars.find(c) != std::string::npos;
36 }
37 
38 /**
39  * Format a feedback URL for an add-on.
40  *
41  * @param format The format string for the URL, presumably obtained
42  * from the add-ons server identification.
43  *
44  * @param params The URL format parameters table.
45  *
46  * @return A string containing a feedback URL or an empty string if that
47  * is not possible (e.g. empty or invalid @a format, empty
48  * @a params table, or a result that is identical in content to
49  * the @a format suggesting that the @a params table contains
50  * incorrect data).
51  */
52 std::string format_addon_feedback_url(const std::string& format, const config& params);
53 
54 void support_translation(config& addon, const std::string& locale_id);
55 
56 /**
57  * Scans an add-on archive directory for translations.
58  *
59  * Any subdirectories of @a base_dir containing a subdirectory named
60  * 'LC_MESSAGES' are assumed to be translation dirs. The names of the
61  * subdirectories thus located are recorded into the @a addon WML node in
62  * [translation] children nodes like the following (comments included for
63  * documentation purposes):
64  *
65  * @verbatim
66  * [translation]
67  * language="es" # translations/es/LC_MESSAGES/
68  * [/translation]
69  * [translation]
70  * language="ja" # translations/ja/LC_MESSAGES/
71  * [/translation]
72  * @endverbatim
73  */
74 void find_translations(const config& base_dir, config& addon);
75 
76 /**
77  * Adds a COPYING.txt file with the full text of the GNU GPL to an add-on.
78  *
79  * This only has an effect if the add-on archive @a cfg does not already
80  * contain an equivalent file ('copying.txt', 'COPYING', etc.).
81  */
82 void add_license(config& cfg);
83 
84 std::map<version_info, config> get_version_map(config& addon);
85 
86 bool data_apply_removelist(config& data, const config& removelist);
87 void data_apply_addlist(config& data, const config& addlist);
88 
89 }
Interfaces for manipulating version numbers of engine, add-ons, etc.
void support_translation(config &addon, const std::string &locale_id)
Definition: addon_utils.cpp:96
std::map< version_info, config > get_version_map(config &addon)
bool data_apply_removelist(config &data, const config &removelist)
void data_apply_addlist(config &data, const config &addlist)
void add_license(config &cfg)
Adds a COPYING.txt file with the full text of the GNU GPL to an add-on.
bool is_text_markup_char(char c)
Definition: addon_utils.hpp:33
void find_translations(const config &base_dir, config &addon)
Scans an add-on archive directory for translations.
const std::string illegal_markup_chars
Markup characters recognized by GUI1 code.
Definition: addon_utils.cpp:62
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:59
mock_char c
std::string format_addon_feedback_url(const std::string &format, const config &params)
Format a feedback URL for an add-on.
Definition: addon_utils.cpp:64