WireCellToolkit
Wire Cell Simulation, Signal Process and Reconstruction Toolki for Liquid Argon Detectors
|
Classes | |
class | Parser |
Typedefs | |
typedef std::map< std::string, std::string > | externalvars_t |
Functions | |
bool | exists (const std::string &filename) |
Return true file exists (no file resolution performed). More... | |
std::string | resolve (const std::string &filename) |
std::string | slurp (const std::string &filename) |
void | dump (const std::string &filename, const Json::Value &top, bool pretty=false) |
std::string | dumps (const Json::Value &top, bool pretty=false) |
As above but dump to a JSON text string. More... | |
Json::Value | load (const std::string &filename, const externalvars_t &extvar=externalvars_t(), const externalvars_t &extcode=externalvars_t()) |
Json::Value | loads (const std::string &text, const externalvars_t &extvar=externalvars_t(), const externalvars_t &extcode=externalvars_t()) |
std::string | evaluate_jsonnet_file (const std::string &filename, const externalvars_t &extvar=externalvars_t(), const externalvars_t &extcode=externalvars_t()) |
std::string | evaluate_jsonnet_text (const std::string &text, const externalvars_t &extvar=externalvars_t(), const externalvars_t &extcode=externalvars_t()) |
Json::Value | json2object (const std::string &text) |
template<typename Iterable > | |
Json::Value | iterable2json (Iterable const &cont) |
typedef std::map<std::string, std::string> WireCell::Persist::externalvars_t |
void WireCell::Persist::dump | ( | const std::string & | filename, |
const Json::Value & | top, | ||
bool | pretty = false |
||
) |
Save the data structure held by the given top Json::Value in to a file of the given name. The format of the file is determined by the file name extension. Valid extensions are:
If pretty
is true then format the JSON text with indents. If also compressed, this formatting can actually lead to smaller files.
default to .json.bz2 regardless of extension.
Definition at line 37 of file Persist.cxx.
std::string WireCell::Persist::dumps | ( | const Json::Value & | top, |
bool | pretty = false |
||
) |
As above but dump to a JSON text string.
Definition at line 58 of file Persist.cxx.
std::string WireCell::Persist::evaluate_jsonnet_file | ( | const std::string & | filename, |
const externalvars_t & | extvar = externalvars_t() , |
||
const externalvars_t & | extcode = externalvars_t() |
||
) |
Explicitly evaluate contents of file with Jsonnet. If no support for Jsonnet is built, return the contents of file. Return empty string if Jsonnet evaluation failes.
WireCell::IOError is thrown if file is not found. WireCell::ValueError is thrown parsing fails.
Definition at line 185 of file Persist.cxx.
std::string WireCell::Persist::evaluate_jsonnet_text | ( | const std::string & | text, |
const externalvars_t & | extvar = externalvars_t() , |
||
const externalvars_t & | extcode = externalvars_t() |
||
) |
Explicitly evaluate text with JSonnet. If no support for Jsonnet is built, return the text. Return empty string if Jsonnet evaluation failes.
WireCell::ValueError is thrown parsing fails.
Definition at line 205 of file Persist.cxx.
bool WireCell::Persist::exists | ( | const std::string & | filename | ) |
Return true file exists (no file resolution performed).
Definition at line 79 of file Persist.cxx.
Json::Value WireCell::Persist::iterable2json | ( | Iterable const & | cont | ) |
Json::Value WireCell::Persist::json2object | ( | const std::string & | text | ) |
Explicitly convert JSON text to Json::Value object
Definition at line 161 of file Persist.cxx.
Json::Value WireCell::Persist::load | ( | const std::string & | filename, |
const externalvars_t & | extvar = externalvars_t() , |
||
const externalvars_t & | extcode = externalvars_t() |
||
) |
Load a file and return the top JSON value.
If extension is `.jsonnet` and Jsonnet support is compiled in, evaluate the file and use the resulting JSON. Other supported extensions include raw (`.json`) or compressed (`.json.bz2`) files. WireCell::IOError is thrown if file is not found.
Definition at line 121 of file Persist.cxx.
Json::Value WireCell::Persist::loads | ( | const std::string & | text, |
const externalvars_t & | extvar = externalvars_t() , |
||
const externalvars_t & | extcode = externalvars_t() |
||
) |
Load a JSON or Jsonnet string, returning a Json::Value.
Definition at line 152 of file Persist.cxx.
std::string WireCell::Persist::resolve | ( | const std::string & | filename | ) |
Return full path to a file of the given filename. If the file is not directly located and is a relative path then the file will be first located in the current working directory. Failing that if the WIRECELL_PATH
environment variable is defined and set as a :
-separated list it will be checked. Failure to resolve returns an empty string.
Definition at line 99 of file Persist.cxx.
std::string WireCell::Persist::slurp | ( | const std::string & | filename | ) |
Return a string holding the entire contents of the file. File resolution is performed. WireCell::IOError is thrown if file is not found.
Definition at line 65 of file Persist.cxx.