Remove dynamic exceptions
[anna.git] / include / anna / http / internal / Tokenizer.hpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite                           //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7
8
9 #ifndef anna_http_internal_Tokenizer_hpp
10 #define anna_http_internal_Tokenizer_hpp
11
12 #include <anna/core/util/Recycler.hpp>
13
14 #include <anna/http/internal/Token.hpp>
15
16 namespace anna {
17
18 class DataBlock;
19
20 namespace http {
21
22 class Tokenizer : public Recycler<Token> {
23 public:
24   void apply(const DataBlock&) noexcept(false);
25   void apply(const DataBlock&, const char* separator) noexcept(false);
26   void apply(const DataBlock&, const char separator) noexcept(false);
27
28   const Token* operator [](int index) const ;
29
30   const Token* operator [](const_iterator ii) const {
31     return (ii == end()) ? NULL : token(ii);
32   }
33
34   static const Token* token(const_iterator ii) { return data(ii); }
35   static Token* token(iterator ii) { return data(ii); }
36
37 private:
38   int createToken(const char* p, const int size) {
39     create()->setValue(p, size);
40     return size;
41   }
42
43   static int find(const char* data, const int size, const char character) ;
44   static int find(const char* data, const int size, const char* searched) ;
45   static bool isSpace(const int c) { return c <= '\t' || c == ' ' || c >= 128; }
46 };
47
48 }
49 }
50
51 #endif