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
87015129
Unverified
Commit
87015129
authored
Aug 17, 2022
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove cif++/Cif++.hpp
Implemented reorder by index
parent
b317c780
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
127 additions
and
5 deletions
+127
-5
include/cif++/Cif++.hpp
+0
-0
include/cif++/category.hpp
+4
-5
src/category.cpp
+6
-0
test/unit-v2-test.cpp
+117
-0
No files found.
include/cif++/Cif++.hpp
deleted
100644 → 0
View file @
b317c780
This diff is collapsed.
Click to expand it.
include/cif++/category.hpp
View file @
87015129
...
@@ -329,13 +329,8 @@ class category
...
@@ -329,13 +329,8 @@ class category
bool
has_parents
(
row_handle
r
)
const
;
bool
has_parents
(
row_handle
r
)
const
;
std
::
vector
<
row_handle
>
get_children
(
row_handle
r
,
const
category
&
childCat
)
const
;
std
::
vector
<
row_handle
>
get_children
(
row_handle
r
,
const
category
&
childCat
)
const
;
// std::vector<row_handle> getChildren(row_handle r, const char *childCat);
std
::
vector
<
row_handle
>
get_parents
(
row_handle
r
,
const
category
&
parentCat
)
const
;
std
::
vector
<
row_handle
>
get_parents
(
row_handle
r
,
const
category
&
parentCat
)
const
;
// std::vector<row_handle> getParents(row_handle r, const char *parentCat);
std
::
vector
<
row_handle
>
get_linked
(
row_handle
r
,
const
category
&
cat
)
const
;
std
::
vector
<
row_handle
>
get_linked
(
row_handle
r
,
const
category
&
cat
)
const
;
// std::vector<row_handle> getLinked(row_handle r, const char *cat);
// --------------------------------------------------------------------
// --------------------------------------------------------------------
...
@@ -467,6 +462,10 @@ class category
...
@@ -467,6 +462,10 @@ class category
// --------------------------------------------------------------------
// --------------------------------------------------------------------
void
reorder_by_index
();
// --------------------------------------------------------------------
std
::
vector
<
std
::
string
>
get_tag_order
()
const
;
std
::
vector
<
std
::
string
>
get_tag_order
()
const
;
void
write
(
std
::
ostream
&
os
)
const
;
void
write
(
std
::
ostream
&
os
)
const
;
...
...
src/category.cpp
View file @
87015129
...
@@ -1638,6 +1638,12 @@ category::iterator category::erase_impl(const_iterator pos)
...
@@ -1638,6 +1638,12 @@ category::iterator category::erase_impl(const_iterator pos)
// return iterator(*this, cur);
// return iterator(*this, cur);
}
}
void
category
::
reorder_by_index
()
{
if
(
m_index
)
std
::
tie
(
m_head
,
m_tail
)
=
m_index
->
reorder
();
}
namespace
detail
namespace
detail
{
{
...
...
test/unit-v2-test.cpp
View file @
87015129
...
@@ -2264,3 +2264,119 @@ BOOST_AUTO_TEST_CASE(replace_all_test)
...
@@ -2264,3 +2264,119 @@ BOOST_AUTO_TEST_CASE(replace_all_test)
BOOST_CHECK_EQUAL
(
s
,
"aap, noot, mies"
);
BOOST_CHECK_EQUAL
(
s
,
"aap, noot, mies"
);
}
}
// --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE
(
reorder_test
)
{
const
char
dict
[]
=
R"(
data_test_dict.dic
_datablock.id test_dict.dic
_datablock.description
;
A test dictionary
;
_dictionary.title test_dict.dic
_dictionary.datablock_id test_dict.dic
_dictionary.version 1.0
loop_
_item_type_list.code
_item_type_list.primitive_code
_item_type_list.construct
_item_type_list.detail
code char
'[][_,.;:"&<>()/\{}'`~!@#$%A-Za-z0-9*|+-]*'
; code item types/single words ...
;
text char
'[][ \n\t()_,.;:"&<>/\{}'`~!@#$%?+=*A-Za-z0-9|^-]*'
; text item types / multi-line text ...
;
int numb
'[+-]?[0-9]+'
; int item types are the subset of numbers that are the negative
or positive integers.
;
save_cat_1
_category.description 'A simple test category'
_category.id cat_1
_category.mandatory_code no
_category_key.name '_cat_1.id'
save_
save__cat_1.id
_item.name '_cat_1.id'
_item.category_id cat_1
_item.mandatory_code yes
_item_aliases.dictionary cif_core.dic
_item_aliases.version 2.0.1
_item_type.code code
save_
save__cat_1.name
_item.name '_cat_1.name'
_item.category_id cat_1
_item.mandatory_code yes
_item_aliases.dictionary cif_core.dic
_item_aliases.version 2.0.1
_item_type.code text
save_
)"
;
struct
membuf
:
public
std
::
streambuf
{
membuf
(
char
*
text
,
size_t
length
)
{
this
->
setg
(
text
,
text
,
text
+
length
);
}
}
buffer
(
const_cast
<
char
*>
(
dict
),
sizeof
(
dict
)
-
1
);
std
::
istream
is_dict
(
&
buffer
);
auto
validator
=
cif
::
parse_dictionary
(
"test"
,
is_dict
);
cif
::
file
f
;
f
.
set_validator
(
&
validator
);
// --------------------------------------------------------------------
const
char
data
[]
=
R"(
data_test
loop_
_cat_1.id
_cat_1.name
2 Noot
1 Aap
3 Mies
)"
;
struct
data_membuf
:
public
std
::
streambuf
{
data_membuf
(
char
*
text
,
size_t
length
)
{
this
->
setg
(
text
,
text
,
text
+
length
);
}
}
data_buffer
(
const_cast
<
char
*>
(
data
),
sizeof
(
data
)
-
1
);
std
::
istream
is_data
(
&
data_buffer
);
f
.
load
(
is_data
);
BOOST_ASSERT
(
f
.
is_valid
());
auto
&
cat1
=
f
.
front
()[
"cat_1"
];
cat1
.
reorder_by_index
();
int
n
=
1
;
const
char
*
ts
[]
=
{
"Aap"
,
"Noot"
,
"Mies"
};
for
(
const
auto
&
[
id
,
name
]
:
cat1
.
rows
<
int
,
std
::
string
>
(
"id"
,
"name"
))
{
BOOST_CHECK_EQUAL
(
id
,
n
);
BOOST_CHECK_EQUAL
(
name
,
ts
[
n
-
1
]);
++
n
;
}
}
\ No newline at end of file
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