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
fb2b1e98
Unverified
Commit
fb2b1e98
authored
Jan 22, 2024
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed serious bug in emplace of both datablock and file.
parent
5d4534fa
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
26 deletions
+30
-26
src/datablock.cpp
+26
-15
src/file.cpp
+4
-11
No files found.
src/datablock.cpp
View file @
fb2b1e98
...
...
@@ -143,13 +143,6 @@ std::tuple<datablock::iterator, bool> datablock::emplace(std::string_view name)
if
(
iequals
(
name
,
i
->
name
()))
{
is_new
=
false
;
if
(
i
!=
begin
())
{
auto
n
=
std
::
next
(
i
);
splice
(
begin
(),
*
this
,
i
,
n
);
}
break
;
}
...
...
@@ -158,12 +151,12 @@ std::tuple<datablock::iterator, bool> datablock::emplace(std::string_view name)
if
(
is_new
)
{
auto
&
c
=
emplace_back
(
name
);
c
.
set_validator
(
m_validator
,
*
this
);
i
=
insert
(
end
(),
{
name
}
);
i
->
set_validator
(
m_validator
,
*
this
);
}
assert
(
end
()
!=
begin
());
return
std
::
make_tuple
(
std
::
prev
(
end
())
,
is_new
);
assert
(
i
!=
end
());
return
std
::
make_tuple
(
i
,
is_new
);
}
std
::
vector
<
std
::
string
>
datablock
::
get_tag_order
()
const
...
...
@@ -171,7 +164,6 @@ std::vector<std::string> datablock::get_tag_order() const
std
::
vector
<
std
::
string
>
result
;
// for entry and audit_conform on top
auto
ci
=
find_if
(
begin
(),
end
(),
[](
const
category
&
cat
)
{
return
cat
.
name
()
==
"entry"
;
});
if
(
ci
!=
end
())
...
...
@@ -253,13 +245,32 @@ void datablock::write(std::ostream &os) const
{
// If the dictionary declares an audit_conform category, put it in,
// but only if it does not exist already!
if
(
get
(
"audit_conform"
)
==
nullptr
and
m_validator
->
get_validator_for_category
(
"audit_conform"
)
!=
nullptr
)
if
(
m_validator
->
get_validator_for_category
(
"audit_conform"
)
!=
nullptr
)
{
auto
*
audit_conform
=
get
(
"audit_conform"
);
if
(
audit_conform
==
nullptr
or
audit_conform
->
size
()
!=
1
)
// There should be one entry here, I guess
audit_conform
=
nullptr
;
else
{
// And the name and version should be filled in of course
auto
&
e
=
audit_conform
->
front
();
if
(
e
[
"dict_name"
].
empty
()
or
e
[
"dict_version"
].
empty
())
audit_conform
=
nullptr
;
}
if
(
not
audit_conform
)
{
category
auditConform
(
"audit_conform"
);
auditConform
.
emplace
({
{
"dict_name"
,
m_validator
->
name
()
},
{
"dict_version"
,
m_validator
->
version
()
}
});
// clang-format off
auditConform
.
emplace
({
{
"dict_name"
,
m_validator
->
name
()
},
{
"dict_version"
,
m_validator
->
version
()
}
});
// clang-format on
auditConform
.
write
(
os
);
}
}
// base order on parent child relationships, parents first
...
...
src/file.cpp
View file @
fb2b1e98
...
...
@@ -158,13 +158,6 @@ std::tuple<file::iterator, bool> file::emplace(std::string_view name)
if
(
iequals
(
name
,
i
->
name
()))
{
is_new
=
false
;
if
(
i
!=
begin
())
{
auto
n
=
std
::
next
(
i
);
splice
(
begin
(),
*
this
,
i
,
n
);
}
break
;
}
...
...
@@ -173,12 +166,12 @@ std::tuple<file::iterator, bool> file::emplace(std::string_view name)
if
(
is_new
)
{
auto
&
db
=
emplace_back
(
name
);
db
.
set_validator
(
m_validator
);
i
=
insert
(
end
(),
{
name
}
);
i
->
set_validator
(
m_validator
);
}
assert
(
begin
()
!=
end
());
return
std
::
make_tuple
(
std
::
prev
(
end
())
,
is_new
);
assert
(
i
!=
end
());
return
std
::
make_tuple
(
i
,
is_new
);
}
void
file
::
load
(
const
std
::
filesystem
::
path
&
p
)
...
...
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