TFCweb
1.0.4 $Rev: 483 $
TFC Primavera 2012: Nucli d'un servidor web
Pàgina principal
Pàgines Relacionades
Espais de Noms
Classes
Fitxers
Llista dels Fitxers
Membres de Fitxers
src
Configuracio.h
Veure la documentació d'aquest fitxer.
1
#if !defined(_CONFIGURACIO_H_)
2
#define _CONFIGURACIO_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 "
Excepcions.h
"
30
#include "
Permisos.h
"
31
#include "
portabilitat.h
"
32
#include "
utils.h
"
33
34
#include <ostream>
35
#include <string>
36
#include <boost/filesystem.hpp>
37
38
namespace
tfc {
39
43
class
ErrorOpcions
:
public
ErrorTFC
{
44
protected
:
45
explicit
ErrorOpcions
(
const
std::string & w)
46
:
ErrorTFC
(w)
47
{
48
// buit
49
}
50
public
:
51
virtual
unsigned
int
codi
()
const
= 0;
52
};
53
57
class
ErrorConfiguracio
:
public
ErrorOpcions
{
58
public
:
59
explicit
ErrorConfiguracio
(
const
std::string & w =
"Error en la configuració"
)
60
:
ErrorOpcions
(w)
61
{
62
// buit
63
}
64
virtual
unsigned
int
codi
()
const
{
return
EX_CONFIG
; }
65
};
66
70
class
ErrorLiniaComandes
:
public
ErrorOpcions
{
71
public
:
72
explicit
ErrorLiniaComandes
(
const
std::string & w =
"Error en la línia de comandes"
)
73
:
ErrorOpcions
(w)
74
{
75
// buit
76
}
77
virtual
unsigned
int
codi
()
const
{
return
EX_USAGE
; }
78
};
79
85
class
AjudaDemanada
:
public
ErrorTFC
{
86
public
:
87
explicit
AjudaDemanada
(
const
std::string & ajuda)
88
:
ErrorTFC
(ajuda)
89
{
90
// buit
91
}
92
};
93
99
class
VersioDemanada
:
public
ErrorTFC
{
100
public
:
101
VersioDemanada
()
102
:
ErrorTFC
(
""
)
103
{
104
// buit
105
}
106
};
107
112
class
Configuracio
{
113
public
:
125
Configuracio
(
int
argc,
char
* argv[])
throw
(
ErrorOpcions
,
AjudaDemanada
,
VersioDemanada
);
126
Configuracio
(
const
Configuracio
& c)
127
:
argc_
(c.
argc_
),
argv_
(c.
argv_
),
128
arrel_
(c.
arrel_
),
index_
(c.
index_
),
port_
(c.
port_
),
config_
(c.
config_
),
129
auth_user_
(c.
auth_user_
),
auth_pass_
(c.
auth_pass_
),
130
cerber_
(c.
cerber_
)
131
{
132
// buit
133
}
134
135
const
boost::filesystem::path
&
arrel
()
const
{
return
arrel_
; }
136
const
std::string&
index
()
const
{
return
index_
; }
137
unsigned
short
port
()
const
{
return
port_
; }
138
const
boost::filesystem::path
&
config
()
const
{
return
config_
; }
139
const
std::string&
usuari
()
const
{
return
auth_user_
; }
140
const
std::string&
contrasenya
()
const
{
return
auth_pass_
; }
141
const
size_t
fils
()
const
{
return
fils_
; }
142
const
std::string &
realme
()
const
{
return
auth_realme_
; }
143
144
const
Cerber
&
cerber
()
const
{
return
cerber_
; }
145
protected
:
146
// C++11: Configuracio& operator=(const Configuracio &) = delete;
147
Configuracio
&
operator=
(
const
Configuracio
&) {
148
throw
ErrorNoImplementat
(
FITXER_I_LINIA_
);
149
return
*
this
;
150
}
151
private
:
152
const
int
argc_
;
153
char
**
argv_
;
157
boost::filesystem::path
arrel_
;
158
std::string
index_
;
159
unsigned
short
port_
;
160
boost::filesystem::path
config_
;
161
std::string
auth_user_
,
auth_pass_
,
auth_realme_
;
162
size_t
fils_
;
163
Cerber
cerber_
;
164
166
friend
std::ostream&
operator<<
(std::ostream & os,
const
Configuracio
& c);
167
};
168
169
}
// namespace tfc
170
171
#endif // _CONFIGURACIO_H_
172
173
// vim:set ts=4 et ai: //
Generat a Dl Jun 17 2013 20:07:39 per a TFCweb per
1.8.1.2