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
1bcb26ba
Unverified
Commit
1bcb26ba
authored
Jun 07, 2023
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extend validator
faster unique_id
parent
32f4749d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
8 deletions
+30
-8
include/cif++/dictionary_parser.hpp
+1
-0
src/category.cpp
+22
-8
src/dictionary_parser.cpp
+7
-0
No files found.
include/cif++/dictionary_parser.hpp
View file @
1bcb26ba
...
...
@@ -32,5 +32,6 @@ namespace cif
{
validator
parse_dictionary
(
std
::
string_view
name
,
std
::
istream
&
is
);
void
extend_dictionary
(
validator
&
v
,
std
::
istream
&
is
);
}
// namespace cif
src/category.cpp
View file @
1bcb26ba
...
...
@@ -1227,23 +1227,37 @@ std::string category::get_unique_id(std::function<std::string(int)> generator)
{
using
namespace
cif
::
literals
;
std
::
string
id_tag
=
"id"
;
if
(
m_cat_validator
!=
nullptr
and
m_cat_validator
->
m_keys
.
size
()
==
1
)
id_tag
=
m_cat_validator
->
m_keys
.
front
();
// calling size() often is a waste of resources
if
(
m_last_unique_num
==
0
)
m_last_unique_num
=
static_cast
<
uint32_t
>
(
size
());
std
::
string
result
=
generator
(
static_cast
<
int
>
(
m_last_unique_num
++
));
std
::
string
id_tag
=
"id"
;
if
(
m_cat_validator
!=
nullptr
and
m_cat_validator
->
m_keys
.
size
()
==
1
)
{
if
(
m_index
==
nullptr
and
m_cat_validator
!=
nullptr
)
m_index
=
new
category_index
(
this
);
for
(;;)
{
std
::
string
result
=
generator
(
static_cast
<
int
>
(
m_last_unique_num
++
));
if
(
m_index
->
find_by_value
({{
id_tag
,
result
}})
==
nullptr
)
break
;
result
=
generator
(
static_cast
<
int
>
(
m_last_unique_num
++
));
}
}
else
{
for
(;;)
{
if
(
not
exists
(
key
(
id_tag
)
==
result
))
break
;
if
(
exists
(
key
(
id_tag
)
==
result
))
continue
;
result
=
generator
(
static_cast
<
int
>
(
m_last_unique_num
++
));
}
}
return
result
;
}
}
void
category
::
update_value
(
const
std
::
vector
<
row_handle
>
&
rows
,
std
::
string_view
tag
,
std
::
string_view
value
)
...
...
src/dictionary_parser.cpp
View file @
1bcb26ba
...
...
@@ -481,4 +481,11 @@ validator parse_dictionary(std::string_view name, std::istream &is)
return
result
;
}
void
extend_dictionary
(
validator
&
v
,
std
::
istream
&
is
)
{
file
f
;
dictionary_parser
p
(
v
,
is
,
f
);
p
.
load_dictionary
();
}
}
// namespace cif
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