CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
CASM::Properties Class Reference

#include <Properties.hh>

+ Inheritance diagram for CASM::Properties:

Detailed Description

Definition at line 58 of file Properties.hh.

Public Types

typedef
json_spirit::mObject::size_type 
size_type
 
typedef jsonParserIterator< false > iterator
 
typedef jsonParserIterator< true > const_iterator
 

Public Member Functions

 Properties ()
 
 Properties (const jsonParser &json)
 
 Properties (std::istream &stream)
 
 Properties (const std::string &file_name)
 
 Properties (const fs::path &mypath)
 
Propertiesoperator+= (const DeltaProperties &delta)
 
Properties operator+ (const DeltaProperties &delta) const
 
DeltaProperties operator- (const Properties &ref) const
 
Propertiesoperator= (const jsonParser &json)
 
bool read (std::istream &stream)
 Reads json from the stream. More...
 
bool read (const boost::filesystem::path &mypath)
 Reads json from a path. More...
 
void print (std::ostream &stream, unsigned int indent=2, unsigned int prec=12) const
 Print json to stream. More...
 
void write (const std::string &file_name, unsigned int indent=2, unsigned int prec=12) const
 Write json to file. More...
 
void write (const boost::filesystem::path &mypath, unsigned int indent=2, unsigned int prec=12) const
 Write json to file. More...
 
bool operator!= (const jsonParser &json) const
 
bool almost_equal (const jsonParser &B, double tol) const
 
bool is_null () const
 Check if null type. More...
 
bool is_bool () const
 Check if bool type. More...
 
bool is_int () const
 Check if int type. More...
 
bool is_number () const
 Check if number type (not including int) More...
 
bool is_string () const
 Check if string. More...
 
bool is_obj () const
 Check if object type. More...
 
bool is_array () const
 Check if array type. More...
 
jsonParseroperator[] (const std::string &name)
 
const jsonParseroperator[] (const std::string &name) const
 
jsonParseroperator[] (const int &element)
 Return a reference to the sub-jsonParser (JSON value) from index 'element' iff jsonParser is a JSON array. More...
 
const jsonParseroperator[] (const int &element) const
 Return a const reference to the sub-jsonParser (JSON value) from index 'element' iff jsonParser is a JSON array. More...
 
jsonParserat (const fs::path &path)
 
const jsonParserat (const fs::path &path) const
 
size_type size () const
 Returns array size if *this is a JSON array, object size if *this is a JSON object, 1 otherwise. More...
 
iterator begin ()
 Returns const_iterator to beginning of JSON object or JSON array. More...
 
const_iterator begin () const
 Returns iterator to beginning of JSON object or JSON array. More...
 
iterator end ()
 Returns iterator to end of JSON object or JSON array. More...
 
const_iterator end () const
 Returns const_iterator to end of JSON object or JSON array. More...
 
const_iterator cbegin () const
 Returns const_iterator to beginning of JSON object or JSON array. More...
 
const_iterator cend () const
 Returns const_iterator to end of JSON object or JSON array. More...
 
iterator find (const std::string &name)
 Return iterator to JSON object value with 'name'. More...
 
const_iterator find (const std::string &name) const
 Return const_iterator to JSON object value with 'name'. More...
 
bool contains (const std::string &name) const
 Return true if JSON object contains 'name'. More...
 
size_type erase (const std::string &name)
 Erase key:value pair from an object. More...
 
template<typename T , typename... Args>
get (Args...args) const
 Get data from json, using one of several alternatives. More...
 
template<typename T , typename... Args>
void get (T &t, Args...args) const
 
template<typename T , typename... Args>
bool get_if (T &t, const std::string &key, Args...args) const
 
template<typename T , typename... Args>
bool get_else (T &t, const std::string &key, const T &default_value, Args...args) const
 
template<typename T >
jsonParserpush_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 >
jsonParserput (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...
 
jsonParserput_obj ()
 Puts new empty JSON object. More...
 
template<typename Iterator >
jsonParserput_obj (Iterator begin, Iterator end)
 Puts new JSON object, from iterators over a range of values of type std::pair<std::string, T> More...
 
jsonParserput_array ()
 Puts new empty JSON array. More...
 
jsonParserput_array (size_type N)
 Puts new JSON array. More...
 
template<typename T >
jsonParserput_array (size_type N, const T &t)
 Puts new JSON array, using the same value. More...
 
template<typename Iterator >
jsonParserput_array (Iterator begin, Iterator end, typename CASM_TMP::enable_if_iterator< Iterator >::type *=nullptr)
 Puts new JSON array, from iterators. More...
 
jsonParserput_null ()
 Puts 'null' JSON value. More...
 

Static Public Member Functions

static jsonParser parse (const std::string &str)
 Construct a jsonParser from a string containing JSON data. More...
 
static jsonParser parse (const fs::path &path)
 Construct a jsonParser from a file containing JSON data. More...
 
static jsonParser parse (std::istream &stream)
 Construct a jsonParser from a stream containing JSON data. More...
 
static jsonParser object ()
 Returns an empty json object. More...
 
template<typename Iterator >
static jsonParser object (Iterator begin, Iterator end)
 Puts new JSON object, from iterators over a range of values of type std::pair<std::string, T> More...
 
static jsonParser array ()
 Returns an empty json array. More...
 
static jsonParser array (size_type N)
 Returns an empty json array. More...
 
template<typename T >
static jsonParser array (size_type N, const T &t)
 Puts new JSON array, using the same value. More...
 
template<typename Iterator >
static jsonParser array (Iterator begin, Iterator end, typename CASM_TMP::enable_if_iterator< Iterator >::type *=nullptr)
 Puts new JSON array, from iterators. More...
 
static jsonParser null ()
 Returns a null JSON value. More...
 

Member Typedef Documentation

Definition at line 84 of file jsonParser.hh.

Definition at line 83 of file jsonParser.hh.

typedef json_spirit::mObject::size_type CASM::jsonParser::size_type
inherited

Definition at line 82 of file jsonParser.hh.

Constructor & Destructor Documentation

CASM::Properties::Properties ( )
inline

Definition at line 62 of file Properties.hh.

CASM::Properties::Properties ( const jsonParser json)
inline

Definition at line 64 of file Properties.hh.

CASM::Properties::Properties ( std::istream &  stream)
inline

Definition at line 66 of file Properties.hh.

CASM::Properties::Properties ( const std::string &  file_name)
inline

Definition at line 68 of file Properties.hh.

CASM::Properties::Properties ( const fs::path &  mypath)
inline

Definition at line 70 of file Properties.hh.

Member Function Documentation

bool CASM::jsonParser::almost_equal ( const jsonParser B,
double  tol 
) const
inherited

Definition at line 211 of file jsonParser.cc.

static jsonParser CASM::jsonParser::array ( )
inlinestaticinherited

Returns an empty json array.

Definition at line 342 of file jsonParser.hh.

static jsonParser CASM::jsonParser::array ( size_type  N)
inlinestaticinherited

Returns an empty json array.

Definition at line 348 of file jsonParser.hh.

template<typename T >
static jsonParser CASM::jsonParser::array ( size_type  N,
const T &  t 
)
inlinestaticinherited

Puts new JSON array, using the same value.

Definition at line 355 of file jsonParser.hh.

template<typename Iterator >
static jsonParser CASM::jsonParser::array ( Iterator  begin,
Iterator  end,
typename CASM_TMP::enable_if_iterator< Iterator >::type *  = nullptr 
)
inlinestaticinherited

Puts new JSON array, from iterators.

Definition at line 362 of file jsonParser.hh.

jsonParser & CASM::jsonParser::at ( const fs::path &  path)
inherited

Return a reference to the sub-jsonParser (JSON value) with specified relative path Will throw if the 'path' doesn't exist.

  • If 'path' is 'A/B/C', then json.at(path) is equivalent to json[A][B][C]
  • If any sub-jsonParser is an array, it will attempt to convert the filename to int

Return a reference to the sub-jsonParser (JSON value) with specified relative path Will throw if the 'path' doesn't exist.

  • If 'path' is 'A/B/C', then json[path] is equivalent to json[A][B][C]
  • If any sub-jsonParser is an array, it will attempt to convert the filename to int

Definition at line 321 of file jsonParser.cc.

const jsonParser & CASM::jsonParser::at ( const fs::path &  path) const
inherited

Return a reference to the sub-jsonParser (JSON value) with specified relative path Will throw if the 'path' doesn't exist.

  • If 'path' is 'A/B/C', then json.at(path) is equivalent to json[A][B][C]
  • If any sub-jsonParser is an array, it will attempt to convert the filename to int

Return a reference to the sub-jsonParser (JSON value) with specified relative path Will throw if the 'path' doesn't exist.

  • If 'path' is 'A/B/C', then json[path] is equivalent to json[A][B][C]
  • If any sub-jsonParser is an array, it will attempt to convert the filename to int

Definition at line 330 of file jsonParser.cc.

jsonParser::iterator CASM::jsonParser::begin ( )
inherited

Returns const_iterator to beginning of JSON object or JSON array.

Returns iterator to beginning of JSON object or JSON array.

Definition at line 440 of file jsonParser.cc.

jsonParser::const_iterator CASM::jsonParser::begin ( ) const
inherited

Returns iterator to beginning of JSON object or JSON array.

Returns const_iterator to beginning of JSON object or JSON array.

Definition at line 450 of file jsonParser.cc.

jsonParser::const_iterator CASM::jsonParser::cbegin ( ) const
inherited

Returns const_iterator to beginning of JSON object or JSON array.

Returns const iterator to beginning of const JSON object or JSON array.

Definition at line 455 of file jsonParser.cc.

jsonParser::const_iterator CASM::jsonParser::cend ( ) const
inherited

Returns const_iterator to end of JSON object or JSON array.

Definition at line 480 of file jsonParser.cc.

bool CASM::jsonParser::contains ( const std::string &  name) const
inherited

Return true if JSON object contains 'name'.

Definition at line 500 of file jsonParser.cc.

jsonParser::iterator CASM::jsonParser::end ( )
inherited

Returns iterator to end of JSON object or JSON array.

Definition at line 465 of file jsonParser.cc.

jsonParser::const_iterator CASM::jsonParser::end ( ) const
inherited

Returns const_iterator to end of JSON object or JSON array.

Returns iterator to end of JSON object or JSON array.

Definition at line 475 of file jsonParser.cc.

json_spirit::mObject::size_type CASM::jsonParser::erase ( const std::string &  name)
inherited

Erase key:value pair from an object.

Erase key:value pair from an object Returns the number of elements erased, which will be 0 or 1

Definition at line 506 of file jsonParser.cc.

jsonParser::iterator CASM::jsonParser::find ( const std::string &  name)
inherited

Return iterator to JSON object value with 'name'.

Definition at line 490 of file jsonParser.cc.

jsonParser::const_iterator CASM::jsonParser::find ( const std::string &  name) const
inherited

Return const_iterator to JSON object value with 'name'.

Definition at line 495 of file jsonParser.cc.

bool CASM::jsonParser::is_array ( ) const
inherited

Check if array type.

Definition at line 281 of file jsonParser.cc.

bool CASM::jsonParser::is_bool ( ) const
inherited

Check if bool type.

Definition at line 256 of file jsonParser.cc.

bool CASM::jsonParser::is_int ( ) const
inherited

Check if int type.

Definition at line 261 of file jsonParser.cc.

bool CASM::jsonParser::is_null ( ) const
inherited

Check if null type.

Definition at line 251 of file jsonParser.cc.

bool CASM::jsonParser::is_number ( ) const
inherited

Check if number type (not including int)

Definition at line 266 of file jsonParser.cc.

bool CASM::jsonParser::is_obj ( ) const
inherited

Check if object type.

Definition at line 276 of file jsonParser.cc.

bool CASM::jsonParser::is_string ( ) const
inherited

Check if string.

Definition at line 271 of file jsonParser.cc.

static jsonParser CASM::jsonParser::null ( )
inlinestaticinherited

Returns a null JSON value.

Definition at line 371 of file jsonParser.hh.

static jsonParser CASM::jsonParser::object ( )
inlinestaticinherited

Returns an empty json object.

Definition at line 329 of file jsonParser.hh.

template<typename Iterator >
static jsonParser CASM::jsonParser::object ( Iterator  begin,
Iterator  end 
)
inlinestaticinherited

Puts new JSON object, from iterators over a range of values of type std::pair<std::string, T>

Definition at line 336 of file jsonParser.hh.

bool CASM::jsonParser::operator!= ( const jsonParser json) const
inlineinherited

Definition at line 157 of file jsonParser.hh.

Properties CASM::Properties::operator+ ( const DeltaProperties delta) const

Definition at line 43 of file Properties.cc.

Properties & CASM::Properties::operator+= ( const DeltaProperties delta)

Definition at line 6 of file Properties.cc.

DeltaProperties CASM::Properties::operator- ( const Properties ref) const

Definition at line 49 of file Properties.cc.

Properties& CASM::Properties::operator= ( const jsonParser json)
inline

Definition at line 78 of file Properties.hh.

jsonParser & CASM::jsonParser::operator[] ( const std::string &  name)
inherited

Return a reference to the sub-jsonParser (JSON value) with 'name' if it exists If it does not exist, create it with an empty JSON object and return a reference to it

Return a reference to the sub-jsonParser (JSON value) with 'name' if it exists If it does not exist, create it with value == 'null' and return a reference

Definition at line 290 of file jsonParser.cc.

const jsonParser & CASM::jsonParser::operator[] ( const std::string &  name) const
inherited

Return a reference to the sub-jsonParser (JSON value) with 'name' if it exists. Will throw if the 'name' doesn't exist.

Definition at line 304 of file jsonParser.cc.

jsonParser & CASM::jsonParser::operator[] ( const int &  element)
inherited

Return a reference to the sub-jsonParser (JSON value) from index 'element' iff jsonParser is a JSON array.

Definition at line 368 of file jsonParser.cc.

const jsonParser & CASM::jsonParser::operator[] ( const int &  element) const
inherited

Return a const reference to the sub-jsonParser (JSON value) from index 'element' iff jsonParser is a JSON array.

Definition at line 374 of file jsonParser.cc.

static jsonParser CASM::jsonParser::parse ( const std::string &  str)
inlinestaticinherited

Construct a jsonParser from a string containing JSON data.

Definition at line 312 of file jsonParser.hh.

static jsonParser CASM::jsonParser::parse ( const fs::path &  path)
inlinestaticinherited

Construct a jsonParser from a file containing JSON data.

Definition at line 319 of file jsonParser.hh.

static jsonParser CASM::jsonParser::parse ( std::istream &  stream)
inlinestaticinherited

Construct a jsonParser from a stream containing JSON data.

Definition at line 324 of file jsonParser.hh.

void CASM::jsonParser::print ( std::ostream &  stream,
unsigned int  indent = 2,
unsigned int  prec = 12 
) const
inherited

Print json to stream.

Writes json to stream.

Definition at line 185 of file jsonParser.cc.

jsonParser& CASM::jsonParser::put_array ( )
inlineinherited

Puts new empty JSON array.

Definition at line 285 of file jsonParser.hh.

jsonParser& CASM::jsonParser::put_array ( size_type  N)
inlineinherited

Puts new JSON array.

Definition at line 290 of file jsonParser.hh.

jsonParser& CASM::jsonParser::put_null ( )
inlineinherited

Puts 'null' JSON value.

Definition at line 305 of file jsonParser.hh.

jsonParser& CASM::jsonParser::put_obj ( )
inlineinherited

Puts new empty JSON object.

Definition at line 276 of file jsonParser.hh.

bool CASM::jsonParser::read ( std::istream &  stream)
inherited

Reads json from the stream.

Definition at line 165 of file jsonParser.cc.

bool CASM::jsonParser::read ( const boost::filesystem::path &  mypath)
inherited

Reads json from a path.

Definition at line 169 of file jsonParser.cc.

jsonParser::size_type CASM::jsonParser::size ( ) const
inherited

Returns array size if *this is a JSON array, object size if *this is a JSON object, 1 otherwise.

Definition at line 430 of file jsonParser.cc.

void CASM::jsonParser::write ( const std::string &  file_name,
unsigned int  indent = 2,
unsigned int  prec = 12 
) const
inherited

Write json to file.

Definition at line 191 of file jsonParser.cc.

void CASM::jsonParser::write ( const boost::filesystem::path &  mypath,
unsigned int  indent = 2,
unsigned int  prec = 12 
) const
inherited

Write json to file.

Definition at line 199 of file jsonParser.cc.


The documentation for this class was generated from the following files: