4 #include <boost/filesystem.hpp>
5 #include <boost/iterator/iterator_facade.hpp>
6 #include <boost/range/iterator_range.hpp>
21 inline std::string singleline_enum_help<DB::SELECTION_TYPE>() {
22 return standard_singleline_enum_help<DB::SELECTION_TYPE>(
34 template <
typename ValueType>
37 template <
typename ValueType>
40 template <
typename ObjType>
43 template <
typename ObjType,
typename BaseIterator>
45 :
public boost::iterator_facade<SelectionIterator<ObjType, BaseIterator>,
46 ObjType, std::bidirectional_iterator_tag,
47 const ObjType &, long> {
50 std::is_same<BaseIterator,
51 std::map<std::string, bool>::const_iterator>::value,
59 std::string
name()
const;
68 friend boost::iterator_core_access;
112 template <
typename ObjType>
121 typedef std::map<std::string, bool, Compare>
map_type;
157 const std::vector<std::string> &
col_headers()
const;
159 const std::string &
name()
const;
162 bool is_selected(
const std::string &name_or_alias)
const;
166 const std::string &criteria);
170 const std::string &criteria,
bool selected);
172 void read(std::istream &_input);
175 bool only_selected =
false)
const;
180 jsonParser &_json,
bool only_selected =
false)
const;
183 const fs::path &out_path,
bool write_json,
184 bool only_selected)
const;
#define ENUM_TRAITS(ENUM)
#define ENUM_IO_DECL(ENUM)
void set(const DataFormatterDictionary< ObjType > &dict, const std::string &criteria)
Set selected objects to value of criteria.
boost::iterator_range< iterator > selected()
void write(const DataFormatterDictionary< ObjType > &dict, const fs::path &out_path, bool write_json, bool only_selected) const
Write selection to file – will overwrite.
void print(const DataFormatterDictionary< ObjType > &_dict, std::ostream &_out, bool only_selected=false) const
Print csv selection to stream.
std::map< std::string, bool, Compare > map_type
Selection()
Default construct into invalid state.
Index selected_size() const
const PrimClex & primclex() const
bool is_selected(const std::string &name_or_alias) const
True if obj is in Selection and is selected; false otherwise.
const jsonParser & from_json(const jsonParser &_json)
Read selection from JSON.
SelectionIterator< ObjType, base_iterator > iterator
SelectionIterator< ObjType, base_const_iterator > const_iterator
boost::iterator_range< iterator > all()
jsonParser & to_json(const DataFormatterDictionary< ObjType > &_dict, jsonParser &_json, bool only_selected=false) const
Write selection to JSON.
map_type::iterator base_iterator
Database< ObjType > * m_db
std::vector< std::string > m_col_headers
const std::vector< std::string > & col_headers() const
map_type::const_iterator base_const_iterator
const PrimClex * m_primclex
const std::string & name() const
void read(std::istream &_input)
Read csv selection from stream.
Database< ObjType > & db() const
void decrement()
boost::iterator_facade implementation
std::string name() const
Name of object the iterator points at.
bool equal(const SelectionIterator &B) const
boost::iterator_facade implementation
bool_type & is_selected()
Reference to value 'is_selected'.
void increment()
boost::iterator_facade implementation
CASM_TMP::ConstSwitch< std::is_same< BaseIterator, std::map< std::string, bool >::const_iterator >::value, bool > bool_type
const ObjType & dereference() const
boost::iterator_facade implementation
SelectionIterator()
Default constructor (equals end)
const Selection< ObjType > * m_list
PrimClex is the top-level data structure for a CASM project.
std::string to_string(ENUM val)
Return string representation of enum class.
typename std::conditional< IsConst, const T, T >::type ConstSwitch
INDEX_TYPE Index
For long integer indexing:
bool operator()(std::string A, std::string B) const