![]() |
Stan
2.5.0
probability, sampling & optimization
|
A json_data is a var_context object that represents a set of named values which are typed to either double or int and can be either scalar value or a non-empty array of values of any dimensionality.
More...
#include <json_data.hpp>
Public Member Functions | |
| json_data (std::istream &in) | |
| Construct a json_data object from the specified input stream. More... | |
| bool | contains_r (const std::string &name) const |
Return true if this json_data contains the specified variable name. More... | |
| bool | contains_i (const std::string &name) const |
Return true if this json_data contains an integer valued array with the specified name. More... | |
| std::vector< double > | vals_r (const std::string &name) const |
| Return the double values for the variable with the specified name or null. More... | |
| std::vector< size_t > | dims_r (const std::string &name) const |
| Return the dimensions for the variable with the specified name. More... | |
| std::vector< int > | vals_i (const std::string &name) const |
| Return the integer values for the variable with the specified name. More... | |
| std::vector< size_t > | dims_i (const std::string &name) const |
| Return the dimensions for the integer variable with the specified name. More... | |
| virtual void | names_r (std::vector< std::string > &names) const |
| Return a list of the names of the floating point variables in the json_data. More... | |
| virtual void | names_i (std::vector< std::string > &names) const |
| Return a list of the names of the integer variables in the json_data. More... | |
| bool | remove (const std::string &name) |
| Remove variable from the object. More... | |
Public Member Functions inherited from stan::io::var_context | |
| virtual | ~var_context () |
| void | add_vec (std::stringstream &msg, const std::vector< size_t > &dims) const |
| void | validate_dims (const std::string &stage, const std::string &name, const std::string &base_type, const std::vector< size_t > &dims_declared) const |
Additional Inherited Members | |
Static Public Member Functions inherited from stan::io::var_context | |
| static std::vector< size_t > | to_vec () |
| static std::vector< size_t > | to_vec (size_t n1) |
| static std::vector< size_t > | to_vec (size_t n1, size_t n2) |
| static std::vector< size_t > | to_vec (size_t n1, size_t n2, size_t n3) |
| static std::vector< size_t > | to_vec (size_t n1, size_t n2, size_t n3, size_t n4) |
| static std::vector< size_t > | to_vec (size_t n1, size_t n2, size_t n3, size_t n4, size_t n5) |
| static std::vector< size_t > | to_vec (size_t n1, size_t n2, size_t n3, size_t n4, size_t n5, size_t n6) |
| static std::vector< size_t > | to_vec (size_t n1, size_t n2, size_t n3, size_t n4, size_t n5, size_t n6, size_t n7) |
| static std::vector< size_t > | to_vec (size_t n1, size_t n2, size_t n3, size_t n4, size_t n5, size_t n6, size_t n7, size_t n8) |
A json_data is a var_context object that represents a set of named values which are typed to either double or int and can be either scalar value or a non-empty array of values of any dimensionality.
Arrays must be retangular and the values of an array are all of the same type, either double or int.
The dimensions and values of variables are accessed by variable name. The values of a variable are stored as a vector of values and a vector of array dimensions, where a scalar value consists of a single value and an emtpy vector for the dimensionality. Multidimensional arrays are stored in column-major order, meaning the first index changes the most quickly. If all the values of an array are int values, the array will be stored as a vector of ints, else the array will be stored as a vector of type double.
json_data objects are created by using the json_parser and a json_data_handler to read a single JSON text from an input stream.
Definition at line 46 of file json_data.hpp.
|
inline |
Construct a json_data object from the specified input stream.
Warning: This method does not close the input stream.
| in | Input stream from which to read. |
| json_exception | if data is not well-formed stan data declaration |
Definition at line 78 of file json_data.hpp.
|
inlinevirtual |
Return true if this json_data contains an integer valued array with the specified name.
| name | Variable name to test. |
true if the variable name has an integer array value. Implements stan::io::var_context.
Definition at line 103 of file json_data.hpp.
|
inlinevirtual |
Return true if this json_data contains the specified variable name.
This method returns true even if the values are all integers.
| name | Variable name to test. |
true if the variable exists. Implements stan::io::var_context.
Definition at line 91 of file json_data.hpp.
|
inlinevirtual |
Return the dimensions for the integer variable with the specified name.
| name | Name of variable. |
Implements stan::io::var_context.
Definition at line 165 of file json_data.hpp.
|
inlinevirtual |
Return the dimensions for the variable with the specified name.
| name | Name of variable. |
Implements stan::io::var_context.
Definition at line 135 of file json_data.hpp.
|
inlinevirtual |
Return a list of the names of the integer variables in the json_data.
| names | Vector to store the list of names in. |
Implements stan::io::var_context.
Definition at line 191 of file json_data.hpp.
|
inlinevirtual |
Return a list of the names of the floating point variables in the json_data.
| names | Vector to store the list of names in. |
Implements stan::io::var_context.
Definition at line 178 of file json_data.hpp.
|
inline |
Remove variable from the object.
| name | Name of the variable to remove. |
true, else returns false. Definition at line 205 of file json_data.hpp.
|
inlinevirtual |
Return the integer values for the variable with the specified name.
| name | Name of variable. |
Implements stan::io::var_context.
Definition at line 151 of file json_data.hpp.
|
inlinevirtual |
Return the double values for the variable with the specified name or null.
| name | Name of variable. |
Implements stan::io::var_context.
Definition at line 114 of file json_data.hpp.