]> Creatis software - cpPlugins.git/blob - lib/mstch/token.hpp
Moved to version 1.0
[cpPlugins.git] / lib / mstch / token.hpp
1 #pragma once
2
3 #include <string>
4
5 namespace mstch {
6
7 using delim_type = std::pair<std::string, std::string>;
8
9 class token {
10  public:
11   enum class type {
12     text, variable, section_open, section_close, inverted_section_open,
13     unescaped_variable, comment, partial, delimiter_change
14   };
15   token(const std::string& str, std::size_t left = 0, std::size_t right = 0);
16   type token_type() const { return m_type; };
17   const std::string& raw() const { return m_raw; };
18   const std::string& name() const { return m_name; };
19   const std::string& partial_prefix() const { return m_partial_prefix; };
20   const delim_type& delims() const { return m_delims; };
21   void partial_prefix(const std::string& p_partial_prefix) {
22     m_partial_prefix = p_partial_prefix;
23   };
24   bool eol() const { return m_eol; }
25   void eol(bool eol) { m_eol = eol; }
26   bool ws_only() const { return m_ws_only; }
27
28  private:
29   type m_type;
30   std::string m_name;
31   std::string m_raw;
32   std::string m_partial_prefix;
33   delim_type m_delims;
34   bool m_eol;
35   bool m_ws_only;
36   type token_info(char c);
37 };
38
39 }