26 #pragma warning(disable : 4996) // 'std::copy': Function call with parameters that may be unsafe - this call relies on 30 #pragma warning(disable : 4512) // 'std::copy': Function call with parameters that may be unsafe - this call relies on 34 #define NOEXCEPT // hide unsupported noexcept keyword under VC++ 36 #define NOEXCEPT noexcept 40 #define NOTHROW throw() // add throw() keyword under MinGW 45 #include <boost/lexical_cast.hpp> 49 #include <unordered_map> 62 typedef std::vector<data_ptr> data_list;
68 virtual ~
Data() =
default;
69 virtual bool empty() = 0;
70 virtual std::string getvalue();
71 virtual data_list &getlist();
73 virtual int getint()
const;
74 virtual void dump(
int indent = 0) = 0;
86 std::string getvalue();
87 virtual int getint()
const;
89 virtual void dump(
int indent = 0);
105 std::string getvalue();
106 virtual int getint()
const;
108 virtual void dump(
int indent = 0);
121 : m_value(std::move(value))
124 std::string getvalue();
125 virtual int getint()
const;
127 virtual void dump(
int indent = 0);
140 : m_items(std::move(items))
143 data_list &getlist();
145 void dump(
int indent = 0);
152 template <
typename T>
155 this->operator=(data);
172 ptr = std::move(data.ptr);
175 data_ptr &operator=(std::string &&data);
177 data_ptr &operator=(data_list &&data);
178 template <
typename T>
179 void operator=(
const T &data);
180 void push_back(
const data_ptr &data);
182 Data *operator->() {
return ptr.get(); }
183 std::shared_ptr<Data>
get() {
return ptr; }
184 bool is_template()
const;
187 std::shared_ptr<Data> ptr;
197 : std::runtime_error(msg)
207 data_ptr &operator[](
const std::string &key);
209 bool has(
const std::string &key);
210 data_ptr &parse_path(
const std::string &key,
bool create =
false);
211 void set_parent(
data_map *p) { parent = p; }
214 std::unordered_map<std::string, data_ptr> data;
230 : m_items(std::move(items))
235 void dump(
int indent = 0);
239 void data_ptr::operator=(
const bool &data);
241 void data_ptr::operator=(
const int &data);
243 void data_ptr::operator=(
const unsigned int &data);
245 void data_ptr::operator=(
const std::string &data);
247 void data_ptr::operator=(
const data_map &data);
249 void data_ptr::operator=(
const data_list &data);
250 template <
typename T>
251 void data_ptr::operator=(
const T &data)
253 this->operator=(boost::lexical_cast<std::string>(data));
260 std::string m_reason;
274 void set_reason(std::string reason) { m_reason = reason; }
275 void set_line_if_missing(
size_t line);
277 virtual const char *what()
const NOEXCEPT NOTHROW {
return m_reason.c_str(); }
289 inline data_ptr make_data(
unsigned int val)
293 inline data_ptr make_data(std::string &val)
297 inline data_ptr make_data(std::string &&val)
301 inline data_ptr make_data(data_list &val)
305 inline data_ptr make_data(data_list &&val)
317 template <
typename T>
320 return data_ptr(boost::lexical_cast<std::string>(val));
329 typedef std::shared_ptr<Node> node_ptr;
330 typedef std::vector<node_ptr> node_vector;
335 typedef std::vector<std::string> string_vector;
339 impl::node_vector m_tree;
340 string_vector m_params;
349 : m_tree(std::move(tree))
352 virtual std::string getvalue();
353 virtual bool empty();
354 std::string eval(
data_map &data, data_list *param_values =
nullptr);
355 void eval(std::ostream &stream,
data_map &data, data_list *param_values =
nullptr);
356 string_vector ¶ms() {
return m_params; }
357 void dump(
int indent = 0);
360 inline data_ptr make_template(
const std::string &templateText,
const string_vector *param_names =
nullptr)
365 t->params() = *param_names;
372 void parse(std::ostream &stream,
const std::string &templ_text,
data_map &data);
373 std::string parse(
const std::string &templ_text,
data_map &data);
Definition: cpptempl.h:111
Definition: cpptempl.h:337
Definition: cpptempl.h:148
Definition: cpptempl.h:257
Definition: cpptempl.h:193
Definition: cpptempl.h:65
Definition: cpptempl.h:92
Definition: cpptempl.h:130
Definition: cpptempl.h:220
Definition: cpptempl.h:190
Definition: cpptempl.h:77
Definition: cpptempl.h:54