Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
yaml-cpp
Commits
6f7ead51
Unverified
Commit
6f7ead51
authored
Apr 07, 2020
by
Maxim Okhotskiy
Committed by
GitHub
Apr 07, 2020
Browse files
Maintain order of nodes in sequences (#668)
parent
cf93f4c5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletion
+11
-1
include/yaml-cpp/node/detail/node.h
include/yaml-cpp/node/detail/node.h
+10
-1
src/node_data.cpp
src/node_data.cpp
+1
-0
No files found.
include/yaml-cpp/node/detail/node.h
View file @
6f7ead51
...
@@ -13,10 +13,16 @@
...
@@ -13,10 +13,16 @@
#include "yaml-cpp/node/ptr.h"
#include "yaml-cpp/node/ptr.h"
#include "yaml-cpp/node/type.h"
#include "yaml-cpp/node/type.h"
#include <set>
#include <set>
#include <atomic>
namespace
YAML
{
namespace
YAML
{
namespace
detail
{
namespace
detail
{
class
node
{
class
node
{
private:
struct
less
{
bool
operator
()(
const
node
*
l
,
const
node
*
r
)
{
return
l
->
m_index
<
r
->
m_index
;}
};
public:
public:
node
()
:
m_pRef
(
new
node_ref
),
m_dependencies
{}
{}
node
()
:
m_pRef
(
new
node_ref
),
m_dependencies
{}
{}
node
(
const
node
&
)
=
delete
;
node
(
const
node
&
)
=
delete
;
...
@@ -108,6 +114,7 @@ class node {
...
@@ -108,6 +114,7 @@ class node {
void
push_back
(
node
&
input
,
shared_memory_holder
pMemory
)
{
void
push_back
(
node
&
input
,
shared_memory_holder
pMemory
)
{
m_pRef
->
push_back
(
input
,
pMemory
);
m_pRef
->
push_back
(
input
,
pMemory
);
input
.
add_dependency
(
*
this
);
input
.
add_dependency
(
*
this
);
m_index
=
m_amount
.
fetch_add
(
1
);
}
}
void
insert
(
node
&
key
,
node
&
value
,
shared_memory_holder
pMemory
)
{
void
insert
(
node
&
key
,
node
&
value
,
shared_memory_holder
pMemory
)
{
m_pRef
->
insert
(
key
,
value
,
pMemory
);
m_pRef
->
insert
(
key
,
value
,
pMemory
);
...
@@ -159,8 +166,10 @@ class node {
...
@@ -159,8 +166,10 @@ class node {
private:
private:
shared_node_ref
m_pRef
;
shared_node_ref
m_pRef
;
using
nodes
=
std
::
set
<
node
*>
;
using
nodes
=
std
::
set
<
node
*
,
less
>
;
nodes
m_dependencies
;
nodes
m_dependencies
;
size_t
m_index
;
static
std
::
atomic
<
size_t
>
m_amount
;
};
};
}
// namespace detail
}
// namespace detail
}
// namespace YAML
}
// namespace YAML
...
...
src/node_data.cpp
View file @
6f7ead51
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
namespace
YAML
{
namespace
YAML
{
namespace
detail
{
namespace
detail
{
std
::
atomic
<
size_t
>
node
::
m_amount
{
0
};
const
std
::
string
&
node_data
::
empty_scalar
()
{
const
std
::
string
&
node_data
::
empty_scalar
()
{
static
const
std
::
string
svalue
;
static
const
std
::
string
svalue
;
...
...
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