Euphoria
texttemplate.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <map>
4 #include <memory>
5 #include <optional>
6 
7 
8 namespace eu::io
9 {
10  struct FileSystem;
11  struct FilePath;
12 }
13 
14 
15 namespace eu::core
16 {
17  struct Defines
18  {
19  std::map<std::string, std::string> values;
20 
22 
23  void remove(const std::string& name);
24  void set(const std::string& name, const std::string& value);
25 
26  [[nodiscard]] bool is_defined(const std::string& name) const;
27  [[nodiscard]] std::string get_value(const std::string& name) const;
28  };
29 
31  {
32  std::vector<std::string> errors;
33 
35 
36  void add_error
37  (
38  const std::optional<io::FilePath>& file,
39  int line,
40  int column,
41  const std::string& error
42  );
43 
44  [[nodiscard]] bool has_errors() const;
45  [[nodiscard]] std::string get_combined_errors() const;
46  };
47 
48  struct TemplateNodeList;
49 
51  {
52  // todo(Gustav): move errors to load and evaluate return values
54  std::shared_ptr<TemplateNodeList> nodes;
55 
56  // todo(Gustav): move to a named constructor
57  explicit CompiledTextTemplate(const std::string& text);
60 
63  void operator=(const CompiledTextTemplate&) = delete;
64  void operator=(CompiledTextTemplate&&) = delete;
65 
66  // todo(Gustav): why is this not const nodiscard?
67  std::string build_string(const Defines& defines);
68  };
69 
70 }
constexpr ParseResult error
no error occurred
Definition: argparse.h:73
Definition: enum.h:8
int line
Definition: nlp_sentence.cc:91
void operator=(const CompiledTextTemplate &)=delete
void operator=(CompiledTextTemplate &&)=delete
std::string build_string(const Defines &defines)
CompiledTextTemplate(CompiledTextTemplate &&)=delete
std::shared_ptr< TemplateNodeList > nodes
Definition: texttemplate.h:54
CompiledTextTemplate(const CompiledTextTemplate &)=delete
CompiledTextTemplate(const std::string &text)
std::map< std::string, std::string > values
Definition: texttemplate.h:19
void remove(const std::string &name)
Definition: texttemplate.cc:46
std::string get_value(const std::string &name) const
Definition: texttemplate.cc:33
bool is_defined(const std::string &name) const
Definition: texttemplate.cc:25
void set(const std::string &name, const std::string &value)
Definition: texttemplate.cc:53
std::vector< std::string > errors
Definition: texttemplate.h:32
void add_error(const std::optional< io::FilePath > &file, int line, int column, const std::string &error)
Definition: texttemplate.cc:74
std::string get_combined_errors() const
Definition: texttemplate.cc:92