]> Creatis software - clitk.git/blobdiff - utilities/gengetopt/acceptedvalues.cpp
Sync gengetopt cmake files with rtk
[clitk.git] / utilities / gengetopt / acceptedvalues.cpp
diff --git a/utilities/gengetopt/acceptedvalues.cpp b/utilities/gengetopt/acceptedvalues.cpp
new file mode 100644 (file)
index 0000000..ea66c0a
--- /dev/null
@@ -0,0 +1,44 @@
+//
+// C++ Implementation: acceptedvalues
+//
+// Description:
+//
+//
+// Author: Lorenzo Bettini <http://www.lorenzobettini.it>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#include "acceptedvalues.h"
+#include "my_sstream.h"
+
+using namespace std;
+
+void
+AcceptedValues::insert(const string &s)
+{
+  push_back(s);
+  values.insert(s);
+}
+
+bool
+AcceptedValues::contains(const string &s) const
+{
+  return (values.count(s) > 0);
+}
+
+const string
+AcceptedValues::toString(bool escape) const
+{
+  ostringstream buf;
+
+  for (const_iterator it = begin(); it != end(); ) {
+    buf << (escape ? "\\\"" : "\"") << *it
+        << (escape ? "\\\"" : "\"");
+    if (++it != end())
+      buf << ", ";
+  }
+
+  return buf.str();
+}