X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Fmstch%2Ftoken.hpp;fp=lib%2Fmstch%2Ftoken.hpp;h=fde8017991f16bb2b045ccb73b5d1e8b938b5cde;hb=2e142df11d6f312a2a2b5097b8da73571ed523e8;hp=0000000000000000000000000000000000000000;hpb=61b3659afe961ed248f30e26f9ca8f28fcfafddc;p=cpPlugins.git diff --git a/lib/mstch/token.hpp b/lib/mstch/token.hpp new file mode 100644 index 0000000..fde8017 --- /dev/null +++ b/lib/mstch/token.hpp @@ -0,0 +1,39 @@ +#pragma once + +#include + +namespace mstch { + +using delim_type = std::pair; + +class token { + public: + enum class type { + text, variable, section_open, section_close, inverted_section_open, + unescaped_variable, comment, partial, delimiter_change + }; + token(const std::string& str, std::size_t left = 0, std::size_t right = 0); + type token_type() const { return m_type; }; + const std::string& raw() const { return m_raw; }; + const std::string& name() const { return m_name; }; + const std::string& partial_prefix() const { return m_partial_prefix; }; + const delim_type& delims() const { return m_delims; }; + void partial_prefix(const std::string& p_partial_prefix) { + m_partial_prefix = p_partial_prefix; + }; + bool eol() const { return m_eol; } + void eol(bool eol) { m_eol = eol; } + bool ws_only() const { return m_ws_only; } + + private: + type m_type; + std::string m_name; + std::string m_raw; + std::string m_partial_prefix; + delim_type m_delims; + bool m_eol; + bool m_ws_only; + type token_info(char c); +}; + +}