20#ifndef PALUDIS_GUARD_PALUDIS_TOKENISER_HH
21#define PALUDIS_GUARD_PALUDIS_TOKENISER_HH 1
89 template <
typename DelimMode_,
typename Iter_>
98 template <
typename Iter_>
123 template <
typename Iter_>
145 const std::string text;
146 std::string::size_type text_pos;
148 const std::string quotes;
151 enum { t_quote, t_delim, t_text } kind;
153 Lexer(
const std::string & t,
const std::string & d,
const std::string & q) :
163 if (text_pos >= text.length())
166 if (std::string::npos != delims.find(text[text_pos]))
168 std::string::size_type start_pos(text_pos);
169 while (++text_pos < text.length())
170 if (std::string::npos == delims.find(text[text_pos]))
173 value = text.substr(start_pos, text_pos - start_pos);
176 else if (std::string::npos != quotes.find(text[text_pos]))
178 value = std::string(1, text[text_pos]);
184 std::string::size_type start_pos(text_pos);
185 while (++text_pos < text.length())
186 if (std::string::npos != delims.find(text[text_pos]))
188 else if (std::string::npos != quotes.find(text[text_pos]))
190 value = text.substr(start_pos, text_pos - start_pos);
198 template <
typename DelimKind_,
typename DelimMode_ = delim_mode::DelimiterTag>
201 template <
typename DelimMode_>
208 template <
typename Iter_>
209 static void tokenise(
const std::string & s,
210 const std::string & delims,
211 const std::string & quotes,
229 TokeniserError(
const std::string & s,
const std::string & msg)
noexcept;
234 template <
typename DelimMode_>
235 template <
typename Iter_>
238 const std::string & s,
239 const std::string & delims,
240 const std::string & quotes,
244 Lexer l(s, delims, quotes);
246 enum { s_initial, s_had_quote, s_had_text, s_had_quote_text, s_had_quote_text_quote } state = s_initial;
262 tokeniser_internals::Writer<DelimMode_, Iter_>::handle_delim(l.value, iter);
267 tokeniser_internals::Writer<DelimMode_, Iter_>::handle_token(l.value, iter);
276 state = s_had_quote_text_quote;
286 state = s_had_quote_text;
292 case s_had_quote_text:
304 state = s_had_quote_text_quote;
310 case s_had_quote_text_quote:
352 case s_had_quote_text_quote:
356 case s_had_quote_text:
367 template <
typename DelimKind_,
typename DelimMode_,
typename Iter_>
368 void tokenise(
const std::string & s,
const std::string & delims,
const std::string & quotes, Iter_ iter)
379 template <
typename Iter_>
391 template <
typename Iter_>
InternalError(const std::string &location, const std::string &message) noexcept
Definition tokeniser.hh:224
Definition tokeniser.hh:199
#define PALUDIS_HERE
Definition exception.hh:217
void tokenise(const std::string &s, const std::string &delims, const std::string "es, Iter_ iter)
Definition tokeniser.hh:368
void tokenise_whitespace(const std::string &s, Iter_ iter)
Definition tokeniser.hh:380
void tokenise_whitespace_quoted(const std::string &s, Iter_ iter)
Definition tokeniser.hh:392
#define PALUDIS_VISIBLE
Definition attributes.hh:59
Definition tokeniser.hh:46
Definition tokeniser.hh:61
Definition tokeniser.hh:83
Definition about_metadata-fwd.hh:24
Definition tokeniser.hh:144
static void handle_token(const std::string &s, Iter_ &i)
Definition tokeniser.hh:129
static void handle_delim(const std::string &s, Iter_ &i)
Definition tokeniser.hh:137
static void handle_delim(const std::string &, const Iter_ &)
Definition tokeniser.hh:112
static void handle_token(const std::string &s, Iter_ &i)
Definition tokeniser.hh:104
Definition tokeniser.hh:90