diff --git a/services/backup/src/Tools.h b/services/backup/src/Tools.h --- a/services/backup/src/Tools.h +++ b/services/backup/src/Tools.h @@ -13,6 +13,8 @@ const std::string &backupID, const std::string &resourceID = ""); +std::string parseAttachmentHolders(const std::string &holders); + } // namespace tools } // namespace network } // namespace comm diff --git a/services/backup/src/Tools.cpp b/services/backup/src/Tools.cpp --- a/services/backup/src/Tools.cpp +++ b/services/backup/src/Tools.cpp @@ -1,10 +1,13 @@ #include "Tools.h" +#include "GlobalConstants.h" #include "GlobalTools.h" #include #include #include +#include +#include namespace comm { namespace network { @@ -30,6 +33,25 @@ ID_SEPARATOR + tools::generateUUID(); } +std::string parseAttachmentHolders(const std::string &holders) { + std::stringstream stream(holders); + std::string item; + std::string result; + + while (std::getline(stream, item, ATTACHMENT_DELIMITER[0])) { + if (item.empty()) { + throw std::runtime_error("empty holder detected"); + } + result += item; + result += ATTACHMENT_DELIMITER; + } + if (result.empty()) { + throw std::runtime_error("parse attachment holders failed"); + } + + return result; +} + } // namespace tools } // namespace network } // namespace comm