Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
libcifpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
libcifpp
Commits
a12acaa5
Unverified
Commit
a12acaa5
authored
Aug 11, 2022
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moving from namespace cif::v2 to cif
parent
ff62efe7
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
215 additions
and
219 deletions
+215
-219
examples/example.cpp
+9
-12
include/cif++/cif/category.hpp
+3
-3
include/cif++/cif/condition.hpp
+3
-3
include/cif++/cif/datablock.hpp
+3
-3
include/cif++/cif/dictionary_parser.hpp
+2
-2
include/cif++/cif/file.hpp
+3
-3
include/cif++/cif/forward_decl.hpp
+3
-3
include/cif++/cif/item.hpp
+2
-2
include/cif++/cif/iterator.hpp
+3
-3
include/cif++/cif/list.hpp
+2
-2
include/cif++/cif/parser.hpp
+2
-2
include/cif++/cif/row.hpp
+3
-3
include/cif++/cif/validate.hpp
+3
-4
include/cif++/structure/Compound.hpp
+2
-2
include/cif++/structure/Structure.hpp
+20
-20
src/cif/category.cpp
+4
-4
src/cif/condition.cpp
+2
-2
src/cif/datablock.cpp
+1
-1
src/cif/dictionary_parser.cpp
+10
-10
src/cif/file.cpp
+3
-3
src/cif/item.cpp
+1
-1
src/cif/parser.cpp
+3
-3
src/cif/row.cpp
+3
-3
src/cif/validate.cpp
+2
-2
test/unit-v2-test.cpp
+123
-123
No files found.
examples/example.cpp
View file @
a12acaa5
#include <iostream>
#include <filesystem>
#include <cif++/
Cif++
.hpp>
#include <cif++/
cif
.hpp>
namespace
fs
=
std
::
filesystem
;
int
main
()
{
fs
::
path
in
(
"1cbs.cif.gz"
);
cif
::
File
file
;
file
.
loadDictionary
(
"mmcif_pdbx_v50"
);
cif
::
file
file
;
file
.
load_dictionary
(
"mmcif_pdbx_v50"
);
file
.
load
(
"1cbs.cif.gz"
);
auto
&
db
=
file
.
firstDatablock
()[
"atom_site"
];
auto
n
=
db
.
find
(
cif
::
Key
(
"label_atom_id"
)
==
"OXT"
).
size
();
auto
&
db
=
file
.
front
();
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
;
for
(
const
auto
&
[
asym
,
comp
,
seqnr
]
:
db
.
find
<
std
::
string
,
std
::
string
,
int
>
(
cif
::
K
ey
(
"label_atom_id"
)
==
"OXT"
,
"label_asym_id"
,
"label_comp_id"
,
"label_seq_id"
))
for
(
const
auto
&
[
asym
,
comp
,
seqnr
]
:
atom_site
.
find
<
std
::
string
,
std
::
string
,
int
>
(
cif
::
k
ey
(
"label_atom_id"
)
==
"OXT"
,
"label_asym_id"
,
"label_comp_id"
,
"label_seq_id"
))
{
std
::
cout
<<
asym
<<
' '
<<
comp
<<
' '
<<
seqnr
<<
std
::
endl
;
}
...
...
include/cif++/cif/category.hpp
View file @
a12acaa5
...
...
@@ -38,7 +38,7 @@
// https://en.cppreference.com/w/cpp/named_req/SequenceContainer
// and more?
namespace
cif
::
v2
namespace
cif
{
// --------------------------------------------------------------------
...
...
@@ -660,4 +660,4 @@ class category
row
*
m_head
=
nullptr
,
*
m_tail
=
nullptr
;
};
}
//
namespace
cif
::
v2
\ No newline at end of file
}
//
namespace
cif
\ No newline at end of file
include/cif++/cif/condition.hpp
View file @
a12acaa5
...
...
@@ -33,7 +33,7 @@
#include <cif++/cif/row.hpp>
namespace
cif
::
v2
namespace
cif
{
// --------------------------------------------------------------------
...
...
@@ -612,4 +612,4 @@ namespace literals
}
}
// namespace literals
}
//
namespace
cif
::
v2
\ No newline at end of file
}
//
namespace
cif
\ No newline at end of file
include/cif++/cif/datablock.hpp
View file @
a12acaa5
...
...
@@ -30,7 +30,7 @@
#include <cif++/cif/category.hpp>
namespace
cif
::
v2
namespace
cif
{
// --------------------------------------------------------------------
...
...
@@ -86,4 +86,4 @@ class datablock : public std::list<category>
const
validator
*
m_validator
=
nullptr
;
};
}
//
namespace
cif
::
v2
\ No newline at end of file
}
//
namespace
cif
\ No newline at end of file
include/cif++/cif/dictionary_parser.hpp
View file @
a12acaa5
...
...
@@ -28,9 +28,9 @@
#include <cif++/cif/validate.hpp>
namespace
cif
::
v2
namespace
cif
{
validator
parse_dictionary
(
std
::
string_view
name
,
std
::
istream
&
is
);
}
// namespace cif
::v2
}
// namespace cif
include/cif++/cif/file.hpp
View file @
a12acaa5
...
...
@@ -29,7 +29,7 @@
#include <cif++/cif/datablock.hpp>
#include <cif++/cif/parser.hpp>
namespace
cif
::
v2
namespace
cif
{
// --------------------------------------------------------------------
...
...
@@ -83,4 +83,4 @@ class file : public std::list<datablock>
const
validator
*
m_validator
=
nullptr
;
};
}
//
namespace
cif
::
v2
\ No newline at end of file
}
//
namespace
cif
\ No newline at end of file
include/cif++/cif/forward_decl.hpp
View file @
a12acaa5
...
...
@@ -29,7 +29,7 @@
#include <string>
#include <vector>
namespace
cif
::
v2
namespace
cif
{
class
category
;
...
...
@@ -43,4 +43,4 @@ class row_handle;
class
item
;
class
item_handle
;
}
//
namespace
cif
::
v2
\ No newline at end of file
}
//
namespace
cif
\ No newline at end of file
include/cif++/cif/item.hpp
View file @
a12acaa5
...
...
@@ -38,7 +38,7 @@
#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
}
};
}
// namespace cif
::v2
}
// namespace cif
include/cif++/cif/iterator.hpp
View file @
a12acaa5
...
...
@@ -28,7 +28,7 @@
#include <cif++/cif/row.hpp>
namespace
cif
::
v2
namespace
cif
{
// --------------------------------------------------------------------
...
...
@@ -466,4 +466,4 @@ void conditional_iterator_proxy<Category, Ts...>::swap(conditional_iterator_prox
std
::
swap
(
mCix
,
rhs
.
mCix
);
}
}
//
namespace
cif
::
v2
\ No newline at end of file
}
//
namespace
cif
\ No newline at end of file
include/cif++/cif/list.hpp
View file @
a12acaa5
...
...
@@ -28,7 +28,7 @@
#include <memory>
namespace
cif
::
v2
namespace
cif
{
// --------------------------------------------------------------------
...
...
@@ -76,4 +76,4 @@ class list
};
}
// namespace cif
::v2
}
// namespace cif
include/cif++/cif/parser.hpp
View file @
a12acaa5
...
...
@@ -28,7 +28,7 @@
#include <cif++/cif/row.hpp>
namespace
cif
::
v2
namespace
cif
{
// --------------------------------------------------------------------
...
...
@@ -284,4 +284,4 @@ class parser : public sac_parser
row_handle
m_row
;
};
}
// namespace cif
::v2
}
// namespace cif
include/cif++/cif/row.hpp
View file @
a12acaa5
...
...
@@ -28,7 +28,7 @@
#include <cif++/cif/item.hpp>
namespace
cif
::
v2
namespace
cif
{
namespace
detail
...
...
@@ -266,4 +266,4 @@ class row_initializer
std
::
vector
<
item
>
m_items
;
};
}
//
namespace
cif
::
v2
\ No newline at end of file
}
//
namespace
cif
\ No newline at end of file
include/cif++/cif/validate.hpp
View file @
a12acaa5
...
...
@@ -35,11 +35,10 @@
#include <cif++/utilities.hpp>
namespace
cif
::
v2
namespace
cif
{
struct
category_validator
;
class
validator_factory
;
// --------------------------------------------------------------------
...
...
@@ -68,7 +67,7 @@ struct type_validator
{
std
::
string
m_name
;
DDL_PrimitiveType
m_primitive_type
;
// std::regex
mR
x;
// std::regex
m_r
x;
boost
::
regex
m_rx
;
bool
operator
<
(
const
type_validator
&
rhs
)
const
...
...
@@ -218,4 +217,4 @@ class validator_factory
std
::
list
<
validator
>
m_validators
;
};
}
// namespace cif
::v2
}
// namespace cif
include/cif++/structure/Compound.hpp
View file @
a12acaa5
...
...
@@ -130,8 +130,8 @@ class Compound
friend
class
CCDCompoundFactoryImpl
;
friend
class
CCP4CompoundFactoryImpl
;
Compound
(
cif
::
v2
::
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
);
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
mName
;
...
...
include/cif++/structure/Structure.hpp
View file @
a12acaa5
...
...
@@ -63,7 +63,7 @@ class Atom
private
:
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
AtomImpl
(
const
AtomImpl
&
impl
,
const
Point
&
loc
,
const
std
::
string
&
sym_op
);
...
...
@@ -85,7 +85,7 @@ class Atom
const
std
::
string
get_property
(
const
std
::
string_view
name
)
const
;
void
set_property
(
const
std
::
string_view
name
,
const
std
::
string
&
value
);
const
cif
::
v2
::
datablock
&
mDb
;
const
cif
::
datablock
&
mDb
;
std
::
string
mID
;
AtomType
mType
;
...
...
@@ -98,7 +98,7 @@ class Atom
Point
mLocation
;
int
mRefcount
;
cif
::
v2
::
row_handle
mRow
;
cif
::
row_handle
mRow
;
// mutable std::vector<std::tuple<std::string, cif::detail::ItemReference>> mCachedRefs;
...
...
@@ -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
Atom
(
const
Atom
&
rhs
,
const
Point
&
symmmetry_location
,
const
std
::
string
&
symmetry_operation
);
...
...
@@ -180,8 +180,8 @@ class Atom
void
translateRotateAndTranslate
(
Point
t1
,
Quaternion
q
,
Point
t2
);
// for direct access to underlying data, be careful!
const
cif
::
v2
::
row_handle
getRow
()
const
{
return
impl
().
mRow
;
}
const
cif
::
v2
::
row_handle
getRowAniso
()
const
;
const
cif
::
row_handle
getRow
()
const
{
return
impl
().
mRow
;
}
const
cif
::
row_handle
getRowAniso
()
const
;
bool
isSymmetryCopy
()
const
{
return
impl
().
mSymmetryCopy
;
}
std
::
string
symmetry
()
const
{
return
impl
().
mSymmetryOperator
;
}
...
...
@@ -513,7 +513,7 @@ class Polymer : public std::vector<Monomer>
Structure
*
mStructure
;
std
::
string
mEntityID
;
std
::
string
mAsymID
;
// cif::
v2::
row_handleSet mPolySeq;
// cif::row_handleSet mPolySeq;
};
// --------------------------------------------------------------------
...
...
@@ -578,7 +578,7 @@ class Branch : public std::vector<Sugar>
// file is a reference to the data stored in e.g. the cif file.
// This object is not copyable.
class
File
:
public
cif
::
v2
::
file
class
File
:
public
cif
::
file
{
public
:
File
()
{}
...
...
@@ -599,10 +599,10 @@ class File : public cif::v2::file
// void load(const std::filesystem::path &p) override;
// void save(const std::filesystem::path &p) override;
// using cif::
v2::
file::load;
// using cif::
v2::
file::save;
// using cif::file::load;
// 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)
class
Structure
{
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
(
cif
::
v2
::
datablock
&
db
,
size_t
modelNr
=
1
,
StructureOpenOptions
options
=
{});
Structure
(
cif
::
datablock
&
db
,
size_t
modelNr
=
1
,
StructureOpenOptions
options
=
{});
Structure
(
Structure
&&
s
)
=
default
;
...
...
@@ -756,12 +756,12 @@ class Structure
/// This method creates new atom records filled with info from the info.
///
/// \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
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
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
///
...
...
@@ -769,7 +769,7 @@ class Structure
/// \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_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
);
/// \brief Remove \a branch
...
...
@@ -797,12 +797,12 @@ class Structure
void
cleanupEmptyCategories
();
/// \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
];
}
cif
::
v2
::
datablock
&
datablock
()
const
cif
::
datablock
&
datablock
()
const
{
return
mDb
;
}
...
...
@@ -832,7 +832,7 @@ class Structure
void
removeAtom
(
Atom
&
a
,
bool
removeFromResidue
);
void
removeSugar
(
Sugar
&
sugar
);
cif
::
v2
::
datablock
&
mDb
;
cif
::
datablock
&
mDb
;
size_t
mModelNr
;
AtomView
mAtoms
;
std
::
vector
<
size_t
>
mAtomIndex
;
...
...
src/cif/category.cpp
View file @
a12acaa5
...
...
@@ -34,7 +34,7 @@
// 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.
namespace
cif
::
v2
namespace
cif
{
const
uint32_t
kMaxLineLength
=
132
;
...
...
@@ -1119,7 +1119,7 @@ void category::erase_orphans(condition &&cond)
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"
;
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
os
<<
"# "
<<
'\n'
;
}
}
//
namespace
cif
::
v2
\ No newline at end of file
}
//
namespace
cif
\ No newline at end of file
src/cif/condition.cpp
View file @
a12acaa5
...
...
@@ -27,7 +27,7 @@
#include <cif++/cif/category.hpp>
#include <cif++/cif/condition.hpp>
namespace
cif
::
v2
namespace
cif
{
iset
get_category_fields
(
const
category
&
cat
)
...
...
@@ -58,4 +58,4 @@ bool is_column_type_uchar(const category &cat, std::string_view col)
return
result
;
}
}
// namespace cif
::v2
}
// namespace cif
src/cif/datablock.cpp
View file @
a12acaa5
...
...
@@ -26,7 +26,7 @@
#include <cif++/cif/datablock.hpp>
namespace
cif
::
v2
namespace
cif
{
void
datablock
::
set_validator
(
const
validator
*
v
)
...
...
src/cif/dictionary_parser.cpp
View file @
a12acaa5
...
...
@@ -29,7 +29,7 @@
#include <cif++/cif/file.hpp>
#include <cif++/cif/parser.hpp>
namespace
cif
::
v2
namespace
cif
{
using
namespace
literals
;
...
...
@@ -194,7 +194,7 @@ class dictionary_parser : public parser
if
(
isCategorySaveFrame
)
{
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
;
for
(
auto
k
:
dict
[
"category_key"
])
...
...
@@ -210,7 +210,7 @@ class dictionary_parser : public parser
{
// if the type code is missing, this must be a pointer, just skip it
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
;
if
(
not
(
typeCode
.
empty
()
or
typeCode
==
"?"
))
...
...
@@ -221,7 +221,7 @@ class dictionary_parser : public parser
ess
.
insert
(
e
[
"value"
].
as
<
std
::
string
>
());
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
;
if
(
defaultValue
.
empty
())
{
...
...
@@ -238,7 +238,7 @@ class dictionary_parser : public parser
{
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
::
tie
(
catName
,
item_name
)
=
splitTagName
(
tagName
);
...
...
@@ -297,7 +297,7 @@ class dictionary_parser : public parser
{
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
);
}
...
...
@@ -347,7 +347,7 @@ class dictionary_parser : public parser
{
std
::
string
child
,
parent
;
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
);
if
(
civ
==
nullptr
)
...
...
@@ -441,7 +441,7 @@ class dictionary_parser : public parser
for
(
auto
t
:
dict
[
"item_type_list"
])
{
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
,
"
\\
t"
,
"
\t
"
);
...
...
@@ -494,4 +494,4 @@ validator parse_dictionary(std::string_view name, std::istream &is)
return
result
;
}
}
//
namespace
cif
::
v2
\ No newline at end of file
}
//
namespace
cif
\ No newline at end of file
src/cif/file.cpp
View file @
a12acaa5
...
...
@@ -28,7 +28,7 @@
#include <cif++/cif/file.hpp>
namespace
cif
::
v2
namespace
cif
{
// --------------------------------------------------------------------
...
...
@@ -165,4 +165,4 @@ void file::save(std::ostream &os) const
db
.
write
(
os
);
}
}
//
namespace
cif
::
v2
\ No newline at end of file
}
//
namespace
cif
\ No newline at end of file
src/cif/item.cpp
View file @
a12acaa5
...
...
@@ -26,7 +26,7 @@
#include <cif++/cif/row.hpp>
namespace
cif
::
v2
namespace
cif
{
std
::
string_view
item_handle
::
text
()
const
...
...
src/cif/parser.cpp
View file @
a12acaa5
...
...
@@ -41,7 +41,7 @@ namespace cif
extern
int
VERBOSE
;
}
namespace
cif
::
v2
namespace
cif
{
// --------------------------------------------------------------------
...
...
@@ -817,4 +817,4 @@ void parser::produce_item(const std::string &category, const std::string &item,
m_row
[
item
]
=
m_token_value
;
}
}
//
namespace
cif
::
v2
\ No newline at end of file
}
//
namespace
cif
\ No newline at end of file
src/cif/row.cpp
View file @
a12acaa5
...
...
@@ -26,7 +26,7 @@
#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
)
...
...
@@ -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
());
}
}
//
namespace
cif
::
v2
\ No newline at end of file
}
//
namespace
cif
\ No newline at end of file
src/cif/validate.cpp
View file @
a12acaa5
...
...
@@ -40,7 +40,7 @@ namespace cif
extern
int
VERBOSE
;
}
namespace
cif
::
v2
namespace
cif
{
using
cif
::
VERBOSE
;
...
...
@@ -430,4 +430,4 @@ void validator_factory::construct_validator(std::string_view name, std::istream
parse_dictionary
(
name
,
is
);
}
}
// namespace cif
::v2
}
// namespace cif
test/unit-v2-test.cpp
View file @
a12acaa5
...
...
@@ -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
{
...
...
@@ -55,7 +55,7 @@ cif::v2::file operator""_cf(const char *text, size_t length)
}
buffer
(
const_cast
<
char
*>
(
text
),
length
);
std
::
istream
is
(
&
buffer
);
return
cif
::
v2
::
file
(
is
);
return
cif
::
file
(
is
);
}
// --------------------------------------------------------------------
...
...
@@ -132,7 +132,7 @@ BOOST_AUTO_TEST_CASE(cc_2)
BOOST_AUTO_TEST_CASE
(
item_1
)
{
using
namespace
cif
::
v2
;
using
namespace
cif
;
item
i1
(
"1"
,
"1"
);
item
i2
(
"2"
,
2.0
);
...
...
@@ -162,7 +162,7 @@ BOOST_AUTO_TEST_CASE(item_1)
BOOST_AUTO_TEST_CASE
(
r_1
)
{
cif
::
v2
::
category
c
(
"foo"
);
cif
::
category
c
(
"foo"
);
c
.
emplace
({
{
"f-1"
,
1
},
{
"f-2"
,
"two"
},
...
...
@@ -177,7 +177,7 @@ BOOST_AUTO_TEST_CASE(r_1)
BOOST_AUTO_TEST_CASE
(
r_2
)
{
cif
::
v2
::
category
c
(
"foo"
);
cif
::
category
c
(
"foo"
);
for
(
size_t
i
=
1
;
i
<
256
;
++
i
)
{
...
...
@@ -188,7 +188,7 @@ BOOST_AUTO_TEST_CASE(r_2)
BOOST_AUTO_TEST_CASE
(
c_1
)
{
cif
::
v2
::
category
c
(
"foo"
);
cif
::
category
c
(
"foo"
);
c
.
emplace
({{
"id"
,
1
},
{
"s"
,
"aap"
}});
c
.
emplace
({{
"id"
,
2
},
{
"s"
,
"noot"
}});
...
...
@@ -212,7 +212,7 @@ BOOST_AUTO_TEST_CASE(c_1)
int
i
;
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
(
s
.
compare
(
ts
[
n
-
1
]),
0
);
...
...
@@ -237,7 +237,7 @@ BOOST_AUTO_TEST_CASE(c_2)
{
3
,
"mies"
}
};
cif
::
v2
::
category
c
(
"foo"
);
cif
::
category
c
(
"foo"
);
for
(
const
auto
&
[
id
,
s
]
:
D
)
c
.
emplace
({
{
"id"
,
id
},
{
"s"
,
s
}
});
...
...
@@ -245,12 +245,12 @@ BOOST_AUTO_TEST_CASE(c_2)
BOOST_CHECK
(
not
c
.
empty
());
BOOST_CHECK_EQUAL
(
c
.
size
(),
3
);
cif
::
v2
::
category
c2
(
c
);
cif
::
category
c2
(
c
);
BOOST_CHECK
(
not
c2
.
empty
());
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_EQUAL
(
c3
.
size
(),
3
);
...
...
@@ -277,12 +277,12 @@ BOOST_AUTO_TEST_CASE(c_3)
{
3
,
"mies"
}
};
cif
::
v2
::
category
c
(
"foo"
);
cif
::
category
c
(
"foo"
);
for
(
const
auto
&
[
id
,
s
]
:
D
)
c
.
emplace
({
{
"id"
,
id
},
{
"s"
,
s
}
});
cif
::
v2
::
category
c2
(
"bar"
);
cif
::
category
c2
(
"bar"
);
for
(
auto
r
:
c
)
c2
.
emplace
(
r
);
...
...
@@ -292,18 +292,18 @@ BOOST_AUTO_TEST_CASE(c_3)
BOOST_AUTO_TEST_CASE
(
ci_1
)
{
cif
::
v2
::
category
c
(
"foo"
);
cif
::
category
c
(
"foo"
);
c
.
emplace
({{
"id"
,
1
},
{
"s"
,
"aap"
}});
c
.
emplace
({{
"id"
,
2
},
{
"s"
,
"noot"
}});
c
.
emplace
({{
"id"
,
3
},
{
"s"
,
"mies"
}});
cif
::
v2
::
category
::
iterator
i1
=
c
.
begin
();
cif
::
v2
::
category
::
const_iterator
i2
=
c
.
cbegin
();
cif
::
v2
::
category
::
const_iterator
i3
=
c
.
begin
();
cif
::
category
::
iterator
i1
=
c
.
begin
();
cif
::
category
::
const_iterator
i2
=
c
.
cbegin
();
cif
::
category
::
const_iterator
i3
=
c
.
begin
();
cif
::
v2
::
category
::
const_iterator
i4
=
i2
;
cif
::
v2
::
category
::
const_iterator
i5
=
i1
;
cif
::
category
::
const_iterator
i4
=
i2
;
cif
::
category
::
const_iterator
i5
=
i1
;
BOOST_CHECK
(
i1
==
i2
);
BOOST_CHECK
(
i1
==
i3
);
...
...
@@ -348,7 +348,7 @@ _test.name
++
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
[
"name"
].
as
<
std
::
string
>
(),
"aap"
);
});
...
...
@@ -387,7 +387,7 @@ _test.value
BOOST_CHECK_EQUAL
(
test
.
size
(),
3
);
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
(
r
[
"id"
].
as
<
int
>
(),
1
);
...
...
@@ -395,18 +395,18 @@ _test.value
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_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_EQUAL
(
t2
.
front
()[
"name"
].
as
<
std
::
string
>
(),
"mies"
);
}
BOOST_AUTO_TEST_CASE
(
ut3
)
{
using
namespace
cif
::
v2
::
literals
;
using
namespace
cif
::
literals
;
auto
f
=
R"(data_TEST
#
...
...
@@ -428,8 +428,8 @@ _test.value
auto
&
test
=
db
[
"test"
];
BOOST_CHECK_EQUAL
(
test
.
size
(),
5
);
BOOST_CHECK
(
test
.
exists
(
"value"
_key
==
cif
::
v2
::
null
));
BOOST_CHECK_EQUAL
(
test
.
find
(
"value"
_key
==
cif
::
v2
::
null
).
size
(),
2
);
BOOST_CHECK
(
test
.
exists
(
"value"
_key
==
cif
::
null
));
BOOST_CHECK_EQUAL
(
test
.
find
(
"value"
_key
==
cif
::
null
).
size
(),
2
);
}
// --------------------------------------------------------------------
...
...
@@ -539,9 +539,9 @@ save__cat_2.desc
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
);
// --------------------------------------------------------------------
...
...
@@ -581,7 +581,7 @@ _cat_2.desc
BOOST_CHECK_EQUAL
(
cat1
.
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
(
cat2
.
size
(),
1
);
...
...
@@ -669,9 +669,9 @@ save__cat_1.c
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
);
// --------------------------------------------------------------------
...
...
@@ -701,11 +701,11 @@ mies Mies
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
);
cat1
.
erase
(
cif
::
v2
::
key
(
"id"
)
==
"noot"
);
cat1
.
erase
(
cif
::
key
(
"id"
)
==
"noot"
);
BOOST_CHECK_EQUAL
(
cat1
.
size
(),
2
);
...
...
@@ -715,7 +715,7 @@ mies Mies
{
"c"
,
"2e-aap"
}
}),
std
::
exception
);
cat1
.
erase
(
cif
::
v2
::
key
(
"id"
)
==
"aap"
);
cat1
.
erase
(
cif
::
key
(
"id"
)
==
"aap"
);
BOOST_CHECK_EQUAL
(
cat1
.
size
(),
1
);
...
...
@@ -834,9 +834,9 @@ save__cat_2.desc
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
);
// --------------------------------------------------------------------
...
...
@@ -878,7 +878,7 @@ _cat_2.desc
// 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
;
break
;
...
...
@@ -887,15 +887,15 @@ _cat_2.desc
BOOST_CHECK_EQUAL
(
cat1
.
size
(),
3
);
BOOST_CHECK_EQUAL
(
cat2
.
size
(),
4
);
BOOST_CHECK_EQUAL
(
cat1
.
find
(
cif
::
v2
::
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"
)
==
1
).
size
(),
0
);
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
::
v2
::
key
(
"parent_id"
)
==
10
).
size
(),
2
);
BOOST_CHECK_EQUAL
(
cat2
.
find
(
cif
::
key
(
"parent_id"
)
==
1
).
size
(),
0
);
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
for
(
auto
r
:
cat1
.
find
(
cif
::
v2
::
key
(
"id"
)
==
2
))
for
(
auto
r
:
cat1
.
find
(
cif
::
key
(
"id"
)
==
2
))
{
r
[
"id"
]
=
20
;
break
;
...
...
@@ -904,25 +904,25 @@ _cat_2.desc
BOOST_CHECK_EQUAL
(
cat1
.
size
(),
3
);
BOOST_CHECK_EQUAL
(
cat2
.
size
(),
4
);
BOOST_CHECK_EQUAL
(
cat1
.
find
(
cif
::
v2
::
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"
)
==
2
).
size
(),
0
);
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
::
v2
::
key
(
"parent_id"
)
==
20
).
size
(),
1
);
BOOST_CHECK_EQUAL
(
cat2
.
find
(
cif
::
key
(
"parent_id"
)
==
2
).
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
::
v2
::
key
(
"parent_id"
)
==
2
and
cif
::
v2
::
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
::
v2
::
key
(
"parent_id"
)
==
20
and
cif
::
v2
::
key
(
"name2"
)
==
"n2"
).
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
::
key
(
"parent_id"
)
==
2
and
cif
::
key
(
"name2"
)
==
"n2"
).
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
::
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
(
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
(
cat2
.
size
(),
1
);
...
...
@@ -1037,9 +1037,9 @@ save__cat_2.parent_id3
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
);
// --------------------------------------------------------------------
...
...
@@ -1091,7 +1091,7 @@ _cat_2.parent_id3
// 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
;
break
;
...
...
@@ -1100,13 +1100,13 @@ _cat_2.parent_id3
BOOST_CHECK_EQUAL
(
cat1
.
size
(),
4
);
BOOST_CHECK_EQUAL
(
cat2
.
size
(),
13
);
BOOST_CHECK_EQUAL
(
cat1
.
find
(
cif
::
v2
::
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"
)
==
1
).
size
(),
0
);
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
::
v2
::
key
(
"parent_id"
)
==
10
).
size
(),
2
);
BOOST_CHECK_EQUAL
(
cat2
.
find
(
cif
::
key
(
"parent_id"
)
==
1
).
size
(),
1
);
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
;
break
;
...
...
@@ -1115,13 +1115,13 @@ _cat_2.parent_id3
BOOST_CHECK_EQUAL
(
cat1
.
size
(),
4
);
BOOST_CHECK_EQUAL
(
cat2
.
size
(),
13
);
BOOST_CHECK_EQUAL
(
cat1
.
find
(
cif
::
v2
::
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"
)
==
2
).
size
(),
0
);
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
::
v2
::
key
(
"parent_id"
)
==
20
).
size
(),
2
);
BOOST_CHECK_EQUAL
(
cat2
.
find
(
cif
::
key
(
"parent_id"
)
==
2
).
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
;
break
;
...
...
@@ -1130,13 +1130,13 @@ _cat_2.parent_id3
BOOST_CHECK_EQUAL
(
cat1
.
size
(),
4
);
BOOST_CHECK_EQUAL
(
cat2
.
size
(),
13
);
BOOST_CHECK_EQUAL
(
cat1
.
find
(
cif
::
v2
::
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"
)
==
3
).
size
(),
0
);
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
::
v2
::
key
(
"parent_id"
)
==
30
).
size
(),
1
);
BOOST_CHECK_EQUAL
(
cat2
.
find
(
cif
::
key
(
"parent_id"
)
==
3
).
size
(),
2
);
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
;
break
;
...
...
@@ -1145,11 +1145,11 @@ _cat_2.parent_id3
BOOST_CHECK_EQUAL
(
cat1
.
size
(),
4
);
BOOST_CHECK_EQUAL
(
cat2
.
size
(),
13
);
BOOST_CHECK_EQUAL
(
cat1
.
find
(
cif
::
v2
::
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"
)
==
4
).
size
(),
0
);
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
::
v2
::
key
(
"parent_id"
)
==
40
).
size
(),
0
);
BOOST_CHECK_EQUAL
(
cat2
.
find
(
cif
::
key
(
"parent_id"
)
==
4
).
size
(),
3
);
BOOST_CHECK_EQUAL
(
cat2
.
find
(
cif
::
key
(
"parent_id"
)
==
40
).
size
(),
0
);
}
// --------------------------------------------------------------------
...
...
@@ -1258,9 +1258,9 @@ cat_2 3 cat_2:cat_1:3
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
);
// --------------------------------------------------------------------
...
...
@@ -1306,7 +1306,7 @@ _cat_2.parent_id3
// --------------------------------------------------------------------
// 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
);
auto
PR2
=
PR2set
.
front
();
BOOST_CHECK_EQUAL
(
PR2
[
"id"
].
as
<
int
>
(),
2
);
...
...
@@ -1315,14 +1315,14 @@ _cat_2.parent_id3
BOOST_ASSERT
(
CR2set
.
size
()
==
3
);
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
>
();
});
std
::
sort
(
CRids
.
begin
(),
CRids
.
end
());
BOOST_CHECK
(
CRids
==
std
::
vector
<
int
>
({
4
,
5
,
6
}));
// 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
;
break
;
...
...
@@ -1331,17 +1331,17 @@ _cat_2.parent_id3
BOOST_CHECK_EQUAL
(
cat1
.
size
(),
3
);
BOOST_CHECK_EQUAL
(
cat2
.
size
(),
7
);
BOOST_CHECK_EQUAL
(
cat1
.
find
(
cif
::
v2
::
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"
)
==
1
).
size
(),
0
);
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
::
v2
::
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
::
v2
::
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
::
v2
::
key
(
"parent_id3"
)
==
10
).
size
(),
1
);
BOOST_CHECK_EQUAL
(
cat2
.
find
(
cif
::
key
(
"parent_id"
)
==
1
).
size
(),
0
);
BOOST_CHECK_EQUAL
(
cat2
.
find
(
cif
::
key
(
"parent_id2"
)
==
1
).
size
(),
0
);
BOOST_CHECK_EQUAL
(
cat2
.
find
(
cif
::
key
(
"parent_id3"
)
==
1
).
size
(),
0
);
BOOST_CHECK_EQUAL
(
cat2
.
find
(
cif
::
key
(
"parent_id"
)
==
10
).
size
(),
1
);
BOOST_CHECK_EQUAL
(
cat2
.
find
(
cif
::
key
(
"parent_id2"
)
==
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
;
break
;
...
...
@@ -1350,17 +1350,17 @@ _cat_2.parent_id3
BOOST_CHECK_EQUAL
(
cat1
.
size
(),
3
);
BOOST_CHECK_EQUAL
(
cat2
.
size
(),
7
);
BOOST_CHECK_EQUAL
(
cat1
.
find
(
cif
::
v2
::
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"
)
==
2
).
size
(),
0
);
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
::
v2
::
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
::
v2
::
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
::
v2
::
key
(
"parent_id3"
)
==
20
).
size
(),
2
);
BOOST_CHECK_EQUAL
(
cat2
.
find
(
cif
::
key
(
"parent_id"
)
==
2
).
size
(),
0
);
BOOST_CHECK_EQUAL
(
cat2
.
find
(
cif
::
key
(
"parent_id2"
)
==
2
).
size
(),
0
);
BOOST_CHECK_EQUAL
(
cat2
.
find
(
cif
::
key
(
"parent_id3"
)
==
2
).
size
(),
0
);
BOOST_CHECK_EQUAL
(
cat2
.
find
(
cif
::
key
(
"parent_id"
)
==
20
).
size
(),
2
);
BOOST_CHECK_EQUAL
(
cat2
.
find
(
cif
::
key
(
"parent_id2"
)
==
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
;
break
;
...
...
@@ -1369,27 +1369,27 @@ _cat_2.parent_id3
BOOST_CHECK_EQUAL
(
cat1
.
size
(),
3
);
BOOST_CHECK_EQUAL
(
cat2
.
size
(),
7
);
BOOST_CHECK_EQUAL
(
cat1
.
find
(
cif
::
v2
::
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"
)
==
3
).
size
(),
0
);
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
::
v2
::
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
::
v2
::
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
::
v2
::
key
(
"parent_id3"
)
==
30
).
size
(),
1
);
BOOST_CHECK_EQUAL
(
cat2
.
find
(
cif
::
key
(
"parent_id"
)
==
3
).
size
(),
0
);
BOOST_CHECK_EQUAL
(
cat2
.
find
(
cif
::
key
(
"parent_id2"
)
==
3
).
size
(),
0
);
BOOST_CHECK_EQUAL
(
cat2
.
find
(
cif
::
key
(
"parent_id3"
)
==
3
).
size
(),
0
);
BOOST_CHECK_EQUAL
(
cat2
.
find
(
cif
::
key
(
"parent_id"
)
==
30
).
size
(),
1
);
BOOST_CHECK_EQUAL
(
cat2
.
find
(
cif
::
key
(
"parent_id2"
)
==
30
).
size
(),
1
);
BOOST_CHECK_EQUAL
(
cat2
.
find
(
cif
::
key
(
"parent_id3"
)
==
30
).
size
(),
1
);
// test delete
cat1
.
erase
(
cif
::
v2
::
key
(
"id"
)
==
10
);
cat1
.
erase
(
cif
::
key
(
"id"
)
==
10
);
BOOST_CHECK_EQUAL
(
cat1
.
size
(),
2
);
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
(
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
(
cat2
.
size
(),
0
);
}
...
...
@@ -1414,21 +1414,21 @@ _test.name
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"
});
BOOST_CHECK_EQUAL
(
id
,
1
);
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"
});
BOOST_CHECK_EQUAL
(
id
,
4
);
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"
});
BOOST_CHECK_EQUAL
(
id
,
5
);
...
...
@@ -1507,7 +1507,7 @@ _test.name
auto
&
db
=
f
.
front
();
// 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
)
{
...
...
@@ -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
(
name
,
"aap"
);
...
...
@@ -1687,9 +1687,9 @@ cat_2 1 '_cat_2.num' '_cat_3.num' cat_3
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
);
// --------------------------------------------------------------------
...
...
@@ -1721,7 +1721,7 @@ _cat_3.num
2 aap 2
)"
;
using
namespace
cif
::
v2
::
literals
;
using
namespace
cif
::
literals
;
struct
data_membuf
:
public
std
::
streambuf
{
...
...
@@ -1745,12 +1745,12 @@ _cat_3.num
{
int
id
,
num
;
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
(
num
,
1
);
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
(
num
,
2
);
BOOST_CHECK_EQUAL
(
name
,
"aap"
);
...
...
@@ -1997,7 +1997,7 @@ BOOST_AUTO_TEST_CASE(reading_file_1)
{
std
::
istringstream
is
(
"Hello, world!"
);
cif
::
v2
::
file
file
;
cif
::
file
file
;
BOOST_CHECK_THROW
(
file
.
load
(
is
),
std
::
runtime_error
);
}
...
...
@@ -2022,7 +2022,7 @@ _test.text ??
std
::
stringstream
ss
;
data1
.
save
(
ss
);
auto
data2
=
cif
::
v2
::
file
(
ss
);
auto
data2
=
cif
::
file
(
ss
);
auto
&
db2
=
data2
.
front
();
auto
&
test2
=
db2
[
"test"
];
...
...
@@ -2070,14 +2070,14 @@ boo.data_.whatever
{
const
auto
&
[
text
]
=
r
.
get
<
std
::
string
>
({
"text"
});
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
;
}
std
::
stringstream
ss
;
data1
.
save
(
ss
);
auto
data2
=
cif
::
v2
::
file
(
ss
);
auto
data2
=
cif
::
file
(
ss
);
auto
&
db2
=
data2
.
front
();
auto
&
test2
=
db2
[
"test"
];
...
...
@@ -2124,14 +2124,14 @@ There it was!)", false}
{
const
auto
&
[
text
]
=
r
.
get
<
std
::
string
>
({
"text"
});
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
;
}
std
::
stringstream
ss
;
data1
.
save
(
ss
);
auto
data2
=
cif
::
v2
::
file
(
ss
);
auto
data2
=
cif
::
file
(
ss
);
auto
&
db2
=
data2
.
front
();
auto
&
test2
=
db2
[
"test"
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment