Commit a12acaa5 by Maarten L. Hekkelman

moving from namespace cif::v2 to cif

parent ff62efe7
#include <iostream> #include <iostream>
#include <filesystem> #include <filesystem>
#include <cif++/Cif++.hpp> #include <cif++/cif.hpp>
namespace fs = std::filesystem; namespace fs = std::filesystem;
int main() int main()
{ {
fs::path in("1cbs.cif.gz"); cif::file file;
file.load_dictionary("mmcif_pdbx_v50");
cif::File file;
file.loadDictionary("mmcif_pdbx_v50");
file.load("1cbs.cif.gz"); file.load("1cbs.cif.gz");
auto& db = file.firstDatablock()["atom_site"]; auto& db = file.front();
auto n = db.find(cif::Key("label_atom_id") == "OXT").size(); auto &atom_site = db["atom_site"];
auto n = atom_site.find(cif::key("label_atom_id") == "OXT").size();
std::cout << "File contains " << db.size() << " atoms of which " << n << (n == 1 ? " is" : " are") << " OXT" << std::endl std::cout << "File contains " << atom_site.size() << " atoms of which " << n << (n == 1 ? " is" : " are") << " OXT" << std::endl
<< "residues with an OXT are:" << std::endl; << "residues with an OXT are:" << std::endl;
for (const auto& [asym, comp, seqnr]: db.find<std::string,std::string,int>( for (const auto& [asym, comp, seqnr]: atom_site.find<std::string,std::string,int>(
cif::Key("label_atom_id") == "OXT", "label_asym_id", "label_comp_id", "label_seq_id")) cif::key("label_atom_id") == "OXT", "label_asym_id", "label_comp_id", "label_seq_id"))
{ {
std::cout << asym << ' ' << comp << ' ' << seqnr << std::endl; std::cout << asym << ' ' << comp << ' ' << seqnr << std::endl;
} }
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
// https://en.cppreference.com/w/cpp/named_req/SequenceContainer // https://en.cppreference.com/w/cpp/named_req/SequenceContainer
// and more? // and more?
namespace cif::v2 namespace cif
{ {
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -660,4 +660,4 @@ class category ...@@ -660,4 +660,4 @@ class category
row *m_head = nullptr, *m_tail = nullptr; row *m_head = nullptr, *m_tail = nullptr;
}; };
} // namespace cif::v2 } // namespace cif
\ No newline at end of file \ No newline at end of file
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include <cif++/cif/row.hpp> #include <cif++/cif/row.hpp>
namespace cif::v2 namespace cif
{ {
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -612,4 +612,4 @@ namespace literals ...@@ -612,4 +612,4 @@ namespace literals
} }
} // namespace literals } // namespace literals
} // namespace cif::v2 } // namespace cif
\ No newline at end of file \ No newline at end of file
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include <cif++/cif/category.hpp> #include <cif++/cif/category.hpp>
namespace cif::v2 namespace cif
{ {
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -86,4 +86,4 @@ class datablock : public std::list<category> ...@@ -86,4 +86,4 @@ class datablock : public std::list<category>
const validator *m_validator = nullptr; const validator *m_validator = nullptr;
}; };
} // namespace cif::v2 } // namespace cif
\ No newline at end of file \ No newline at end of file
...@@ -28,9 +28,9 @@ ...@@ -28,9 +28,9 @@
#include <cif++/cif/validate.hpp> #include <cif++/cif/validate.hpp>
namespace cif::v2 namespace cif
{ {
validator parse_dictionary(std::string_view name, std::istream &is); validator parse_dictionary(std::string_view name, std::istream &is);
} // namespace cif::v2 } // namespace cif
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <cif++/cif/datablock.hpp> #include <cif++/cif/datablock.hpp>
#include <cif++/cif/parser.hpp> #include <cif++/cif/parser.hpp>
namespace cif::v2 namespace cif
{ {
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -83,4 +83,4 @@ class file : public std::list<datablock> ...@@ -83,4 +83,4 @@ class file : public std::list<datablock>
const validator *m_validator = nullptr; const validator *m_validator = nullptr;
}; };
} // namespace cif::v2 } // namespace cif
\ No newline at end of file \ No newline at end of file
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
namespace cif::v2 namespace cif
{ {
class category; class category;
...@@ -43,4 +43,4 @@ class row_handle; ...@@ -43,4 +43,4 @@ class row_handle;
class item; class item;
class item_handle; class item_handle;
} // namespace cif::v2 } // namespace cif
\ No newline at end of file \ No newline at end of file
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#include <cif++/cif/forward_decl.hpp> #include <cif++/cif/forward_decl.hpp>
namespace cif::v2 namespace cif
{ {
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -458,4 +458,4 @@ struct item_handle::item_value_as<T, std::enable_if_t<std::is_same_v<T, std::str ...@@ -458,4 +458,4 @@ struct item_handle::item_value_as<T, std::enable_if_t<std::is_same_v<T, std::str
} }
}; };
} // namespace cif::v2 } // namespace cif
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <cif++/cif/row.hpp> #include <cif++/cif/row.hpp>
namespace cif::v2 namespace cif
{ {
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -466,4 +466,4 @@ void conditional_iterator_proxy<Category, Ts...>::swap(conditional_iterator_prox ...@@ -466,4 +466,4 @@ void conditional_iterator_proxy<Category, Ts...>::swap(conditional_iterator_prox
std::swap(mCix, rhs.mCix); std::swap(mCix, rhs.mCix);
} }
} // namespace cif::v2 } // namespace cif
\ No newline at end of file \ No newline at end of file
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <memory> #include <memory>
namespace cif::v2 namespace cif
{ {
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -76,4 +76,4 @@ class list ...@@ -76,4 +76,4 @@ class list
}; };
} // namespace cif::v2 } // namespace cif
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <cif++/cif/row.hpp> #include <cif++/cif/row.hpp>
namespace cif::v2 namespace cif
{ {
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -284,4 +284,4 @@ class parser : public sac_parser ...@@ -284,4 +284,4 @@ class parser : public sac_parser
row_handle m_row; row_handle m_row;
}; };
} // namespace cif::v2 } // namespace cif
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <cif++/cif/item.hpp> #include <cif++/cif/item.hpp>
namespace cif::v2 namespace cif
{ {
namespace detail namespace detail
...@@ -266,4 +266,4 @@ class row_initializer ...@@ -266,4 +266,4 @@ class row_initializer
std::vector<item> m_items; std::vector<item> m_items;
}; };
} // namespace cif::v2 } // namespace cif
\ No newline at end of file \ No newline at end of file
...@@ -35,11 +35,10 @@ ...@@ -35,11 +35,10 @@
#include <cif++/utilities.hpp> #include <cif++/utilities.hpp>
namespace cif::v2 namespace cif
{ {
struct category_validator; struct category_validator;
class validator_factory;
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -68,7 +67,7 @@ struct type_validator ...@@ -68,7 +67,7 @@ struct type_validator
{ {
std::string m_name; std::string m_name;
DDL_PrimitiveType m_primitive_type; DDL_PrimitiveType m_primitive_type;
// std::regex mRx; // std::regex m_rx;
boost::regex m_rx; boost::regex m_rx;
bool operator<(const type_validator &rhs) const bool operator<(const type_validator &rhs) const
...@@ -218,4 +217,4 @@ class validator_factory ...@@ -218,4 +217,4 @@ class validator_factory
std::list<validator> m_validators; std::list<validator> m_validators;
}; };
} // namespace cif::v2 } // namespace cif
...@@ -130,8 +130,8 @@ class Compound ...@@ -130,8 +130,8 @@ class Compound
friend class CCDCompoundFactoryImpl; friend class CCDCompoundFactoryImpl;
friend class CCP4CompoundFactoryImpl; friend class CCP4CompoundFactoryImpl;
Compound(cif::v2::datablock &db); Compound(cif::datablock &db);
Compound(cif::v2::datablock &db, const std::string &id, const std::string &name, const std::string &type, const std::string &group); Compound(cif::datablock &db, const std::string &id, const std::string &name, const std::string &type, const std::string &group);
std::string mID; std::string mID;
std::string mName; std::string mName;
......
...@@ -63,7 +63,7 @@ class Atom ...@@ -63,7 +63,7 @@ class Atom
private: private:
struct AtomImpl : public std::enable_shared_from_this<AtomImpl> struct AtomImpl : public std::enable_shared_from_this<AtomImpl>
{ {
AtomImpl(cif::v2::datablock &db, const std::string &id, cif::v2::row_handle row); AtomImpl(cif::datablock &db, const std::string &id, cif::row_handle row);
// constructor for a symmetry copy of an atom // constructor for a symmetry copy of an atom
AtomImpl(const AtomImpl &impl, const Point &loc, const std::string &sym_op); AtomImpl(const AtomImpl &impl, const Point &loc, const std::string &sym_op);
...@@ -85,7 +85,7 @@ class Atom ...@@ -85,7 +85,7 @@ class Atom
const std::string get_property(const std::string_view name) const; const std::string get_property(const std::string_view name) const;
void set_property(const std::string_view name, const std::string &value); void set_property(const std::string_view name, const std::string &value);
const cif::v2::datablock &mDb; const cif::datablock &mDb;
std::string mID; std::string mID;
AtomType mType; AtomType mType;
...@@ -98,7 +98,7 @@ class Atom ...@@ -98,7 +98,7 @@ class Atom
Point mLocation; Point mLocation;
int mRefcount; int mRefcount;
cif::v2::row_handle mRow; cif::row_handle mRow;
// mutable std::vector<std::tuple<std::string, cif::detail::ItemReference>> mCachedRefs; // mutable std::vector<std::tuple<std::string, cif::detail::ItemReference>> mCachedRefs;
...@@ -123,7 +123,7 @@ class Atom ...@@ -123,7 +123,7 @@ class Atom
{ {
} }
Atom(cif::v2::datablock &db, cif::v2::row_handle &row); Atom(cif::datablock &db, cif::row_handle &row);
// a special constructor to create symmetry copies // a special constructor to create symmetry copies
Atom(const Atom &rhs, const Point &symmmetry_location, const std::string &symmetry_operation); Atom(const Atom &rhs, const Point &symmmetry_location, const std::string &symmetry_operation);
...@@ -180,8 +180,8 @@ class Atom ...@@ -180,8 +180,8 @@ class Atom
void translateRotateAndTranslate(Point t1, Quaternion q, Point t2); void translateRotateAndTranslate(Point t1, Quaternion q, Point t2);
// for direct access to underlying data, be careful! // for direct access to underlying data, be careful!
const cif::v2::row_handle getRow() const { return impl().mRow; } const cif::row_handle getRow() const { return impl().mRow; }
const cif::v2::row_handle getRowAniso() const; const cif::row_handle getRowAniso() const;
bool isSymmetryCopy() const { return impl().mSymmetryCopy; } bool isSymmetryCopy() const { return impl().mSymmetryCopy; }
std::string symmetry() const { return impl().mSymmetryOperator; } std::string symmetry() const { return impl().mSymmetryOperator; }
...@@ -513,7 +513,7 @@ class Polymer : public std::vector<Monomer> ...@@ -513,7 +513,7 @@ class Polymer : public std::vector<Monomer>
Structure *mStructure; Structure *mStructure;
std::string mEntityID; std::string mEntityID;
std::string mAsymID; std::string mAsymID;
// cif::v2::row_handleSet mPolySeq; // cif::row_handleSet mPolySeq;
}; };
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -578,7 +578,7 @@ class Branch : public std::vector<Sugar> ...@@ -578,7 +578,7 @@ class Branch : public std::vector<Sugar>
// file is a reference to the data stored in e.g. the cif file. // file is a reference to the data stored in e.g. the cif file.
// This object is not copyable. // This object is not copyable.
class File : public cif::v2::file class File : public cif::file
{ {
public: public:
File() {} File() {}
...@@ -599,10 +599,10 @@ class File : public cif::v2::file ...@@ -599,10 +599,10 @@ class File : public cif::v2::file
// void load(const std::filesystem::path &p) override; // void load(const std::filesystem::path &p) override;
// void save(const std::filesystem::path &p) override; // void save(const std::filesystem::path &p) override;
// using cif::v2::file::load; // using cif::file::load;
// using cif::v2::file::save; // using cif::file::save;
cif::v2::datablock &data() { return front(); } cif::datablock &data() { return front(); }
}; };
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -622,12 +622,12 @@ inline bool operator&(StructureOpenOptions a, StructureOpenOptions b) ...@@ -622,12 +622,12 @@ inline bool operator&(StructureOpenOptions a, StructureOpenOptions b)
class Structure class Structure
{ {
public: public:
Structure(cif::v2::file &p, size_t modelNr = 1, StructureOpenOptions options = {}) Structure(cif::file &p, size_t modelNr = 1, StructureOpenOptions options = {})
: Structure(p.front(), modelNr, options) : Structure(p.front(), modelNr, options)
{ {
} }
Structure(cif::v2::datablock &db, size_t modelNr = 1, StructureOpenOptions options = {}); Structure(cif::datablock &db, size_t modelNr = 1, StructureOpenOptions options = {});
Structure(Structure &&s) = default; Structure(Structure &&s) = default;
...@@ -756,12 +756,12 @@ class Structure ...@@ -756,12 +756,12 @@ class Structure
/// This method creates new atom records filled with info from the info. /// This method creates new atom records filled with info from the info.
/// ///
/// \param entity_id The entity ID of the new nonpoly /// \param entity_id The entity ID of the new nonpoly
/// \param atoms The array of sets of cif::v2::item data containing the data for the atoms. /// \param atoms The array of sets of cif::item data containing the data for the atoms.
/// \return The newly create asym ID /// \return The newly create asym ID
std::string createNonpoly(const std::string &entity_id, std::vector<std::vector<cif::v2::item>> &atom_info); std::string createNonpoly(const std::string &entity_id, std::vector<std::vector<cif::item>> &atom_info);
/// \brief Create a new (sugar) branch with one first NAG containing atoms constructed from \a nag_atom_info /// \brief Create a new (sugar) branch with one first NAG containing atoms constructed from \a nag_atom_info
Branch &createBranch(std::vector<std::vector<cif::v2::item>> &nag_atom_info); Branch &createBranch(std::vector<std::vector<cif::item>> &nag_atom_info);
/// \brief Extend an existing (sugar) branch identified by \a asymID with one sugar containing atoms constructed from \a atom_info /// \brief Extend an existing (sugar) branch identified by \a asymID with one sugar containing atoms constructed from \a atom_info
/// ///
...@@ -769,7 +769,7 @@ class Structure ...@@ -769,7 +769,7 @@ class Structure
/// \param atom_info Array containing the info for the atoms to construct for the new sugar /// \param atom_info Array containing the info for the atoms to construct for the new sugar
/// \param link_sugar The sugar to link to, note: this is the sugar number (1 based) /// \param link_sugar The sugar to link to, note: this is the sugar number (1 based)
/// \param link_atom The atom id of the atom linked in the sugar /// \param link_atom The atom id of the atom linked in the sugar
Branch &extendBranch(const std::string &asym_id, std::vector<std::vector<cif::v2::item>> &atom_info, Branch &extendBranch(const std::string &asym_id, std::vector<std::vector<cif::item>> &atom_info,
int link_sugar, const std::string &link_atom); int link_sugar, const std::string &link_atom);
/// \brief Remove \a branch /// \brief Remove \a branch
...@@ -797,12 +797,12 @@ class Structure ...@@ -797,12 +797,12 @@ class Structure
void cleanupEmptyCategories(); void cleanupEmptyCategories();
/// \brief Direct access to underlying data /// \brief Direct access to underlying data
cif::v2::category &category(std::string_view name) const cif::category &category(std::string_view name) const
{ {
return mDb[name]; return mDb[name];
} }
cif::v2::datablock &datablock() const cif::datablock &datablock() const
{ {
return mDb; return mDb;
} }
...@@ -832,7 +832,7 @@ class Structure ...@@ -832,7 +832,7 @@ class Structure
void removeAtom(Atom &a, bool removeFromResidue); void removeAtom(Atom &a, bool removeFromResidue);
void removeSugar(Sugar &sugar); void removeSugar(Sugar &sugar);
cif::v2::datablock &mDb; cif::datablock &mDb;
size_t mModelNr; size_t mModelNr;
AtomView mAtoms; AtomView mAtoms;
std::vector<size_t> mAtomIndex; std::vector<size_t> mAtomIndex;
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
// is inconsistent. It all depends whether a link is satified if a field taking part in the // is inconsistent. It all depends whether a link is satified if a field taking part in the
// set of linked items is null at one side and not null in the other. // set of linked items is null at one side and not null in the other.
namespace cif::v2 namespace cif
{ {
const uint32_t kMaxLineLength = 132; const uint32_t kMaxLineLength = 132;
...@@ -1119,7 +1119,7 @@ void category::erase_orphans(condition &&cond) ...@@ -1119,7 +1119,7 @@ void category::erase_orphans(condition &&cond)
std::string category::get_unique_id(std::function<std::string(int)> generator) std::string category::get_unique_id(std::function<std::string(int)> generator)
{ {
using namespace cif::v2::literals; using namespace cif::literals;
std::string id_tag = "id"; std::string id_tag = "id";
if (m_cat_validator != nullptr and m_cat_validator->m_keys.size() == 1) if (m_cat_validator != nullptr and m_cat_validator->m_keys.size() == 1)
...@@ -1875,4 +1875,4 @@ void category::write(std::ostream &os, const std::vector<uint16_t> &order, bool ...@@ -1875,4 +1875,4 @@ void category::write(std::ostream &os, const std::vector<uint16_t> &order, bool
os << "# " << '\n'; os << "# " << '\n';
} }
} // namespace cif::v2 } // namespace cif
\ No newline at end of file \ No newline at end of file
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include <cif++/cif/category.hpp> #include <cif++/cif/category.hpp>
#include <cif++/cif/condition.hpp> #include <cif++/cif/condition.hpp>
namespace cif::v2 namespace cif
{ {
iset get_category_fields(const category &cat) iset get_category_fields(const category &cat)
...@@ -58,4 +58,4 @@ bool is_column_type_uchar(const category &cat, std::string_view col) ...@@ -58,4 +58,4 @@ bool is_column_type_uchar(const category &cat, std::string_view col)
return result; return result;
} }
} // namespace cif::v2 } // namespace cif
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <cif++/cif/datablock.hpp> #include <cif++/cif/datablock.hpp>
namespace cif::v2 namespace cif
{ {
void datablock::set_validator(const validator *v) void datablock::set_validator(const validator *v)
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <cif++/cif/file.hpp> #include <cif++/cif/file.hpp>
#include <cif++/cif/parser.hpp> #include <cif++/cif/parser.hpp>
namespace cif::v2 namespace cif
{ {
using namespace literals; using namespace literals;
...@@ -194,7 +194,7 @@ class dictionary_parser : public parser ...@@ -194,7 +194,7 @@ class dictionary_parser : public parser
if (isCategorySaveFrame) if (isCategorySaveFrame)
{ {
std::string category; std::string category;
cif::v2::tie(category) = dict["category"].front().get("id"); cif::tie(category) = dict["category"].front().get("id");
std::vector<std::string> keys; std::vector<std::string> keys;
for (auto k : dict["category_key"]) for (auto k : dict["category_key"])
...@@ -210,7 +210,7 @@ class dictionary_parser : public parser ...@@ -210,7 +210,7 @@ class dictionary_parser : public parser
{ {
// if the type code is missing, this must be a pointer, just skip it // if the type code is missing, this must be a pointer, just skip it
std::string typeCode; std::string typeCode;
cif::v2::tie(typeCode) = dict["item_type"].front().get("code"); cif::tie(typeCode) = dict["item_type"].front().get("code");
const type_validator *tv = nullptr; const type_validator *tv = nullptr;
if (not(typeCode.empty() or typeCode == "?")) if (not(typeCode.empty() or typeCode == "?"))
...@@ -221,7 +221,7 @@ class dictionary_parser : public parser ...@@ -221,7 +221,7 @@ class dictionary_parser : public parser
ess.insert(e["value"].as<std::string>()); ess.insert(e["value"].as<std::string>());
std::string defaultValue; std::string defaultValue;
cif::v2::tie(defaultValue) = dict["item_default"].front().get("value"); cif::tie(defaultValue) = dict["item_default"].front().get("value");
bool defaultIsNull = false; bool defaultIsNull = false;
if (defaultValue.empty()) if (defaultValue.empty())
{ {
...@@ -238,7 +238,7 @@ class dictionary_parser : public parser ...@@ -238,7 +238,7 @@ class dictionary_parser : public parser
{ {
std::string tagName, category, mandatory; std::string tagName, category, mandatory;
cif::v2::tie(tagName, category, mandatory) = i.get("name", "category_id", "mandatory_code"); cif::tie(tagName, category, mandatory) = i.get("name", "category_id", "mandatory_code");
std::string catName, item_name; std::string catName, item_name;
std::tie(catName, item_name) = splitTagName(tagName); std::tie(catName, item_name) = splitTagName(tagName);
...@@ -297,7 +297,7 @@ class dictionary_parser : public parser ...@@ -297,7 +297,7 @@ class dictionary_parser : public parser
{ {
std::string childTagName, parentTagName; std::string childTagName, parentTagName;
cif::v2::tie(childTagName, parentTagName) = i.get("child_name", "parent_name"); cif::tie(childTagName, parentTagName) = i.get("child_name", "parent_name");
mLinkedItems.emplace(childTagName, parentTagName); mLinkedItems.emplace(childTagName, parentTagName);
} }
...@@ -347,7 +347,7 @@ class dictionary_parser : public parser ...@@ -347,7 +347,7 @@ class dictionary_parser : public parser
{ {
std::string child, parent; std::string child, parent;
int link_group_id; int link_group_id;
cif::v2::tie(child, parent, link_group_id) = gl.get("child_name", "parent_name", "link_group_id"); cif::tie(child, parent, link_group_id) = gl.get("child_name", "parent_name", "link_group_id");
auto civ = m_validator.get_validator_for_item(child); auto civ = m_validator.get_validator_for_item(child);
if (civ == nullptr) if (civ == nullptr)
...@@ -441,7 +441,7 @@ class dictionary_parser : public parser ...@@ -441,7 +441,7 @@ class dictionary_parser : public parser
for (auto t : dict["item_type_list"]) for (auto t : dict["item_type_list"])
{ {
std::string code, primitiveCode, construct; std::string code, primitiveCode, construct;
cif::v2::tie(code, primitiveCode, construct) = t.get("code", "primitive_code", "construct"); cif::tie(code, primitiveCode, construct) = t.get("code", "primitive_code", "construct");
replace_all(construct, "\\n", "\n"); replace_all(construct, "\\n", "\n");
replace_all(construct, "\\t", "\t"); replace_all(construct, "\\t", "\t");
...@@ -494,4 +494,4 @@ validator parse_dictionary(std::string_view name, std::istream &is) ...@@ -494,4 +494,4 @@ validator parse_dictionary(std::string_view name, std::istream &is)
return result; return result;
} }
} // namespace cif::v2 } // namespace cif
\ No newline at end of file \ No newline at end of file
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <cif++/cif/file.hpp> #include <cif++/cif/file.hpp>
namespace cif::v2 namespace cif
{ {
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -165,4 +165,4 @@ void file::save(std::ostream &os) const ...@@ -165,4 +165,4 @@ void file::save(std::ostream &os) const
db.write(os); db.write(os);
} }
} // namespace cif::v2 } // namespace cif
\ No newline at end of file \ No newline at end of file
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <cif++/cif/row.hpp> #include <cif++/cif/row.hpp>
namespace cif::v2 namespace cif
{ {
std::string_view item_handle::text() const std::string_view item_handle::text() const
......
...@@ -41,7 +41,7 @@ namespace cif ...@@ -41,7 +41,7 @@ namespace cif
extern int VERBOSE; extern int VERBOSE;
} }
namespace cif::v2 namespace cif
{ {
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -817,4 +817,4 @@ void parser::produce_item(const std::string &category, const std::string &item, ...@@ -817,4 +817,4 @@ void parser::produce_item(const std::string &category, const std::string &item,
m_row[item] = m_token_value; m_row[item] = m_token_value;
} }
} // namespace cif::v2 } // namespace cif
\ No newline at end of file \ No newline at end of file
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <cif++/cif/category.hpp> #include <cif++/cif/category.hpp>
namespace cif::v2 namespace cif
{ {
void row_handle::assign(size_t column, std::string_view value, bool updateLinked, bool validate) void row_handle::assign(size_t column, std::string_view value, bool updateLinked, bool validate)
...@@ -60,4 +60,4 @@ row_initializer::row_initializer(row_handle rh) ...@@ -60,4 +60,4 @@ row_initializer::row_initializer(row_handle rh)
m_items.emplace_back(cat.get_column_name(i->m_column_ix), i->text()); m_items.emplace_back(cat.get_column_name(i->m_column_ix), i->text());
} }
} // namespace cif::v2 } // namespace cif
\ No newline at end of file \ No newline at end of file
...@@ -40,7 +40,7 @@ namespace cif ...@@ -40,7 +40,7 @@ namespace cif
extern int VERBOSE; extern int VERBOSE;
} }
namespace cif::v2 namespace cif
{ {
using cif::VERBOSE; using cif::VERBOSE;
...@@ -430,4 +430,4 @@ void validator_factory::construct_validator(std::string_view name, std::istream ...@@ -430,4 +430,4 @@ void validator_factory::construct_validator(std::string_view name, std::istream
parse_dictionary(name, is); parse_dictionary(name, is);
} }
} // namespace cif::v2 } // namespace cif
...@@ -44,7 +44,7 @@ std::filesystem::path gTestDir = std::filesystem::current_path(); // filled in f ...@@ -44,7 +44,7 @@ std::filesystem::path gTestDir = std::filesystem::current_path(); // filled in f
// -------------------------------------------------------------------- // --------------------------------------------------------------------
cif::v2::file operator""_cf(const char *text, size_t length) cif::file operator""_cf(const char *text, size_t length)
{ {
struct membuf : public std::streambuf struct membuf : public std::streambuf
{ {
...@@ -55,7 +55,7 @@ cif::v2::file operator""_cf(const char *text, size_t length) ...@@ -55,7 +55,7 @@ cif::v2::file operator""_cf(const char *text, size_t length)
} buffer(const_cast<char *>(text), length); } buffer(const_cast<char *>(text), length);
std::istream is(&buffer); std::istream is(&buffer);
return cif::v2::file(is); return cif::file(is);
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -132,7 +132,7 @@ BOOST_AUTO_TEST_CASE(cc_2) ...@@ -132,7 +132,7 @@ BOOST_AUTO_TEST_CASE(cc_2)
BOOST_AUTO_TEST_CASE(item_1) BOOST_AUTO_TEST_CASE(item_1)
{ {
using namespace cif::v2; using namespace cif;
item i1("1", "1"); item i1("1", "1");
item i2("2", 2.0); item i2("2", 2.0);
...@@ -162,7 +162,7 @@ BOOST_AUTO_TEST_CASE(item_1) ...@@ -162,7 +162,7 @@ BOOST_AUTO_TEST_CASE(item_1)
BOOST_AUTO_TEST_CASE(r_1) BOOST_AUTO_TEST_CASE(r_1)
{ {
cif::v2::category c("foo"); cif::category c("foo");
c.emplace({ c.emplace({
{"f-1", 1}, {"f-1", 1},
{"f-2", "two"}, {"f-2", "two"},
...@@ -177,7 +177,7 @@ BOOST_AUTO_TEST_CASE(r_1) ...@@ -177,7 +177,7 @@ BOOST_AUTO_TEST_CASE(r_1)
BOOST_AUTO_TEST_CASE(r_2) BOOST_AUTO_TEST_CASE(r_2)
{ {
cif::v2::category c("foo"); cif::category c("foo");
for (size_t i = 1; i < 256; ++i) for (size_t i = 1; i < 256; ++i)
{ {
...@@ -188,7 +188,7 @@ BOOST_AUTO_TEST_CASE(r_2) ...@@ -188,7 +188,7 @@ BOOST_AUTO_TEST_CASE(r_2)
BOOST_AUTO_TEST_CASE(c_1) BOOST_AUTO_TEST_CASE(c_1)
{ {
cif::v2::category c("foo"); cif::category c("foo");
c.emplace({{"id", 1}, {"s", "aap"}}); c.emplace({{"id", 1}, {"s", "aap"}});
c.emplace({{"id", 2}, {"s", "noot"}}); c.emplace({{"id", 2}, {"s", "noot"}});
...@@ -212,7 +212,7 @@ BOOST_AUTO_TEST_CASE(c_1) ...@@ -212,7 +212,7 @@ BOOST_AUTO_TEST_CASE(c_1)
int i; int i;
std::string s; std::string s;
cif::v2::tie(i, s) = r.get("id", "s"); cif::tie(i, s) = r.get("id", "s");
BOOST_CHECK_EQUAL(i, n); BOOST_CHECK_EQUAL(i, n);
BOOST_CHECK_EQUAL(s.compare(ts[n - 1]), 0); BOOST_CHECK_EQUAL(s.compare(ts[n - 1]), 0);
...@@ -237,7 +237,7 @@ BOOST_AUTO_TEST_CASE(c_2) ...@@ -237,7 +237,7 @@ BOOST_AUTO_TEST_CASE(c_2)
{3, "mies"} {3, "mies"}
}; };
cif::v2::category c("foo"); cif::category c("foo");
for (const auto &[id, s] : D) for (const auto &[id, s] : D)
c.emplace({ {"id", id}, { "s", s} }); c.emplace({ {"id", id}, { "s", s} });
...@@ -245,12 +245,12 @@ BOOST_AUTO_TEST_CASE(c_2) ...@@ -245,12 +245,12 @@ BOOST_AUTO_TEST_CASE(c_2)
BOOST_CHECK(not c.empty()); BOOST_CHECK(not c.empty());
BOOST_CHECK_EQUAL(c.size(), 3); BOOST_CHECK_EQUAL(c.size(), 3);
cif::v2::category c2(c); cif::category c2(c);
BOOST_CHECK(not c2.empty()); BOOST_CHECK(not c2.empty());
BOOST_CHECK_EQUAL(c2.size(), 3); BOOST_CHECK_EQUAL(c2.size(), 3);
cif::v2::category c3(std::move(c)); cif::category c3(std::move(c));
BOOST_CHECK(not c3.empty()); BOOST_CHECK(not c3.empty());
BOOST_CHECK_EQUAL(c3.size(), 3); BOOST_CHECK_EQUAL(c3.size(), 3);
...@@ -277,12 +277,12 @@ BOOST_AUTO_TEST_CASE(c_3) ...@@ -277,12 +277,12 @@ BOOST_AUTO_TEST_CASE(c_3)
{3, "mies"} {3, "mies"}
}; };
cif::v2::category c("foo"); cif::category c("foo");
for (const auto &[id, s] : D) for (const auto &[id, s] : D)
c.emplace({ {"id", id}, { "s", s} }); c.emplace({ {"id", id}, { "s", s} });
cif::v2::category c2("bar"); cif::category c2("bar");
for (auto r : c) for (auto r : c)
c2.emplace(r); c2.emplace(r);
...@@ -292,18 +292,18 @@ BOOST_AUTO_TEST_CASE(c_3) ...@@ -292,18 +292,18 @@ BOOST_AUTO_TEST_CASE(c_3)
BOOST_AUTO_TEST_CASE(ci_1) BOOST_AUTO_TEST_CASE(ci_1)
{ {
cif::v2::category c("foo"); cif::category c("foo");
c.emplace({{"id", 1}, {"s", "aap"}}); c.emplace({{"id", 1}, {"s", "aap"}});
c.emplace({{"id", 2}, {"s", "noot"}}); c.emplace({{"id", 2}, {"s", "noot"}});
c.emplace({{"id", 3}, {"s", "mies"}}); c.emplace({{"id", 3}, {"s", "mies"}});
cif::v2::category::iterator i1 = c.begin(); cif::category::iterator i1 = c.begin();
cif::v2::category::const_iterator i2 = c.cbegin(); cif::category::const_iterator i2 = c.cbegin();
cif::v2::category::const_iterator i3 = c.begin(); cif::category::const_iterator i3 = c.begin();
cif::v2::category::const_iterator i4 = i2; cif::category::const_iterator i4 = i2;
cif::v2::category::const_iterator i5 = i1; cif::category::const_iterator i5 = i1;
BOOST_CHECK(i1 == i2); BOOST_CHECK(i1 == i2);
BOOST_CHECK(i1 == i3); BOOST_CHECK(i1 == i3);
...@@ -348,7 +348,7 @@ _test.name ...@@ -348,7 +348,7 @@ _test.name
++n; ++n;
} }
auto n2 = test.erase(cif::v2::key("id") == 1, [](cif::v2::row_handle r) auto n2 = test.erase(cif::key("id") == 1, [](cif::row_handle r)
{ {
BOOST_CHECK_EQUAL(r["id"].as<int>(), 1); BOOST_CHECK_EQUAL(r["id"].as<int>(), 1);
BOOST_CHECK_EQUAL(r["name"].as<std::string>(), "aap"); }); BOOST_CHECK_EQUAL(r["name"].as<std::string>(), "aap"); });
...@@ -387,7 +387,7 @@ _test.value ...@@ -387,7 +387,7 @@ _test.value
BOOST_CHECK_EQUAL(test.size(), 3); BOOST_CHECK_EQUAL(test.size(), 3);
int n = 0; int n = 0;
for (auto r : test.find(cif::v2::key("name") == "aap")) for (auto r : test.find(cif::key("name") == "aap"))
{ {
BOOST_CHECK_EQUAL(++n, 1); BOOST_CHECK_EQUAL(++n, 1);
BOOST_CHECK_EQUAL(r["id"].as<int>(), 1); BOOST_CHECK_EQUAL(r["id"].as<int>(), 1);
...@@ -395,18 +395,18 @@ _test.value ...@@ -395,18 +395,18 @@ _test.value
BOOST_CHECK_EQUAL(r["value"].as<float>(), 1.0); BOOST_CHECK_EQUAL(r["value"].as<float>(), 1.0);
} }
auto t = test.find(cif::v2::key("id") == 1); auto t = test.find(cif::key("id") == 1);
BOOST_CHECK(not t.empty()); BOOST_CHECK(not t.empty());
BOOST_CHECK_EQUAL(t.front()["name"].as<std::string>(), "aap"); BOOST_CHECK_EQUAL(t.front()["name"].as<std::string>(), "aap");
auto t2 = test.find(cif::v2::key("value") == 1.2); auto t2 = test.find(cif::key("value") == 1.2);
BOOST_CHECK(not t2.empty()); BOOST_CHECK(not t2.empty());
BOOST_CHECK_EQUAL(t2.front()["name"].as<std::string>(), "mies"); BOOST_CHECK_EQUAL(t2.front()["name"].as<std::string>(), "mies");
} }
BOOST_AUTO_TEST_CASE(ut3) BOOST_AUTO_TEST_CASE(ut3)
{ {
using namespace cif::v2::literals; using namespace cif::literals;
auto f = R"(data_TEST auto f = R"(data_TEST
# #
...@@ -428,8 +428,8 @@ _test.value ...@@ -428,8 +428,8 @@ _test.value
auto &test = db["test"]; auto &test = db["test"];
BOOST_CHECK_EQUAL(test.size(), 5); BOOST_CHECK_EQUAL(test.size(), 5);
BOOST_CHECK(test.exists("value"_key == cif::v2::null)); BOOST_CHECK(test.exists("value"_key == cif::null));
BOOST_CHECK_EQUAL(test.find("value"_key == cif::v2::null).size(), 2); BOOST_CHECK_EQUAL(test.find("value"_key == cif::null).size(), 2);
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -539,9 +539,9 @@ save__cat_2.desc ...@@ -539,9 +539,9 @@ save__cat_2.desc
std::istream is_dict(&buffer); std::istream is_dict(&buffer);
auto validator = cif::v2::parse_dictionary("test", is_dict); auto validator = cif::parse_dictionary("test", is_dict);
cif::v2::file f; cif::file f;
f.set_validator(&validator); f.set_validator(&validator);
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -581,7 +581,7 @@ _cat_2.desc ...@@ -581,7 +581,7 @@ _cat_2.desc
BOOST_CHECK_EQUAL(cat1.size(), 3); BOOST_CHECK_EQUAL(cat1.size(), 3);
BOOST_CHECK_EQUAL(cat2.size(), 3); BOOST_CHECK_EQUAL(cat2.size(), 3);
cat1.erase(cif::v2::key("id") == 1); cat1.erase(cif::key("id") == 1);
BOOST_CHECK_EQUAL(cat1.size(), 2); BOOST_CHECK_EQUAL(cat1.size(), 2);
BOOST_CHECK_EQUAL(cat2.size(), 1); BOOST_CHECK_EQUAL(cat2.size(), 1);
...@@ -669,9 +669,9 @@ save__cat_1.c ...@@ -669,9 +669,9 @@ save__cat_1.c
std::istream is_dict(&buffer); std::istream is_dict(&buffer);
auto validator = cif::v2::parse_dictionary("test", is_dict); auto validator = cif::parse_dictionary("test", is_dict);
cif::v2::file f; cif::file f;
f.set_validator(&validator); f.set_validator(&validator);
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -701,11 +701,11 @@ mies Mies ...@@ -701,11 +701,11 @@ mies Mies
BOOST_CHECK_EQUAL(cat1.size(), 3); BOOST_CHECK_EQUAL(cat1.size(), 3);
cat1.erase(cif::v2::key("id") == "AAP"); cat1.erase(cif::key("id") == "AAP");
BOOST_CHECK_EQUAL(cat1.size(), 3); BOOST_CHECK_EQUAL(cat1.size(), 3);
cat1.erase(cif::v2::key("id") == "noot"); cat1.erase(cif::key("id") == "noot");
BOOST_CHECK_EQUAL(cat1.size(), 2); BOOST_CHECK_EQUAL(cat1.size(), 2);
...@@ -715,7 +715,7 @@ mies Mies ...@@ -715,7 +715,7 @@ mies Mies
{"c", "2e-aap"} {"c", "2e-aap"}
}), std::exception); }), std::exception);
cat1.erase(cif::v2::key("id") == "aap"); cat1.erase(cif::key("id") == "aap");
BOOST_CHECK_EQUAL(cat1.size(), 1); BOOST_CHECK_EQUAL(cat1.size(), 1);
...@@ -834,9 +834,9 @@ save__cat_2.desc ...@@ -834,9 +834,9 @@ save__cat_2.desc
std::istream is_dict(&buffer); std::istream is_dict(&buffer);
auto validator = cif::v2::parse_dictionary("test", is_dict); auto validator = cif::parse_dictionary("test", is_dict);
cif::v2::file f; cif::file f;
f.set_validator(&validator); f.set_validator(&validator);
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -878,7 +878,7 @@ _cat_2.desc ...@@ -878,7 +878,7 @@ _cat_2.desc
// check a rename in parent and child // check a rename in parent and child
for (auto r : cat1.find(cif::v2::key("id") == 1)) for (auto r : cat1.find(cif::key("id") == 1))
{ {
r["id"] = 10; r["id"] = 10;
break; break;
...@@ -887,15 +887,15 @@ _cat_2.desc ...@@ -887,15 +887,15 @@ _cat_2.desc
BOOST_CHECK_EQUAL(cat1.size(), 3); BOOST_CHECK_EQUAL(cat1.size(), 3);
BOOST_CHECK_EQUAL(cat2.size(), 4); BOOST_CHECK_EQUAL(cat2.size(), 4);
BOOST_CHECK_EQUAL(cat1.find(cif::v2::key("id") == 1).size(), 0); BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 1).size(), 0);
BOOST_CHECK_EQUAL(cat1.find(cif::v2::key("id") == 10).size(), 1); BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 10).size(), 1);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id") == 1).size(), 0); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 1).size(), 0);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id") == 10).size(), 2); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 10).size(), 2);
// check a rename in parent and child, this time only one child should be renamed // check a rename in parent and child, this time only one child should be renamed
for (auto r : cat1.find(cif::v2::key("id") == 2)) for (auto r : cat1.find(cif::key("id") == 2))
{ {
r["id"] = 20; r["id"] = 20;
break; break;
...@@ -904,25 +904,25 @@ _cat_2.desc ...@@ -904,25 +904,25 @@ _cat_2.desc
BOOST_CHECK_EQUAL(cat1.size(), 3); BOOST_CHECK_EQUAL(cat1.size(), 3);
BOOST_CHECK_EQUAL(cat2.size(), 4); BOOST_CHECK_EQUAL(cat2.size(), 4);
BOOST_CHECK_EQUAL(cat1.find(cif::v2::key("id") == 2).size(), 0); BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 2).size(), 0);
BOOST_CHECK_EQUAL(cat1.find(cif::v2::key("id") == 20).size(), 1); BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 20).size(), 1);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id") == 2).size(), 1); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 2).size(), 1);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id") == 20).size(), 1); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 20).size(), 1);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id") == 2 and cif::v2::key("name2") == "noot").size(), 0); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 2 and cif::key("name2") == "noot").size(), 0);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id") == 2 and cif::v2::key("name2") == "n2").size(), 1); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 2 and cif::key("name2") == "n2").size(), 1);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id") == 20 and cif::v2::key("name2") == "noot").size(), 1); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 20 and cif::key("name2") == "noot").size(), 1);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id") == 20 and cif::v2::key("name2") == "n2").size(), 0); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 20 and cif::key("name2") == "n2").size(), 0);
// -------------------------------------------------------------------- // --------------------------------------------------------------------
cat1.erase(cif::v2::key("id") == 10); cat1.erase(cif::key("id") == 10);
BOOST_CHECK_EQUAL(cat1.size(), 2); BOOST_CHECK_EQUAL(cat1.size(), 2);
BOOST_CHECK_EQUAL(cat2.size(), 2); BOOST_CHECK_EQUAL(cat2.size(), 2);
cat1.erase(cif::v2::key("id") == 20); cat1.erase(cif::key("id") == 20);
BOOST_CHECK_EQUAL(cat1.size(), 1); BOOST_CHECK_EQUAL(cat1.size(), 1);
BOOST_CHECK_EQUAL(cat2.size(), 1); BOOST_CHECK_EQUAL(cat2.size(), 1);
...@@ -1037,9 +1037,9 @@ save__cat_2.parent_id3 ...@@ -1037,9 +1037,9 @@ save__cat_2.parent_id3
std::istream is_dict(&buffer); std::istream is_dict(&buffer);
auto validator = cif::v2::parse_dictionary("test", is_dict); auto validator = cif::parse_dictionary("test", is_dict);
cif::v2::file f; cif::file f;
f.set_validator(&validator); f.set_validator(&validator);
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -1091,7 +1091,7 @@ _cat_2.parent_id3 ...@@ -1091,7 +1091,7 @@ _cat_2.parent_id3
// check a rename in parent and child // check a rename in parent and child
for (auto r : cat1.find(cif::v2::key("id") == 1)) for (auto r : cat1.find(cif::key("id") == 1))
{ {
r["id"] = 10; r["id"] = 10;
break; break;
...@@ -1100,13 +1100,13 @@ _cat_2.parent_id3 ...@@ -1100,13 +1100,13 @@ _cat_2.parent_id3
BOOST_CHECK_EQUAL(cat1.size(), 4); BOOST_CHECK_EQUAL(cat1.size(), 4);
BOOST_CHECK_EQUAL(cat2.size(), 13); BOOST_CHECK_EQUAL(cat2.size(), 13);
BOOST_CHECK_EQUAL(cat1.find(cif::v2::key("id") == 1).size(), 0); BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 1).size(), 0);
BOOST_CHECK_EQUAL(cat1.find(cif::v2::key("id") == 10).size(), 1); BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 10).size(), 1);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id") == 1).size(), 1); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 1).size(), 1);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id") == 10).size(), 2); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 10).size(), 2);
for (auto r : cat1.find(cif::v2::key("id") == 2)) for (auto r : cat1.find(cif::key("id") == 2))
{ {
r["id"] = 20; r["id"] = 20;
break; break;
...@@ -1115,13 +1115,13 @@ _cat_2.parent_id3 ...@@ -1115,13 +1115,13 @@ _cat_2.parent_id3
BOOST_CHECK_EQUAL(cat1.size(), 4); BOOST_CHECK_EQUAL(cat1.size(), 4);
BOOST_CHECK_EQUAL(cat2.size(), 13); BOOST_CHECK_EQUAL(cat2.size(), 13);
BOOST_CHECK_EQUAL(cat1.find(cif::v2::key("id") == 2).size(), 0); BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 2).size(), 0);
BOOST_CHECK_EQUAL(cat1.find(cif::v2::key("id") == 20).size(), 1); BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 20).size(), 1);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id") == 2).size(), 2); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 2).size(), 2);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id") == 20).size(), 2); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 20).size(), 2);
for (auto r : cat1.find(cif::v2::key("id") == 3)) for (auto r : cat1.find(cif::key("id") == 3))
{ {
r["id"] = 30; r["id"] = 30;
break; break;
...@@ -1130,13 +1130,13 @@ _cat_2.parent_id3 ...@@ -1130,13 +1130,13 @@ _cat_2.parent_id3
BOOST_CHECK_EQUAL(cat1.size(), 4); BOOST_CHECK_EQUAL(cat1.size(), 4);
BOOST_CHECK_EQUAL(cat2.size(), 13); BOOST_CHECK_EQUAL(cat2.size(), 13);
BOOST_CHECK_EQUAL(cat1.find(cif::v2::key("id") == 3).size(), 0); BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 3).size(), 0);
BOOST_CHECK_EQUAL(cat1.find(cif::v2::key("id") == 30).size(), 1); BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 30).size(), 1);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id") == 3).size(), 2); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 3).size(), 2);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id") == 30).size(), 1); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 30).size(), 1);
for (auto r : cat1.find(cif::v2::key("id") == 4)) for (auto r : cat1.find(cif::key("id") == 4))
{ {
r["id"] = 40; r["id"] = 40;
break; break;
...@@ -1145,11 +1145,11 @@ _cat_2.parent_id3 ...@@ -1145,11 +1145,11 @@ _cat_2.parent_id3
BOOST_CHECK_EQUAL(cat1.size(), 4); BOOST_CHECK_EQUAL(cat1.size(), 4);
BOOST_CHECK_EQUAL(cat2.size(), 13); BOOST_CHECK_EQUAL(cat2.size(), 13);
BOOST_CHECK_EQUAL(cat1.find(cif::v2::key("id") == 4).size(), 0); BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 4).size(), 0);
BOOST_CHECK_EQUAL(cat1.find(cif::v2::key("id") == 10).size(), 1); BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 10).size(), 1);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id") == 4).size(), 3); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 4).size(), 3);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id") == 40).size(), 0); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 40).size(), 0);
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -1258,9 +1258,9 @@ cat_2 3 cat_2:cat_1:3 ...@@ -1258,9 +1258,9 @@ cat_2 3 cat_2:cat_1:3
std::istream is_dict(&buffer); std::istream is_dict(&buffer);
auto validator = cif::v2::parse_dictionary("test", is_dict); auto validator = cif::parse_dictionary("test", is_dict);
cif::v2::file f; cif::file f;
f.set_validator(&validator); f.set_validator(&validator);
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -1306,7 +1306,7 @@ _cat_2.parent_id3 ...@@ -1306,7 +1306,7 @@ _cat_2.parent_id3
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// check iterate children // check iterate children
auto PR2set = cat1.find(cif::v2::key("id") == 2); auto PR2set = cat1.find(cif::key("id") == 2);
BOOST_ASSERT(PR2set.size() == 1); BOOST_ASSERT(PR2set.size() == 1);
auto PR2 = PR2set.front(); auto PR2 = PR2set.front();
BOOST_CHECK_EQUAL(PR2["id"].as<int>(), 2); BOOST_CHECK_EQUAL(PR2["id"].as<int>(), 2);
...@@ -1315,14 +1315,14 @@ _cat_2.parent_id3 ...@@ -1315,14 +1315,14 @@ _cat_2.parent_id3
BOOST_ASSERT(CR2set.size() == 3); BOOST_ASSERT(CR2set.size() == 3);
std::vector<int> CRids; std::vector<int> CRids;
std::transform(CR2set.begin(), CR2set.end(), std::back_inserter(CRids), [](cif::v2::row_handle r) std::transform(CR2set.begin(), CR2set.end(), std::back_inserter(CRids), [](cif::row_handle r)
{ return r["id"].as<int>(); }); { return r["id"].as<int>(); });
std::sort(CRids.begin(), CRids.end()); std::sort(CRids.begin(), CRids.end());
BOOST_CHECK(CRids == std::vector<int>({4, 5, 6})); BOOST_CHECK(CRids == std::vector<int>({4, 5, 6}));
// check a rename in parent and child // check a rename in parent and child
for (auto r : cat1.find(cif::v2::key("id") == 1)) for (auto r : cat1.find(cif::key("id") == 1))
{ {
r["id"] = 10; r["id"] = 10;
break; break;
...@@ -1331,17 +1331,17 @@ _cat_2.parent_id3 ...@@ -1331,17 +1331,17 @@ _cat_2.parent_id3
BOOST_CHECK_EQUAL(cat1.size(), 3); BOOST_CHECK_EQUAL(cat1.size(), 3);
BOOST_CHECK_EQUAL(cat2.size(), 7); BOOST_CHECK_EQUAL(cat2.size(), 7);
BOOST_CHECK_EQUAL(cat1.find(cif::v2::key("id") == 1).size(), 0); BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 1).size(), 0);
BOOST_CHECK_EQUAL(cat1.find(cif::v2::key("id") == 10).size(), 1); BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 10).size(), 1);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id") == 1).size(), 0); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 1).size(), 0);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id2") == 1).size(), 0); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id2") == 1).size(), 0);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id3") == 1).size(), 0); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id3") == 1).size(), 0);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id") == 10).size(), 1); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 10).size(), 1);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id2") == 10).size(), 1); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id2") == 10).size(), 1);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id3") == 10).size(), 1); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id3") == 10).size(), 1);
for (auto r : cat1.find(cif::v2::key("id") == 2)) for (auto r : cat1.find(cif::key("id") == 2))
{ {
r["id"] = 20; r["id"] = 20;
break; break;
...@@ -1350,17 +1350,17 @@ _cat_2.parent_id3 ...@@ -1350,17 +1350,17 @@ _cat_2.parent_id3
BOOST_CHECK_EQUAL(cat1.size(), 3); BOOST_CHECK_EQUAL(cat1.size(), 3);
BOOST_CHECK_EQUAL(cat2.size(), 7); BOOST_CHECK_EQUAL(cat2.size(), 7);
BOOST_CHECK_EQUAL(cat1.find(cif::v2::key("id") == 2).size(), 0); BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 2).size(), 0);
BOOST_CHECK_EQUAL(cat1.find(cif::v2::key("id") == 20).size(), 1); BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 20).size(), 1);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id") == 2).size(), 0); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 2).size(), 0);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id2") == 2).size(), 0); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id2") == 2).size(), 0);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id3") == 2).size(), 0); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id3") == 2).size(), 0);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id") == 20).size(), 2); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 20).size(), 2);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id2") == 20).size(), 2); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id2") == 20).size(), 2);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id3") == 20).size(), 2); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id3") == 20).size(), 2);
for (auto r : cat1.find(cif::v2::key("id") == 3)) for (auto r : cat1.find(cif::key("id") == 3))
{ {
r["id"] = 30; r["id"] = 30;
break; break;
...@@ -1369,27 +1369,27 @@ _cat_2.parent_id3 ...@@ -1369,27 +1369,27 @@ _cat_2.parent_id3
BOOST_CHECK_EQUAL(cat1.size(), 3); BOOST_CHECK_EQUAL(cat1.size(), 3);
BOOST_CHECK_EQUAL(cat2.size(), 7); BOOST_CHECK_EQUAL(cat2.size(), 7);
BOOST_CHECK_EQUAL(cat1.find(cif::v2::key("id") == 3).size(), 0); BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 3).size(), 0);
BOOST_CHECK_EQUAL(cat1.find(cif::v2::key("id") == 30).size(), 1); BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 30).size(), 1);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id") == 3).size(), 0); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 3).size(), 0);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id2") == 3).size(), 0); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id2") == 3).size(), 0);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id3") == 3).size(), 0); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id3") == 3).size(), 0);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id") == 30).size(), 1); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 30).size(), 1);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id2") == 30).size(), 1); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id2") == 30).size(), 1);
BOOST_CHECK_EQUAL(cat2.find(cif::v2::key("parent_id3") == 30).size(), 1); BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id3") == 30).size(), 1);
// test delete // test delete
cat1.erase(cif::v2::key("id") == 10); cat1.erase(cif::key("id") == 10);
BOOST_CHECK_EQUAL(cat1.size(), 2); BOOST_CHECK_EQUAL(cat1.size(), 2);
BOOST_CHECK_EQUAL(cat2.size(), 4); BOOST_CHECK_EQUAL(cat2.size(), 4);
cat1.erase(cif::v2::key("id") == 20); cat1.erase(cif::key("id") == 20);
BOOST_CHECK_EQUAL(cat1.size(), 1); BOOST_CHECK_EQUAL(cat1.size(), 1);
BOOST_CHECK_EQUAL(cat2.size(), 1); BOOST_CHECK_EQUAL(cat2.size(), 1);
cat1.erase(cif::v2::key("id") == 30); cat1.erase(cif::key("id") == 30);
BOOST_CHECK_EQUAL(cat1.size(), 0); BOOST_CHECK_EQUAL(cat1.size(), 0);
BOOST_CHECK_EQUAL(cat2.size(), 0); BOOST_CHECK_EQUAL(cat2.size(), 0);
} }
...@@ -1414,21 +1414,21 @@ _test.name ...@@ -1414,21 +1414,21 @@ _test.name
auto &db = f.front(); auto &db = f.front();
for (auto r : db["test"].find(cif::v2::key("id") == 1)) for (auto r : db["test"].find(cif::key("id") == 1))
{ {
const auto &[id, name] = r.get<int, std::string>({"id", "name"}); const auto &[id, name] = r.get<int, std::string>({"id", "name"});
BOOST_CHECK_EQUAL(id, 1); BOOST_CHECK_EQUAL(id, 1);
BOOST_CHECK_EQUAL(name, "aap"); BOOST_CHECK_EQUAL(name, "aap");
} }
for (auto r : db["test"].find(cif::v2::key("id") == 4)) for (auto r : db["test"].find(cif::key("id") == 4))
{ {
const auto &[id, name] = r.get<int, std::string>({"id", "name"}); const auto &[id, name] = r.get<int, std::string>({"id", "name"});
BOOST_CHECK_EQUAL(id, 4); BOOST_CHECK_EQUAL(id, 4);
BOOST_CHECK(name.empty()); BOOST_CHECK(name.empty());
} }
for (auto r : db["test"].find(cif::v2::key("id") == 5)) for (auto r : db["test"].find(cif::key("id") == 5))
{ {
const auto &[id, name] = r.get<int, std::string>({"id", "name"}); const auto &[id, name] = r.get<int, std::string>({"id", "name"});
BOOST_CHECK_EQUAL(id, 5); BOOST_CHECK_EQUAL(id, 5);
...@@ -1507,7 +1507,7 @@ _test.name ...@@ -1507,7 +1507,7 @@ _test.name
auto &db = f.front(); auto &db = f.front();
// query tests // query tests
for (const auto &[id, name] : db["test"].find<int, std::optional<std::string>>(cif::v2::all(), "id", "name")) for (const auto &[id, name] : db["test"].find<int, std::optional<std::string>>(cif::all(), "id", "name"))
{ {
switch (id) switch (id)
{ {
...@@ -1521,7 +1521,7 @@ _test.name ...@@ -1521,7 +1521,7 @@ _test.name
} }
} }
const auto &[id, name] = db["test"].find1<int, std::string>(cif::v2::key("id") == 1, "id", "name"); const auto &[id, name] = db["test"].find1<int, std::string>(cif::key("id") == 1, "id", "name");
BOOST_CHECK_EQUAL(id, 1); BOOST_CHECK_EQUAL(id, 1);
BOOST_CHECK_EQUAL(name, "aap"); BOOST_CHECK_EQUAL(name, "aap");
...@@ -1687,9 +1687,9 @@ cat_2 1 '_cat_2.num' '_cat_3.num' cat_3 ...@@ -1687,9 +1687,9 @@ cat_2 1 '_cat_2.num' '_cat_3.num' cat_3
std::istream is_dict(&buffer); std::istream is_dict(&buffer);
auto validator = cif::v2::parse_dictionary("test", is_dict); auto validator = cif::parse_dictionary("test", is_dict);
cif::v2::file f; cif::file f;
f.set_validator(&validator); f.set_validator(&validator);
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -1721,7 +1721,7 @@ _cat_3.num ...@@ -1721,7 +1721,7 @@ _cat_3.num
2 aap 2 2 aap 2
)"; )";
using namespace cif::v2::literals; using namespace cif::literals;
struct data_membuf : public std::streambuf struct data_membuf : public std::streambuf
{ {
...@@ -1745,12 +1745,12 @@ _cat_3.num ...@@ -1745,12 +1745,12 @@ _cat_3.num
{ {
int id, num; int id, num;
std::string name; std::string name;
cif::v2::tie(id, name, num) = cat3.front().get("id", "name", "num"); cif::tie(id, name, num) = cat3.front().get("id", "name", "num");
BOOST_CHECK_EQUAL(id, 1); BOOST_CHECK_EQUAL(id, 1);
BOOST_CHECK_EQUAL(num, 1); BOOST_CHECK_EQUAL(num, 1);
BOOST_CHECK_EQUAL(name, "aapje"); BOOST_CHECK_EQUAL(name, "aapje");
cif::v2::tie(id, name, num) = cat3.back().get("id", "name", "num"); cif::tie(id, name, num) = cat3.back().get("id", "name", "num");
BOOST_CHECK_EQUAL(id, 2); BOOST_CHECK_EQUAL(id, 2);
BOOST_CHECK_EQUAL(num, 2); BOOST_CHECK_EQUAL(num, 2);
BOOST_CHECK_EQUAL(name, "aap"); BOOST_CHECK_EQUAL(name, "aap");
...@@ -1997,7 +1997,7 @@ BOOST_AUTO_TEST_CASE(reading_file_1) ...@@ -1997,7 +1997,7 @@ BOOST_AUTO_TEST_CASE(reading_file_1)
{ {
std::istringstream is("Hello, world!"); std::istringstream is("Hello, world!");
cif::v2::file file; cif::file file;
BOOST_CHECK_THROW(file.load(is), std::runtime_error); BOOST_CHECK_THROW(file.load(is), std::runtime_error);
} }
...@@ -2022,7 +2022,7 @@ _test.text ?? ...@@ -2022,7 +2022,7 @@ _test.text ??
std::stringstream ss; std::stringstream ss;
data1.save(ss); data1.save(ss);
auto data2 = cif::v2::file(ss); auto data2 = cif::file(ss);
auto &db2 = data2.front(); auto &db2 = data2.front();
auto &test2 = db2["test"]; auto &test2 = db2["test"];
...@@ -2070,14 +2070,14 @@ boo.data_.whatever ...@@ -2070,14 +2070,14 @@ boo.data_.whatever
{ {
const auto &[text] = r.get<std::string>({"text"}); const auto &[text] = r.get<std::string>({"text"});
BOOST_CHECK_EQUAL(text, kS[i].s); BOOST_CHECK_EQUAL(text, kS[i].s);
BOOST_CHECK_EQUAL(cif::v2::sac_parser::is_unquoted_string(kS[i].s), kS[i].q); BOOST_CHECK_EQUAL(cif::sac_parser::is_unquoted_string(kS[i].s), kS[i].q);
++i; ++i;
} }
std::stringstream ss; std::stringstream ss;
data1.save(ss); data1.save(ss);
auto data2 = cif::v2::file(ss); auto data2 = cif::file(ss);
auto &db2 = data2.front(); auto &db2 = data2.front();
auto &test2 = db2["test"]; auto &test2 = db2["test"];
...@@ -2124,14 +2124,14 @@ There it was!)", false} ...@@ -2124,14 +2124,14 @@ There it was!)", false}
{ {
const auto &[text] = r.get<std::string>({"text"}); const auto &[text] = r.get<std::string>({"text"});
BOOST_CHECK_EQUAL(text, kS[i].s); BOOST_CHECK_EQUAL(text, kS[i].s);
BOOST_CHECK_EQUAL(cif::v2::sac_parser::is_unquoted_string(kS[i].s), kS[i].q); BOOST_CHECK_EQUAL(cif::sac_parser::is_unquoted_string(kS[i].s), kS[i].q);
++i; ++i;
} }
std::stringstream ss; std::stringstream ss;
data1.save(ss); data1.save(ss);
auto data2 = cif::v2::file(ss); auto data2 = cif::file(ss);
auto &db2 = data2.front(); auto &db2 = data2.front();
auto &test2 = db2["test"]; auto &test2 = db2["test"];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment