28 #include "json/json.h"
29 #include "JSONLoaderPlugin.h"
33 #include <mxx/bcast.hpp>
45 std::vector<std::unique_ptr<JSONLoaderPlugin>>
plugins_;
68 Json::Value
LoadFile(
const std::string& filename,
const mxx::comm& world)
70 std::string contents, path;
77 mxx::bcast(contents, 0, world);
78 mxx::bcast(path, 0, world);
81 plugin->ApplyFilter(contents, path);
86 Json::CharReaderBuilder rbuilder;
87 Json::CharReader* reader = rbuilder.newCharReader();
88 if(!reader->parse(contents.c_str(), contents.c_str() + contents.size(), &root, &errors))
90 throw std::invalid_argument(
91 filename +
": " + errors
Class for JSON loader include plugin.
Class for loading JSON content from files.
std::vector< std::unique_ptr< JSONLoaderPlugin > > plugins_
List of plugins.
Json::Value LoadFile(const std::string &filename, const mxx::comm &world)
Load file and return JSON tree.
std::string GetFileContents(const std::string filename)
Read contents from a file.
std::string GetFilePath(const std::string filename)
Gets file path from filename.