AirInv Logo  1.00.7
C++ Simulated Airline Inventory Management System Library
Loading...
Searching...
No Matches
RequestParser.hpp
Go to the documentation of this file.
1#ifndef __AIRINV_SVR_REQUESTPARSER_HPP
2#define __AIRINV_SVR_REQUESTPARSER_HPP
3
4// //////////////////////////////////////////////////////////////////////
5// Import section
6// //////////////////////////////////////////////////////////////////////
7// STL
8// Boost
9#include <boost/logic/tribool.hpp>
10#include <boost/tuple/tuple.hpp>
11
12namespace AIRINV {
13
14 struct Request;
15
18 public:
21
23 void reset();
24
29 template <typename InputIterator>
30 boost::tuple<boost::tribool, InputIterator> parse (Request& req,
31 InputIterator begin,
32 InputIterator end) {
33
34 while (begin != end) {
35 boost::tribool result = consume(req, *begin++);
36 if (result || !result)
37 return boost::make_tuple(result, begin);
38 }
39
40 boost::tribool result = boost::indeterminate;
41 return boost::make_tuple(result, begin);
42 }
43
44 private:
46 boost::tribool consume (Request& req, char input);
47
49 static bool is_char(int c);
50
52 static bool is_ctl(int c);
53
55 static bool is_tspecial(int c);
56
58 static bool is_digit(int c);
59
61 enum state {
62 method_start,
63 method,
64 uri_start,
65 uri,
66 http_version_h,
67 http_version_t_1,
68 http_version_t_2,
69 http_version_p,
70 http_version_slash,
71 http_version_major_start,
72 http_version_major,
73 http_version_minor_start,
74 http_version_minor,
75 expecting_newline_1,
76 header_line_start,
77 header_lws,
78 header_name,
79 space_before_header_value,
80 header_value,
81 expecting_newline_2,
82 expecting_newline_3
83 } state_;
84 };
85
86}
87#endif // __AIRINV_SVR_REQUESTPARSER_HPP
Parser for incoming requests.
boost::tuple< boost::tribool, InputIterator > parse(Request &req, InputIterator begin, InputIterator end)
RequestParser()
Construct ready to parse the request method.
void reset()
Reset to initial parser state.