template<typename ObjectType>
class CASM::simpleformatter::DataFormatter< ObjectType >
Abstract base class for a DataFormatter implementation
- Holds a vector of Evaluator pointers (
std::unique_ptr<BaseDatumEvaluator<ObjectType>>
) which are used sequentially by operator()(ObjectType const &object)
to evaluate and format properties of an object.
- During the course of evaluation, any errors thrown by evaluators are caught and added to a vector of error messages. The values that could not be formatted due to the error are replaced by strings "error_$i", where "$i" is the index into the error message vector.
Example usage (with derived class jsonDataFormatter):
jsonDataFormatter<ConfigEnumData<EnumeratorType, InitialStateType>>
formatter {...options...}; formatter.push_back(
ConfigEnumIO::dof_strain());
formatter.init();
for(auto const &data : config_enum_data) {
formatter(data);
}
jsonParser result;
result["data"] = formatter.value();
result["errors"] = formatter.errors();
GenericDatumFormatter< std::string, ConfigEnumDataType > name()
GenericDatumFormatter< bool, ConfigEnumDataType > selected()
Definition at line 362 of file SimpleFormatter.hh.
|
| DataFormatter () |
|
virtual | ~DataFormatter () |
|
virtual std::string | formatter_type () const =0 |
|
virtual void | init ()=0 |
|
virtual void | format (std::string const &value_name, bool const &value)=0 |
|
virtual void | format (std::string const &value_name, long const &value)=0 |
|
virtual void | format (std::string const &value_name, double const &value)=0 |
|
virtual void | format (std::string const &value_name, std::string const &value)=0 |
|
virtual void | format (std::string const &value_name, Eigen::MatrixXl const &value)=0 |
|
virtual void | format (std::string const &value_name, Eigen::MatrixXd const &value)=0 |
|
virtual void | format (std::string const &value_name, jsonParser const &value)=0 |
|
virtual void | operator() (ObjectType const &object)=0 |
| Evaluate all DatumEvaluators and format results. More...
|
|
std::vector< std::string > const & | errors () const |
| Access error messages from caught exceptions that occur during evaluation. More...
|
|
int | insert_error (std::string what) |
|