1 #ifndef CASM_DataFormatter
2 #define CASM_DataFormatter
72 const std::string &_expr);
81 std::vector<std::string> &tag_names,
82 std::vector<std::string> &sub_exprs);
91 std::vector<std::string> &tag_names,
92 std::vector<std::string> &sub_exprs);
167 template <
typename _DataObject>
171 template <
typename IteratorType>
179 DataFormatter(
int _sep = 4,
int _precision = 12, std::string _comment =
"#")
188 template <
typename... Args>
197 template <
typename IteratorType>
199 IteratorType end)
const {
221 template <
typename ValueType>
225 template <
typename ValueType>
232 template <
typename ValueType,
typename IteratorType>
234 IteratorType end)
const;
237 template <
typename IteratorType>
239 IteratorType end)
const;
262 const std::string &args) {
283 template <
typename... Args>
285 const Args &... formatters) {
307 std::vector<notstd::cloneable_ptr<BaseDatumFormatter<DataObject> > >
331 template <
typename _DataObject>
369 std::unique_ptr<BaseDatumFormatter<DataObject> >
clone()
const {
370 return std::unique_ptr<BaseDatumFormatter<DataObject> >(this->
_clone());
376 virtual bool init(
const DataObject &_template_obj)
const {
return true; };
391 return std::vector<std::string>{this->
short_header(_template_obj)};
401 if (_col.size() == 1) {
405 std::stringstream t_ss;
406 for (
Index i = 0; i < _col.size(); i++) {
407 t_ss <<
" " << _col[i];
430 Index pass_index = 0)
const = 0;
436 Index pass_index = 0)
const = 0;
456 virtual bool parse_args(
const std::string &args) {
return args.size() == 0; }
472 void _add_rule(
const std::vector<Index> &new_rule)
const {
504 virtual void print(std::ostream &stream)
const = 0;
516 template <
typename DataObject>
517 template <
typename IteratorType>
525 IteratorType _begin, IteratorType _end)
526 : m_formatter_ptr(_formatter_ptr), m_begin_it(_begin), m_end_it(_end) {}
529 if (m_begin_it == m_end_it)
return;
532 std::stringstream _ss;
534 for (IteratorType it(m_begin_it); it != m_end_it; ++it)
535 m_formatter_ptr->
inject(*it, _stream);
538 void print(std::ostream &_stream)
const {
539 if (m_begin_it == m_end_it)
return;
546 std::stringstream _ss;
551 for (IteratorType it(m_begin_it); it != m_end_it; ++it)
552 m_formatter_ptr->
print(*it, _stream);
557 for (IteratorType it(m_begin_it); it != m_end_it; ++it)
565 for (IteratorType it(m_begin_it); it != m_end_it; ++it)
579 template <
typename DataObject>
587 : m_formatter_ptr(_formatter_ptr), m_obj_ptr(&_obj) {}
590 m_formatter_ptr->
inject(*m_obj_ptr, _stream);
593 void print(std::ostream &_stream)
const {
600 m_formatter_ptr->
print(*m_obj_ptr, _stream);
604 m_formatter_ptr->
to_json(*m_obj_ptr, json);
612 template <
typename DataObject,
typename DatumFormatterType>
643 typename _DataObject,
644 typename _DatumFormatterType >
690 using UniqueMapType::insert;
694 const_iterator lookup(
const key_type &_name)
const;
698 return this->
find(_name) != this->end();
702 int width = 60,
int separation = 8)
const;
712 std::initializer_list<std::string> input)
const;
719 template <
typename DataObject>
723 template <
typename DataObject>
731 template <
typename DataObject>
734 dict.
insert(make_attribute_dictionary<DataObject>(),
735 make_operator_dictionary<DataObject>());
749 _formatted.
print(_stream);
756 _formatted.
inject(_stream);
static jsonParser object()
Returns an empty json object.
jsonParser & put_array()
Puts new empty JSON array.
An iterator over a UniqueMap.
A 'cloneable_ptr' can be used in place of 'unique_ptr'.
std::map wrapper to enforce a 1-1 ValueType->KeyType relationship
MapType::size_type size_type
jsonParser & push_back(const T &value, Args &&... args)
std::pair< std::vector< long >, std::vector< long > > index_expression_to_bounds(const std::string &_expr)
DataStream & operator<<(DataStream &_stream, const FormattedPrintable &_formatted)
DataFormatterDictionary< DataObject > make_operator_dictionary()
Dictionary of all DatumFormatterOperator.
void split_formatter_expression(const std::string &input_expr, std::vector< std::string > &tag_names, std::vector< std::string > &sub_exprs)
GenericDatumFormatter< std::string, DataObject > name()
DataFormatterDictionary< DataObject > make_dictionary()
Template to can be specialized for constructing dictionaries for particular DataObject.
Iterator find(Iterator begin, Iterator end, const T &value, BinaryCompare q)
Equivalent to std::find(begin, end, value), but with custom comparison.
DataFormatterDictionary< DataObject > make_attribute_dictionary()
Dictionary of all AttributeFormatter (i.e. BaseValueFormatter<V, DataObject>)
jsonParser & to_json(const FormattedPrintable &_obj, jsonParser &json)
INDEX_TYPE Index
For long integer indexing:
void parse(InputParser< ConfigEnumOptions > &parser, std::string method_name, PrimClex const &primclex, DataFormatterDictionary< Configuration > const &dict)
DatumFormatterType formatter
notstd::cloneable_ptr< formatter > operator()(const formatter &value)
Shortcut for multidimensional vector (std::vector< std::vector< ...)