0.08.01
C++ Open Travel Request Parsing Library
Toggle main menu visibility
Loading...
Searching...
No Matches
Names.cpp
Go to the documentation of this file.
1
// //////////////////////////////////////////////////////////////////////
2
// Import section
3
// //////////////////////////////////////////////////////////////////////
4
// STL
5
#include <cassert>
6
#include <sstream>
7
// OpenTrep
8
#include <
opentrep/Names.hpp
>
9
10
namespace
OPENTREP
{
11
12
// //////////////////////////////////////////////////////////////////////
13
Names::Names
() : _languageCode (
"en_US"
) {
14
assert (
false
);
15
}
16
17
// //////////////////////////////////////////////////////////////////////
18
Names::Names
(
const
LanguageCode_T
& iLanguageCode)
19
: _languageCode (iLanguageCode) {
20
}
21
22
// //////////////////////////////////////////////////////////////////////
23
Names::Names
(
const
Names
& iName)
24
: _languageCode (iName._languageCode),
25
_nameList (iName._nameList) {
26
}
27
28
// //////////////////////////////////////////////////////////////////////
29
Names::~Names
() {
30
}
31
32
// //////////////////////////////////////////////////////////////////////
33
std::string
Names::getFirstName
()
const
{
34
if
(_nameList.empty() ==
true
) {
35
return
""
;
36
}
37
NameList_T::const_iterator itName = _nameList.begin();
38
assert (itName != _nameList.end());
39
const
std::string& lName = *itName;
40
return
lName;
41
}
42
43
// //////////////////////////////////////////////////////////////////////
44
std::string
Names::describeKey
()
const
{
45
std::ostringstream oStr;
46
//oStr << "[" << Language::getLongLabel (_languageCode) << "]: ";
47
return
oStr.str();
48
}
49
50
// //////////////////////////////////////////////////////////////////////
51
std::string
Names::describe
()
const
{
52
std::ostringstream oStr;
53
oStr <<
describeKey
();
54
55
// The language code is the same for all the items of the list. But it
56
// is repeated for every item, so that it can be parsed easily.
57
// const std::string& lLangCode = Language::getShortLabel (_languageCode);
58
59
unsigned
short
idx = 0;
60
for
(NameList_T::const_iterator itName = _nameList.begin();
61
itName != _nameList.end(); ++itName, ++idx) {
62
if
(idx != 0) {
63
oStr <<
","
;
64
}
65
const
std::string& lName = *itName;
66
oStr << _languageCode <<
","
<< lName;
67
}
68
69
return
oStr.str();
70
}
71
72
// //////////////////////////////////////////////////////////////////////
73
void
Names::toStream
(std::ostream& ioOut)
const
{
74
ioOut <<
describe
();
75
}
76
77
// //////////////////////////////////////////////////////////////////////
78
void
Names::fromStream
(std::istream& ioIn) {
79
}
80
81
// //////////////////////////////////////////////////////////////////////
82
std::string
Names::toString
()
const
{
83
std::ostringstream oStr;
84
oStr <<
describe
();
85
return
oStr.str();
86
}
87
88
// //////////////////////////////////////////////////////////////////////
89
void
Names::addName
(
const
std::string& iName) {
90
_nameList.push_back (iName);
91
}
92
93
// //////////////////////////////////////////////////////////////////////
94
void
Names::resetList
() {
95
_nameList.clear();
96
}
97
98
}
Names.hpp
OPENTREP
Definition
BasChronometer.cpp:10
OPENTREP::LanguageCode_T
Definition
OPENTREP_Types.hpp:300
OPENTREP::Names::describeKey
std::string describeKey() const
Definition
Names.cpp:44
OPENTREP::Names::toString
std::string toString() const
Definition
Names.cpp:82
OPENTREP::Names::toStream
void toStream(std::ostream &ioOut) const
Definition
Names.cpp:73
OPENTREP::Names::addName
void addName(const std::string &iName)
Definition
Names.cpp:89
OPENTREP::Names::resetList
void resetList()
Definition
Names.cpp:94
OPENTREP::Names::Names
Names(const LanguageCode_T &)
Definition
Names.cpp:18
OPENTREP::Names::fromStream
void fromStream(std::istream &ioIn)
Definition
Names.cpp:78
OPENTREP::Names::describe
std::string describe() const
Definition
Names.cpp:51
OPENTREP::Names::getFirstName
std::string getFirstName() const
Definition
Names.cpp:33
OPENTREP::Names::~Names
~Names()
Definition
Names.cpp:29
Generated on
for OpenTREP by
1.17.0