]> Creatis software - clitk.git/blob - cmake/gengetopt/acceptedvalues.cpp
Added FindGengetopt.cmake which compiles gengetopt if not installed.
[clitk.git] / cmake / gengetopt / acceptedvalues.cpp
1 //
2 // C++ Implementation: acceptedvalues
3 //
4 // Description:
5 //
6 //
7 // Author: Lorenzo Bettini <http://www.lorenzobettini.it>, (C) 2004
8 //
9 // Copyright: See COPYING file that comes with this distribution
10 //
11 //
12
13 #include "acceptedvalues.h"
14 #include "my_sstream.h"
15
16 using namespace std;
17
18 void
19 AcceptedValues::insert(const string &s)
20 {
21   push_back(s);
22   values.insert(s);
23 }
24
25 bool
26 AcceptedValues::contains(const string &s) const
27 {
28   return (values.count(s) > 0);
29 }
30
31 const string
32 AcceptedValues::toString(bool escape) const
33 {
34   ostringstream buf;
35
36   for (const_iterator it = begin(); it != end(); ) {
37     buf << (escape ? "\\\"" : "\"") << *it
38         << (escape ? "\\\"" : "\"");
39     if (++it != end())
40       buf << ", ";
41   }
42
43   return buf.str();
44 }