CASM
AClustersApproachtoStatisticalMechanics
|
JSON input/output.
Classes | |
class | CASM::jsonParser |
struct | CASM::jsonConstructor< ReturnType > |
Helper struct for constructing objects that need additional data. More... | |
class | CASM::jsonParserIterator< IsConst > |
Functions | |
std::ostream & | CASM::operator<< (std::ostream &stream, const jsonParser &json) |
std::istream & | CASM::operator>> (std::istream &stream, jsonParser &json) |
jsonParser & | CASM::to_json (bool value, jsonParser &json) |
To JSON for basic types. More... | |
jsonParser & | CASM::to_json (int value, jsonParser &json) |
jsonParser & | CASM::to_json (unsigned int value, jsonParser &json) |
jsonParser & | CASM::to_json (long int value, jsonParser &json) |
jsonParser & | CASM::to_json (unsigned long int value, jsonParser &json) |
jsonParser & | CASM::to_json (double value, jsonParser &json) |
jsonParser & | CASM::to_json (const std::string &value, jsonParser &json) |
jsonParser & | CASM::to_json (const char *value, jsonParser &json) |
jsonParser & | CASM::to_json (const jsonParser &value, jsonParser &json) |
template<typename T > | |
T | CASM::from_json (const jsonParser &json) |
From JSON for basic types. More... | |
template<> | |
bool | CASM::from_json< bool > (const jsonParser &json) |
template<> | |
int | CASM::from_json< int > (const jsonParser &json) |
template<> | |
unsigned int | CASM::from_json< unsigned int > (const jsonParser &json) |
template<> | |
long int | CASM::from_json< long int > (const jsonParser &json) |
template<> | |
unsigned long int | CASM::from_json< unsigned long int > (const jsonParser &json) |
template<> | |
double | CASM::from_json< double > (const jsonParser &json) |
template<> | |
std::string | CASM::from_json< std::string > (const jsonParser &json) |
template<> | |
jsonParser | CASM::from_json< jsonParser > (const jsonParser &json) |
void | CASM::from_json (bool &value, const jsonParser &json) |
From JSON for basic types. More... | |
void | CASM::from_json (int &value, const jsonParser &json) |
void | CASM::from_json (unsigned int &value, const jsonParser &json) |
void | CASM::from_json (long int &value, const jsonParser &json) |
void | CASM::from_json (unsigned long int &value, const jsonParser &json) |
void | CASM::from_json (double &value, const jsonParser &json) |
void | CASM::from_json (std::string &value, const jsonParser &json) |
void | CASM::from_json (jsonParser &value, const jsonParser &json) |
void | CASM::from_json (std::istream &stream, const jsonParser &json) |
void | CASM::from_json (fs::path &value, const jsonParser &json) |
void | CASM::to_json (std::istream &stream, jsonParser &json) |
Create a jsonParser from a stream. More... | |
void | CASM::to_json (fs::path file_path, jsonParser &json) |
template<typename T > | |
jsonParser & | CASM::to_json (const std::complex< T > &value, jsonParser &json) |
To JSON for complex. More... | |
template<typename T > | |
void | CASM::from_json (std::complex< T > &value, const jsonParser &json) |
From JSON for complex. More... | |
template<typename Key , typename T > | |
jsonParser & | CASM::to_json (const std::pair< Key, T > &value, jsonParser &json) |
To JSON for std::pair<std::string, T> More... | |
template<typename Key , typename T > | |
void | CASM::from_json (std::pair< Key, T > &value, const jsonParser &json) |
From JSON for std::pair<std::string, T> More... | |
boost::filesystem::path | CASM::find_diff (const jsonParser &A, const jsonParser &B, boost::filesystem::path diff=boost::filesystem::path()) |
Return the location at which jsonParser 'A' != 'B' as a boost::filesystem::path. More... | |
boost::filesystem::path | CASM::find_diff (const jsonParser &A, const jsonParser &B, double tol, boost::filesystem::path diff=boost::filesystem::path()) |
Return the location at which jsonParser !A.almost_equal(B, tol) as a boost::filesystem::path. More... | |
template<typename T > | |
jsonParser & | CASM::jsonParser::push_back (const T &value) |
Puts new valued element at end of array of any type T for which 'jsonParser& to_json( const T &value, jsonParser &json)' is defined. More... | |
template<typename T , typename... Args> | |
T | CASM::jsonParser::get (Args...args) const |
Get data from json, using one of several alternatives. More... | |
template<typename T , typename... Args> | |
void | CASM::jsonParser::get (T &t, Args...args) const |
template<typename T , typename... Args> | |
bool | CASM::jsonParser::get_if (T &t, const std::string &key, Args...args) const |
template<typename T , typename... Args> | |
bool | CASM::jsonParser::get_else (T &t, const std::string &key, const T &default_value, Args...args) const |
template<typename T > | |
jsonParser & | CASM::jsonParser::put (const T &value) |
Puts data of any type T for which 'jsonParser& to_json( const T &value, jsonParser &json)' is defined (same as 'operator=') More... | |
template<typename Iterator > | |
jsonParser & | CASM::jsonParser::put_obj (Iterator begin, Iterator end) |
Puts new JSON object, from iterators over a range of values of type std::pair<std::string, T> More... | |
template<typename T > | |
jsonParser & | CASM::jsonParser::put_array (size_type N, const T &t) |
Puts new JSON array, using the same value. More... | |
template<typename Iterator > | |
jsonParser & | CASM::jsonParser::put_array (Iterator begin, Iterator end, typename CASM_TMP::enable_if_iterator< Iterator >::type *=nullptr) |
Puts new JSON array, from iterators. More... | |
template<typename T > | |
jsonParser & | CASM::jsonParser::operator= (const T &value) |
Puts data of any type T for which 'jsonParser& to_json( const T &value, jsonParser &json)' is defined. More... | |
template<typename T > | |
jsonParser & | CASM::to_json (const std::map< std::string, T > &map, jsonParser &json) |
Converts to a JSON object. More... | |
template<typename T > | |
void | CASM::from_json (std::map< std::string, T > &map, const jsonParser &json) |
template<typename T > | |
jsonParser & | CASM::to_json (const std::vector< T > &vec, jsonParser &json) |
Converts to a JSON array. More... | |
template<typename T > | |
void | CASM::from_json (std::vector< T > &vec, const jsonParser &json) |
template<typename T , std::size_t N> | |
jsonParser & | CASM::to_json (const std::array< T, N > &arr, jsonParser &json) |
Converts to a JSON array. More... | |
template<typename T , std::size_t N> | |
void | CASM::from_json (std::array< T, N > &arr, const jsonParser &json) |
template<typename T , typename Compare > | |
jsonParser & | CASM::to_json (const std::set< T, Compare > &set, jsonParser &json) |
Converts to a JSON array. More... | |
template<typename T , typename Compare , typename... Args> | |
void | CASM::from_json (std::set< T, Compare > &set, const jsonParser &json, Args...args) |
template<typename Derived > | |
CASM::jsonParser & | CASM::to_json (const Eigen::MatrixBase< Derived > &value, CASM::jsonParser &json) |
Write Eigen Matrix/Vector to JSON. More... | |
template<typename Derived > | |
CASM::jsonParser & | CASM::to_json_array (const Eigen::MatrixBase< Derived > &value, CASM::jsonParser &json) |
Write Eigen Matrix with 1 row or 1 column to JSON array. More... | |
template<typename Derived > | |
void | CASM::from_json (Eigen::MatrixBase< Derived > &value, const CASM::jsonParser &json) |
Read Eigen Matrix/Vector from JSON. More... | |
boost::filesystem::path CASM::find_diff | ( | const jsonParser & | A, |
const jsonParser & | B, | ||
boost::filesystem::path | diff = boost::filesystem::path() |
||
) |
Return the location at which jsonParser 'A' != 'B' as a boost::filesystem::path.
Definition at line 380 of file jsonParser.cc.
boost::filesystem::path CASM::find_diff | ( | const jsonParser & | A, |
const jsonParser & | B, | ||
double | tol, | ||
boost::filesystem::path | diff = boost::filesystem::path() |
||
) |
Return the location at which jsonParser !A.almost_equal(B, tol) as a boost::filesystem::path.
Definition at line 402 of file jsonParser.cc.
void CASM::from_json | ( | std::map< std::string, T > & | map, |
const jsonParser & | json | ||
) |
void CASM::from_json | ( | std::vector< T > & | vec, |
const jsonParser & | json | ||
) |
void CASM::from_json | ( | std::array< T, N > & | arr, |
const jsonParser & | json | ||
) |
void CASM::from_json | ( | std::set< T, Compare > & | set, |
const jsonParser & | json, | ||
Args... | args | ||
) |
Read std::set from JSON array
Clears any previous contents, constructs via jsonConstructor<T>
Definition at line 163 of file container.hh.
void CASM::from_json | ( | Eigen::MatrixBase< Derived > & | value, |
const CASM::jsonParser & | json | ||
) |
Read Eigen Matrix/Vector from JSON.
Definition at line 213 of file container.hh.
T CASM::from_json | ( | const jsonParser & | json | ) |
From JSON for basic types.
Default works if T::T(args...) and 'void from_json(T&, const jsonParser&)' exist.
Definition at line 497 of file jsonParser.hh.
void CASM::from_json | ( | bool & | value, |
const jsonParser & | json | ||
) |
From JSON for basic types.
Definition at line 108 of file jsonParser.cc.
void CASM::from_json | ( | int & | value, |
const jsonParser & | json | ||
) |
Definition at line 112 of file jsonParser.cc.
void CASM::from_json | ( | unsigned int & | value, |
const jsonParser & | json | ||
) |
Definition at line 116 of file jsonParser.cc.
void CASM::from_json | ( | long int & | value, |
const jsonParser & | json | ||
) |
Definition at line 120 of file jsonParser.cc.
void CASM::from_json | ( | unsigned long int & | value, |
const jsonParser & | json | ||
) |
Definition at line 124 of file jsonParser.cc.
void CASM::from_json | ( | double & | value, |
const jsonParser & | json | ||
) |
Definition at line 128 of file jsonParser.cc.
void CASM::from_json | ( | std::string & | value, |
const jsonParser & | json | ||
) |
Definition at line 149 of file jsonParser.cc.
void CASM::from_json | ( | jsonParser & | value, |
const jsonParser & | json | ||
) |
Definition at line 153 of file jsonParser.cc.
void CASM::from_json | ( | std::istream & | stream, |
const jsonParser & | json | ||
) |
void CASM::from_json | ( | fs::path & | value, |
const jsonParser & | json | ||
) |
Definition at line 157 of file jsonParser.cc.
void CASM::from_json | ( | std::complex< T > & | value, |
const jsonParser & | json | ||
) |
void CASM::from_json | ( | std::pair< Key, T > & | value, |
const jsonParser & | json | ||
) |
From JSON for std::pair<std::string, T>
Definition at line 815 of file jsonParser.hh.
bool CASM::from_json< bool > | ( | const jsonParser & | json | ) |
Definition at line 66 of file jsonParser.cc.
double CASM::from_json< double > | ( | const jsonParser & | json | ) |
Definition at line 91 of file jsonParser.cc.
int CASM::from_json< int > | ( | const jsonParser & | json | ) |
Definition at line 71 of file jsonParser.cc.
jsonParser CASM::from_json< jsonParser > | ( | const jsonParser & | json | ) |
Definition at line 103 of file jsonParser.cc.
long int CASM::from_json< long int > | ( | const jsonParser & | json | ) |
Definition at line 81 of file jsonParser.cc.
std::string CASM::from_json< std::string > | ( | const jsonParser & | json | ) |
Definition at line 98 of file jsonParser.cc.
unsigned int CASM::from_json< unsigned int > | ( | const jsonParser & | json | ) |
Definition at line 76 of file jsonParser.cc.
unsigned long int CASM::from_json< unsigned long int > | ( | const jsonParser & | json | ) |
Definition at line 86 of file jsonParser.cc.
T CASM::jsonParser::get | ( | Args... | args | ) | const |
Get data from json, using one of several alternatives.
Get data from json, using one of several alternatives
Use for any type T for which the either of the following is specialized (they are called in the following order):
Definition at line 729 of file jsonParser.hh.
void CASM::jsonParser::get | ( | T & | t, |
Args... | args | ||
) | const |
Get data from json, for any type T for which 'void from_json( T &value, const jsonParser &json, Args... args)' is defined Call using: T t; json.get(t);
Definition at line 734 of file jsonParser.hh.
bool CASM::jsonParser::get_else | ( | T & | t, |
const std::string & | key, | ||
const T & | default_value, | ||
Args... | args | ||
) | const |
Get data from json, if 'this' contains 'key', else set to 'default_value' Returns true if 'key' found, else false
Definition at line 749 of file jsonParser.hh.
bool CASM::jsonParser::get_if | ( | T & | t, |
const std::string & | key, | ||
Args... | args | ||
) | const |
Get data from json, if 'this' contains 'key' Returns true if 'key' found, else false
Definition at line 740 of file jsonParser.hh.
std::ostream & CASM::operator<< | ( | std::ostream & | stream, |
const jsonParser & | json | ||
) |
Definition at line 206 of file jsonParser.cc.
jsonParser & CASM::jsonParser::operator= | ( | const T & | value | ) |
Puts data of any type T for which 'jsonParser& to_json( const T &value, jsonParser &json)' is defined.
Definition at line 802 of file jsonParser.hh.
std::istream & CASM::operator>> | ( | std::istream & | stream, |
jsonParser & | json | ||
) |
Definition at line 174 of file jsonParser.cc.
jsonParser & CASM::jsonParser::push_back | ( | const T & | value | ) |
Puts new valued element at end of array of any type T for which 'jsonParser& to_json( const T &value, jsonParser &json)' is defined.
re-throw exceptions
Definition at line 696 of file jsonParser.hh.
jsonParser & CASM::jsonParser::put | ( | const T & | value | ) |
Puts data of any type T for which 'jsonParser& to_json( const T &value, jsonParser &json)' is defined (same as 'operator=')
Puts data of any type T for which 'jsonParser& to_json( const T &value, jsonParser &json)' is defined (same as operator=)
Definition at line 761 of file jsonParser.hh.
jsonParser & CASM::jsonParser::put_array | ( | size_type | N, |
const T & | t | ||
) |
Puts new JSON array, using the same value.
Definition at line 778 of file jsonParser.hh.
jsonParser & CASM::jsonParser::put_array | ( | Iterator | begin, |
Iterator | end, | ||
typename CASM_TMP::enable_if_iterator< Iterator >::type * | = nullptr |
||
) |
Puts new JSON array, from iterators.
Definition at line 788 of file jsonParser.hh.
jsonParser & CASM::jsonParser::put_obj | ( | Iterator | begin, |
Iterator | end | ||
) |
Puts new JSON object, from iterators over a range of values of type std::pair<std::string, T>
Definition at line 767 of file jsonParser.hh.
jsonParser& CASM::to_json | ( | const std::map< std::string, T > & | map, |
jsonParser & | json | ||
) |
Converts to a JSON object.
Definition at line 91 of file container.hh.
jsonParser& CASM::to_json | ( | const std::vector< T > & | vec, |
jsonParser & | json | ||
) |
Converts to a JSON array.
Definition at line 110 of file container.hh.
jsonParser& CASM::to_json | ( | const std::array< T, N > & | arr, |
jsonParser & | json | ||
) |
Converts to a JSON array.
Definition at line 130 of file container.hh.
jsonParser& CASM::to_json | ( | const std::set< T, Compare > & | set, |
jsonParser & | json | ||
) |
Converts to a JSON array.
Definition at line 155 of file container.hh.
CASM::jsonParser& CASM::to_json | ( | const Eigen::MatrixBase< Derived > & | value, |
CASM::jsonParser & | json | ||
) |
Write Eigen Matrix/Vector to JSON.
Definition at line 175 of file container.hh.
jsonParser & CASM::to_json | ( | bool | value, |
jsonParser & | json | ||
) |
To JSON for basic types.
Functions for converting basic types to/from json.
Definition at line 8 of file jsonParser.cc.
jsonParser & CASM::to_json | ( | int | value, |
jsonParser & | json | ||
) |
Definition at line 13 of file jsonParser.cc.
jsonParser & CASM::to_json | ( | unsigned int | value, |
jsonParser & | json | ||
) |
Definition at line 18 of file jsonParser.cc.
jsonParser & CASM::to_json | ( | long int | value, |
jsonParser & | json | ||
) |
Definition at line 23 of file jsonParser.cc.
jsonParser & CASM::to_json | ( | unsigned long int | value, |
jsonParser & | json | ||
) |
Definition at line 28 of file jsonParser.cc.
jsonParser & CASM::to_json | ( | double | value, |
jsonParser & | json | ||
) |
Definition at line 33 of file jsonParser.cc.
jsonParser & CASM::to_json | ( | const std::string & | value, |
jsonParser & | json | ||
) |
Definition at line 50 of file jsonParser.cc.
jsonParser & CASM::to_json | ( | const char * | value, |
jsonParser & | json | ||
) |
Definition at line 55 of file jsonParser.cc.
jsonParser & CASM::to_json | ( | const jsonParser & | value, |
jsonParser & | json | ||
) |
Definition at line 60 of file jsonParser.cc.
|
inline |
Create a jsonParser from a stream.
Definition at line 428 of file jsonParser.hh.
|
inline |
Create a jsonParser by reading a file
This function reads the contents of the file at 'file_path' as if it were JSON. Use 'to_json(file_path.string(), json)' if you only want the path as a string
Definition at line 440 of file jsonParser.hh.
jsonParser& CASM::to_json | ( | const std::complex< T > & | value, |
jsonParser & | json | ||
) |
To JSON for complex.
Definition at line 450 of file jsonParser.hh.
jsonParser & CASM::to_json | ( | const std::pair< Key, T > & | value, |
jsonParser & | json | ||
) |
To JSON for std::pair<std::string, T>
To JSON for std::pair<std::string, T> and other convertible types.
Definition at line 808 of file jsonParser.hh.
CASM::jsonParser& CASM::to_json_array | ( | const Eigen::MatrixBase< Derived > & | value, |
CASM::jsonParser & | json | ||
) |
Write Eigen Matrix with 1 row or 1 column to JSON array.
Definition at line 191 of file container.hh.