X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=utilities%2Fgengetopt%2Facceptedvalues.cpp;fp=utilities%2Fgengetopt%2Facceptedvalues.cpp;h=ea66c0abf41c042c807fd0f162001a21787f5dd0;hb=79381bc54b9e0c85156460daa211fe5ac83da0a7;hp=0000000000000000000000000000000000000000;hpb=4454c06e212fb6af58d206f2d6f9b76778858967;p=clitk.git diff --git a/utilities/gengetopt/acceptedvalues.cpp b/utilities/gengetopt/acceptedvalues.cpp new file mode 100644 index 0000000..ea66c0a --- /dev/null +++ b/utilities/gengetopt/acceptedvalues.cpp @@ -0,0 +1,44 @@ +// +// C++ Implementation: acceptedvalues +// +// Description: +// +// +// Author: Lorenzo Bettini , (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(); +}