TFCweb  1.0.4 $Rev: 483 $
TFC Primavera 2012: Nucli d'un servidor web
CapsaleraHTTP.h
Veure la documentació d'aquest fitxer.
1 #if !defined(_CAPSALERA_HTTP_H_)
2 #define _CAPSALERA_HTTP_H_
3 
10 /*
11  * Copyright (c) 2012 Toni Corvera
12  *
13  * This file is part of TFCWeb.
14  *
15  * TFCWeb is free software: you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation, either version 3 of the License, or
18  * (at your option) any later version.
19  *
20  * TFCWeb is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with TFCWeb. If not, see <http://www.gnu.org/licenses/>.
27  */
28 
29 #include "portabilitat.h"
30 
31 #include <iostream>
32 #include <ostream>
33 #include <stdexcept>
34 #include <string>
35 
36 namespace tfc {
37 
43 public:
44  CapsaleraHTTP(const std::string & nom, const std::string & valor = "")
45  : nom_(nom), valor_(valor)
46  {
47  // buit
48  }
53  : nom_(c.nom()), valor_(c.valor())
54  {
55  // buit
56  }
57 
58 #if 0
59  // Amb nom definit constant no es pot definir operator= coherentment
60  // p.e. { CapsaleraHTTP("Host") h; h = CapsaleraHTTP("Server") } seria un problema
61  CapsaleraHTTP& operator=(const CapsaleraHTTP & c) {
62  if (this == &c) {
63  return *this;
64  }
65  valor_ = c.valor();
66  return *this;
67  }
68 #endif
69 
70  bool operator==(const CapsaleraHTTP & c) const {
71  if (this == &c) {
72  return true;
73  }
74  return nom_ == c.nom() && valor_ == c.valor();
75  }
76  std::string nom() const { return nom_; }
77  std::string valor() const { return valor_; }
78  void set_valor(const std::string &);
79 
85  static bool es_repetible(const std::string & nom);
86 private:
87  /* const */ std::string nom_;
88  std::string valor_;
89 
90  friend std::ostream& operator<< (std::ostream& os, const CapsaleraHTTP& c) {
91  return os << c.nom() << ": " << c.valor();
92  }
93 };
94 
95 } // ns tfc
96 
97 #endif // _CAPSALERA_HTTP_H_
98 
99 // vim:set ts=4 et ai: //