Remove dynamic exceptions
[anna.git] / include / anna / http / internal / EncodedBlock.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_EncodedBlock_hpp
10 #define anna_http_internal_EncodedBlock_hpp
11
12 #include <anna/core/DataBlock.hpp>
13
14 namespace anna {
15
16 namespace http {
17
18 class EncodedBlock : public DataBlock {
19 public:
20   struct Type { enum _v { None, Chunked }; };
21   struct State { enum _v { Completed, Incomplete }; };
22
23   EncodedBlock() : DataBlock(true), a_chunk(true), a_expectedSize(-1), a_type(Type::None) {;}
24
25   Type::_v getType() const { return a_type; }
26   bool isValid() const { return a_type != Type::None; }
27
28   void setType(const Type::_v type) { a_type = type; }
29   void setExpectedSize(const int expectedSize) { a_expectedSize = expectedSize; }
30
31   void clear() { DataBlock::clear(); a_expectedSize = -1; a_chunk.clear(); a_type = Type::None; }
32
33   State::_v append(const DataBlock& chunk) ;
34
35 private:
36   Type::_v a_type;
37   DataBlock a_chunk;
38   int a_expectedSize;
39 };
40
41 }
42 }
43
44 #endif