diff --git a/src/util.cpp b/src/util.cpp index 0a5f3a044a8628460b7d0777ea01cd22541f899d..7053ea06925328afc4d7311a8b994a969cc68b70 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -24,6 +24,7 @@ #include #include #include +#include using namespace boost::filesystem; @@ -103,6 +104,30 @@ std::string decryptPassword(std::string &encrypted, const std::string &key) { return password; } +std::string serializeGroups(const std::vector &groups) { + std::string ret; + BOOST_FOREACH(const std::string &group, groups) { + ret += group + "\n"; + } + if (!ret.empty()) { + ret.erase(ret.end() - 1); + } + return ret; +} + +std::vector deserializeGroups(std::string &groups) { + std::vector ret; + if (groups.empty()) { + return ret; + } + + boost::split(ret, groups, boost::is_any_of("\n")); + if (ret.back().empty()) { + ret.erase(ret.end() - 1); + } + return ret; +} + } }