Telnet++
A C++ library for interacting with Telnet streams
parser.hpp
1 #pragma once
2 
3 #include "telnetpp/command.hpp"
4 #include "telnetpp/negotiation.hpp"
5 #include "telnetpp/protocol.hpp"
6 #include "telnetpp/subnegotiation.hpp"
7 #include "telnetpp/element.hpp"
8 #include "telnetpp/detail/parse_helper.hpp"
9 #include <vector>
10 
11 namespace telnetpp { namespace detail {
12 
13 //* =========================================================================
20 //* =========================================================================
21 template <class InputIterator1, class InputIterator2>
22 std::vector<element> parse(InputIterator1 &begin, InputIterator2 end)
23 {
24  detail::parse_temps temps;
25 
26  auto position = begin;
27  while (position != end)
28  {
29  detail::parse_helper(temps, *position);
30  ++position;
31 
32  // If the current state is idle, then it means that a token has been
33  // completely parsed, and therefore we can move the begin iterator
34  // indicating that a range has been consumed.
35  if (temps.state == detail::parse_state::idle)
36  {
37  begin = position;
38  }
39  }
40 
41  return temps.elements;
42 }
43 
44 }}
Definition: byte_converter.hpp:4