Use transform for stringlist <-> jsonarray conversion.
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
e7e222f035
commit
be4585a578
|
@ -20,6 +20,7 @@
|
||||||
#include <boost/log/trivial.hpp>
|
#include <boost/log/trivial.hpp>
|
||||||
#include <mastodon-cpp/mastodon-cpp.hpp>
|
#include <mastodon-cpp/mastodon-cpp.hpp>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -29,6 +30,8 @@
|
||||||
|
|
||||||
namespace mastorss
|
namespace mastorss
|
||||||
{
|
{
|
||||||
|
using std::transform;
|
||||||
|
using std::back_inserter;
|
||||||
using std::stoul;
|
using std::stoul;
|
||||||
using std::getenv;
|
using std::getenv;
|
||||||
using std::ifstream;
|
using std::ifstream;
|
||||||
|
@ -272,10 +275,9 @@ void Config::write()
|
||||||
list<string> Config::jsonarray_to_stringlist(const Json::Value &jsonarray) const
|
list<string> Config::jsonarray_to_stringlist(const Json::Value &jsonarray) const
|
||||||
{
|
{
|
||||||
list<string> stringlist;
|
list<string> stringlist;
|
||||||
for (const auto &element : jsonarray)
|
std::transform(jsonarray.begin(), jsonarray.end(), stringlist.begin(),
|
||||||
{
|
back_inserter(stringlist));
|
||||||
stringlist.push_back(element.asString());
|
|
||||||
}
|
|
||||||
return stringlist;
|
return stringlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,12 +285,9 @@ Json::Value Config::stringlist_to_jsonarray(const list<string> &stringlist)
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
Json::Value jsonarray;
|
Json::Value jsonarray;
|
||||||
for (const auto &element : stringlist)
|
std::transform(stringlist.begin(), stringlist.end(), jsonarray.begin(),
|
||||||
{
|
back_inserter(jsonarray));
|
||||||
static Json::ArrayIndex index{0};
|
|
||||||
jsonarray[index] = element;
|
|
||||||
++index;
|
|
||||||
}
|
|
||||||
return jsonarray;
|
return jsonarray;
|
||||||
}
|
}
|
||||||
} // namespace mastorss
|
} // namespace mastorss
|
||||||
|
|
Loading…
Reference in New Issue
Block a user