diff options
Diffstat (limited to 'gentoobrowse-api/domain/converters.cpp')
-rw-r--r-- | gentoobrowse-api/domain/converters.cpp | 79 |
1 files changed, 5 insertions, 74 deletions
diff --git a/gentoobrowse-api/domain/converters.cpp b/gentoobrowse-api/domain/converters.cpp index 073c545..b4748cd 100644 --- a/gentoobrowse-api/domain/converters.cpp +++ b/gentoobrowse-api/domain/converters.cpp @@ -1,51 +1,24 @@ #include <portage-models.h> #include "converters.h" +#include "converters.impl.h" #include "unpackPqTextArray.h" #include <string> #include <boost/algorithm/string/join.hpp> #include <boost/algorithm/string/split.hpp> namespace Slicer { - static - void - unpackPqTextArray(const std::string & s, ::Gentoo::StringList & list) - { - std::stringstream ss(s); - UnpackPqTextArray l(ss, list); - l.yylex(); - } - template<typename T> PqArray<T>::PqArray(std::vector<T> * l) : ModelPartForSequence<std::vector<T>>(l) { } - PqArray<std::string>::PqArray(::Gentoo::StringList * sl) : - ModelPartForSequence<::Gentoo::StringList>(sl) - { - } - template<typename T> void PqArray<T>::SetValue(ValueSourcePtr s) { - this->Model->clear(); - std::string v; - s->set(v); - if (v.size() < 3) return; - typedef boost::algorithm::split_iterator<std::string::iterator> string_split_iterator; - string_split_iterator sfi(++v.begin(), --v.end(), boost::algorithm::first_finder(",", boost::algorithm::is_iequal())); - for(auto it = sfi; it != string_split_iterator(); ++it) { - this->Model->push_back(boost::lexical_cast<T>(*it)); - } - } - - void PqArray<std::string>::SetValue(ValueSourcePtr s) - { - Model->clear(); - std::string v; - s->set(v); - unpackPqTextArray(v, *Model); + std::string in; + s->set(in); + *this->Model = unpackPqArray<T>(in); } template<typename T> @@ -56,50 +29,8 @@ namespace Slicer { return true; } - bool - PqArray<std::string>::GetValue(ValueTargetPtr s) - { - s->get(packPqArray(*this->Model)); - return true; - } - template class PqArray<Ice::Int>; - - ::Gentoo::StringList - unpackPqTextArray(const std::string & s) - { - ::Gentoo::StringList list; - unpackPqTextArray(s, list); - return list; - } - - template<typename T> - std::string - packPqArray(const T & l) - { - if (l.empty()) return "{}"; - std::vector<std::string> l2; - l2.reserve(l.size()); - for(const auto & i : l) { - l2.push_back(packPqVar(i)); - } - return "{" + boost::algorithm::join(l2, ",") + "}"; - } - template std::string packPqArray<std::set<std::string>>(const std::set<std::string> &); - - template<typename T> - std::string - packPqVar(const T & l) - { - return boost::lexical_cast<std::string>(l); - } - - template<> - std::string - packPqVar(const std::string & l) - { - return "\"" + boost::algorithm::replace_all_copy(l, "\"", "\\\"") + "\""; - } + template class PqArray<std::string>; boost::posix_time::ptime shortDateToPosixTime(const std::string & s) |