bitz-server  0.1.6
header.h
1 /*
2  * C++ ICAP library
3  * Copyright (C) 2012 Uditha Atukorala
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19 
20 #ifndef ICAP_HEADER_H
21 #define ICAP_HEADER_H
22 
23 #include "common.h"
24 
25 #include <string>
26 #include <map>
27 #include <vector>
28 #include <functional>
29 
30 
31 namespace icap {
32 
33  class Header {
34  public:
35 
36  /* headers data type */
37  typedef std::map<std::string, std::string> headers_t;
38 
39  /* headers iterator type */
40  typedef headers_t::iterator headers_index_t;
41 
42  /* encapsulated header type */
43  typedef std::map<std::string, int> encapsulated_header_t;
44 
45  /* encapsulated header iterator type */
46  typedef encapsulated_header_t::iterator encapsulated_header_index_t;
47 
48  /* encapsulated header data type */
49  typedef std::pair<std::string, int> encapsulated_header_data_t;
50 
56  : std::binary_function<icap::Header::encapsulated_header_data_t, icap::Header::encapsulated_header_data_t, bool> {
57  inline bool operator()( const icap::Header::encapsulated_header_data_t &lhs, const icap::Header::encapsulated_header_data_t &rhs ) {
58  return lhs.second < rhs.second;
59  }
60  };
61 
62 
63  Header();
64  virtual ~Header();
65 
70  const headers_t &headers() const throw();
71 
79  const std::string value( const std::string &key ) throw();
80 
88  const int encapsulated_header( const std::string &entity ) throw();
89 
103  virtual void attach( std::string key, std::string value ) throw();
104 
120  virtual bool attach_encapsulated( std::string header_value ) throw();
121 
122 
132  virtual void update_encapsulated( const payload_t &payload ) throw();
133 
140  virtual bool remove( std::string key ) throw();
141 
146  virtual const std::string encapsulated_header_str() throw();
147 
154  virtual std::vector<encapsulated_header_data_t> sort_encapsulated_header();
155 
156 
157  protected:
158  headers_t _headers;
159  encapsulated_header_t _encapsulated;
160 
161  private:
162 
163  };
164 
165 } /* end of namespace icap */
166 
167 #endif /* !ICAP_HEADER_H */
168 
const int encapsulated_header(const std::string &entity)
Definition: header.cpp:63
virtual const std::string encapsulated_header_str()
Definition: header.cpp:131
const std::string value(const std::string &key)
Definition: header.cpp:49
virtual bool attach_encapsulated(std::string header_value)
Definition: header.cpp:93
virtual void update_encapsulated(const payload_t &payload)
Definition: header.cpp:172
virtual std::vector< encapsulated_header_data_t > sort_encapsulated_header()
Definition: header.cpp:213
const headers_t & headers() const
Definition: header.cpp:44
virtual bool remove(std::string key)
Definition: header.cpp:126
Definition: common.h:26
virtual void attach(std::string key, std::string value)
Definition: header.cpp:77
Definition: header.h:33
Definition: common.h:31