1 #include <Poco/JSON/JSON.h>
2 #include <Poco/JSON/Stringifier.h>
3 #include <Poco/JSON/Parser.h>
4 #include <Poco/JSON/JSONException.h>
5 #include <Poco/Dynamic/Var.h>
11 #include <Poco/File.h>
12 #include <Poco/Path.h>
26 :
taskId(0), infoData(
""), timeModified(0)
31 :
taskId(0), infoData(
""), timeModified(0)
37 :
taskId(0), infoData(
""), timeModified(0)
39 (*this) = std::forward<TaskInfoData>(rhs);
57 taskId = std::move(rhs.taskId);
84 Poco::JSON::Array::Ptr pItems =
new Poco::JSON::Array();
90 Poco::JSON::Object::Ptr pItemElem =
new Poco::JSON::Object();
92 if (!pItemElem.isNull())
98 pItems->add(pItemElem);
102 std::stringstream ostr;
103 Poco::JSON::Stringifier::stringify(pItems, ostr);
106 catch(std::exception& e)
124 Poco::JSON::Parser parser;
125 Poco::Dynamic::Var res = parser.parse(json);
126 Poco::JSON::Array::Ptr pItems = res.extract<Poco::JSON::Array::Ptr>();
127 if (!pItems.isNull())
129 for (
size_t i=0;i<pItems->size();++i)
131 Poco::JSON::Object::Ptr pItemElem = pItems->getObject(i);
132 if (!pItemElem.isNull())
137 taskInfoData.
taskId = convertVarToNumeric<unsigned int>(tmp, 0);
141 taskInfoData.
infoData = tmp.convert<std::string>();
144 taskInfoData.
timeModified = convertVarToNumeric<time_t>(tmp, 0);
146 addItem(std::forward<TaskInfoData>(taskInfoData));
151 catch(Poco::JSON::JSONException& e)
157 catch(Poco::Exception& e)
163 catch(std::exception& e)
180 Poco::File sources(sourceDir);
181 if (sources.exists() && sources.isDirectory())
183 std::vector<std::string> files;
186 for (
const std::string&
fileName : files)
188 Poco::Path path(sourceDir);
194 std::istringstream(path.getFileName()) >> taskId;
198 std::string fileContent;
200 fileStream >> fileContent;
205 taskInfoData.
infoData = fileContent;
206 taskInfoData.
timeModified = Poco::File(path).getLastModified().epochTime();
208 addItem(std::forward<TaskInfoData>(taskInfoData));
214 catch(Poco::Exception& e)
220 catch(std::exception& e)