MongoType
MongoDB Collection Data Dump with BSON Types
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Parameters.hpp
Go to the documentation of this file.
1
32
#ifndef PARAMETERS_HPP_
33
#define PARAMETERS_HPP_
34
35
#include <
mongotype.hpp
>
36
37
#define DEFAULT_CONFIGURATION_FILE "~/.mongotype"
38
#define DEFAULT_HOST "localhost"
39
#define DEFAULT_PORT 27017
40
41
namespace
mongotype {
42
47
enum
StyleParam
{
48
STYLE_UNDEF
= -1,
49
STYLE_DOTTED
= 0,
50
STYLE_TREE
= 1,
51
STYLE_JSON
= 2,
52
STYLE_JSONPACKED
= 3
53
};
54
55
enum
TypeParamMask
{
56
TYPE_UNDEF
= -1,
57
TYPE_NONE
= 0,
58
TYPE_NAME
= 1,
59
TYPE_DESC
= 2,
60
TYPE_CODE
= 4,
61
TYPE_ALL
= 7
62
};
63
68
template
<
class
E>
class
EnumMapper
{
69
typedef
map<string, E>
EnumMap
;
70
typedef
typename
EnumMap::value_type
EnumMapValue
;
71
72
EnumMap
enumMap
;
73
74
public
:
75
EnumMapper
() {}
81
void
insert
(
const
char
* key, E value) {
EnumMapValue
v(
string
(key), value);
enumMap
.insert(v); }
88
E
find
(
string
& s, E defValue) {
typename
EnumMap::iterator i =
enumMap
.find(s);
if
(i !=
enumMap
.end()) {
return
i->second; }
else
{
return
defValue; } }
89
};
90
98
class
Parameters
{
99
bool
valid
;
100
string
config_file
;
101
string
host
;
102
int
port
;
103
bool
scalarFirst
;
104
StyleParam
style
;
105
TypeParamMask
typeMask
;
106
string
dbCollection
;
107
// string query;
108
// string projection;
109
110
boost::program_options::variables_map
vm
;
111
112
public
:
113
114
Parameters
();
115
virtual
~Parameters
();
116
117
int
parse
(
int
ac,
char
* av[]);
118
119
bool
isValid
() {
return
valid
; }
120
121
bool
isDebug
() {
return
vm
.count(
"debug"
) > 0; }
122
123
bool
isStackDebug
() {
return
vm
.count(
"stack"
) > 0; }
124
125
const
string
&
getConfigFile
()
const
{
126
return
config_file
;
127
}
128
129
const
string
&
getDbCollection
()
const
{
130
return
dbCollection
;
131
}
132
133
const
string
&
getHost
()
const
{
134
return
host
;
135
}
136
137
int
getPort
()
const
{
138
return
port
;
139
}
140
141
// const string& getProjection() const {
142
// return projection;
143
// }
144
//
145
// const string& getQuery() const {
146
// return query;
147
// }
148
149
bool
isScalarFirst
()
const
{
150
return
scalarFirst
;
151
}
152
153
StyleParam
getStyle
()
const
{
154
return
style
;
155
}
156
157
TypeParamMask
getTypeMask
()
const
{
158
return
typeMask
;
159
}
160
161
friend
ostream&
operator <<
(ostream& os,
Parameters
& p);
162
};
163
164
}
/* namespace mongotype */
165
166
#endif
/* PARAMETERS_HPP_ */
include
Parameters.hpp
Generated on Mon Apr 28 2014 20:19:25 for MongoType by
1.8.3.1