alaCarte Maps
Renderer for OpenStreetMap tiles
request_parser.hpp
Go to the documentation of this file.
1 
21 //
22 // request_parser.hpp
23 // ~~~~~~~~~~~~~~~~~~
24 //
25 // Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
26 //
27 // Distributed under the Boost Software License, Version 1.0. (See accompanying
28 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
29 //
30 
31 #ifndef HTTP_REQUEST_PARSER_HPP
32 #define HTTP_REQUEST_PARSER_HPP
33 
34 #include "settings.hpp"
35 #include <boost/logic/tribool.hpp>
36 #include <boost/tuple/tuple.hpp>
37 
38 class HttpRequest;
39 
42 {
43 public:
46 
48  void reset();
49 
54  template <typename InputIterator>
55  boost::tuple<boost::tribool, InputIterator> parse ( shared_ptr<HttpRequest> req,
56  InputIterator begin, InputIterator end ) {
57  while ( begin != end ) {
58  boost::tribool result = consume ( req, *begin++ );
59 
60  if ( result || !result )
61  return boost::make_tuple ( result, begin );
62  }
63 
64  boost::tribool result = boost::indeterminate;
65  return boost::make_tuple ( result, begin );
66  }
67 
68 private:
70  boost::tribool consume ( shared_ptr<HttpRequest> req, char input );
71 
73  static bool is_char ( int c );
74 
76  static bool is_ctl ( int c );
77 
79  static bool is_tspecial ( int c );
80 
82  static bool is_digit ( int c );
83 
85  enum state {
88  uri,
106  } state_;
107 };
108 
109 
110 #endif // HTTP_REQUEST_PARSER_HPP
state
The current state of the parser.
Parser for incoming requests.
static bool is_tspecial(int c)
Check if a byte is defined as an HTTP tspecial character.
HttpRequestParser()
Construct ready to parse the request method.
static bool is_ctl(int c)
Check if a byte is an HTTP control character.
static bool is_digit(int c)
Check if a byte is a digit.
static bool is_char(int c)
Check if a byte is an HTTP character.
enum HttpRequestParser::state state_
boost::tribool consume(shared_ptr< HttpRequest > req, char input)
Handle the next character of input.
void reset()
Reset to initial parser state.
boost::tuple< boost::tribool, InputIterator > parse(shared_ptr< HttpRequest > req, InputIterator begin, InputIterator end)
Parse some data.