Archived
1
0
This repository has been archived on 2023-08-12. You can view files and clone it, but cannot push or open issues or pull requests.
nntpchan/contrib/backends/nntpchan-daemon/libmustache/token.hpp

47 lines
1.1 KiB
C++
Raw Normal View History

2017-10-11 18:48:27 +05:00
#pragma once
#include <string>
2017-10-17 19:29:56 +05:00
namespace mstch
{
2017-10-11 18:48:27 +05:00
using delim_type = std::pair<std::string, std::string>;
2017-10-17 19:29:56 +05:00
class token
{
public:
enum class type
{
text,
variable,
section_open,
section_close,
inverted_section_open,
unescaped_variable,
comment,
partial,
delimiter_change
2017-10-11 18:48:27 +05:00
};
2017-10-17 19:29:56 +05:00
token(const std::string &str, std::size_t left = 0, std::size_t right = 0);
2017-10-11 18:48:27 +05:00
type token_type() const { return m_type; };
2017-10-17 19:29:56 +05:00
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; };
2017-10-11 18:48:27 +05:00
bool eol() const { return m_eol; }
void eol(bool eol) { m_eol = eol; }
bool ws_only() const { return m_ws_only; }
2017-10-17 19:29:56 +05:00
private:
2017-10-11 18:48:27 +05:00
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);
};
}