filter lambda support

This commit is contained in:
Daniel Sipka 2015-04-22 11:39:07 +02:00
parent bfa6d161bb
commit 0ddf2cd121
10 changed files with 66 additions and 44 deletions

View file

@ -15,23 +15,24 @@ token::type token::token_info(char c) {
}
}
token::token(bool is_tag, bool eol, bool ws_only, const std::string& str):
m_eol(eol), m_ws_only(ws_only), m_marked(false)
token::token(const std::string& str, std::size_t skip_left, std::size_t skip_right):
m_eol(false), m_ws_only(false), m_raw(str)
{
if(is_tag) {
if(str[0] == '{' && str[str.size() - 1] == '}') {
if(skip_left != 0 && skip_right != 0) {
if(str[skip_left] == '{' && str[str.size() - skip_right - 1] == '}') {
m_type = type::unescaped_variable;
m_content = {first_not_ws(str.begin() + 1, str.end()),
first_not_ws(str.rbegin() + 1, str.rend()) + 1};
m_name = {first_not_ws(str.begin() + skip_left + 1, str.end() - skip_right),
first_not_ws(str.rbegin() + 1 + skip_right, str.rend() - skip_left) + 1};
} else {
auto first = first_not_ws(str.begin(), str.end());
auto first = first_not_ws(str.begin() + skip_left, str.end() - skip_right);
m_type = token_info(*first);
if(m_type != type::variable)
first = first_not_ws(first + 1, str.end());
m_content = {first, first_not_ws(str.rbegin(), str.rend()) + 1};
first = first_not_ws(first + 1, str.end() - skip_right);
m_name = {first, first_not_ws(str.rbegin() + skip_right, str.rend() - skip_left) + 1};
}
} else {
m_type = type::text;
m_content = str;
m_eol = (str.size() > 0 && str[str.size() - 1] == '\n');
m_ws_only = (str.find_first_not_of(" \n\t") == std::string::npos);
}
}