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
d3bbd082
Commit
d3bbd082
authored
Sep 09, 2011
by
Jesse Beder
Browse files
Added append()
parent
4f8680b5
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
37 additions
and
1 deletion
+37
-1
include/yaml-cpp/value/detail/node.h
include/yaml-cpp/value/detail/node.h
+2
-0
include/yaml-cpp/value/detail/node_data.h
include/yaml-cpp/value/detail/node_data.h
+2
-0
include/yaml-cpp/value/detail/node_ref.h
include/yaml-cpp/value/detail/node_ref.h
+2
-0
include/yaml-cpp/value/impl.h
include/yaml-cpp/value/impl.h
+13
-0
include/yaml-cpp/value/value.h
include/yaml-cpp/value/value.h
+4
-0
src/value/detail/node_data.cpp
src/value/detail/node_data.cpp
+9
-0
util/value.cpp
util/value.cpp
+5
-1
No files found.
include/yaml-cpp/value/detail/node.h
View file @
d3bbd082
...
@@ -32,6 +32,8 @@ namespace YAML
...
@@ -32,6 +32,8 @@ namespace YAML
void
set_type
(
ValueType
::
value
type
)
{
m_pRef
->
set_type
(
type
);
}
void
set_type
(
ValueType
::
value
type
)
{
m_pRef
->
set_type
(
type
);
}
void
set_null
()
{
m_pRef
->
set_null
();
}
void
set_null
()
{
m_pRef
->
set_null
();
}
void
set_scalar
(
const
std
::
string
&
scalar
)
{
m_pRef
->
set_scalar
(
scalar
);
}
void
set_scalar
(
const
std
::
string
&
scalar
)
{
m_pRef
->
set_scalar
(
scalar
);
}
void
append
(
node
&
node
,
shared_memory_holder
pMemory
)
{
m_pRef
->
append
(
node
,
pMemory
);
}
// indexing
// indexing
template
<
typename
Key
>
node
&
get
(
const
Key
&
key
,
shared_memory_holder
pMemory
)
const
{
return
static_cast
<
const
node_ref
&>
(
*
m_pRef
).
get
(
key
,
pMemory
);
}
template
<
typename
Key
>
node
&
get
(
const
Key
&
key
,
shared_memory_holder
pMemory
)
const
{
return
static_cast
<
const
node_ref
&>
(
*
m_pRef
).
get
(
key
,
pMemory
);
}
...
...
include/yaml-cpp/value/detail/node_data.h
View file @
d3bbd082
...
@@ -30,6 +30,8 @@ namespace YAML
...
@@ -30,6 +30,8 @@ namespace YAML
ValueType
::
value
type
()
const
{
return
m_isDefined
?
m_type
:
ValueType
::
Undefined
;
}
ValueType
::
value
type
()
const
{
return
m_isDefined
?
m_type
:
ValueType
::
Undefined
;
}
const
std
::
string
&
scalar
()
const
{
return
m_scalar
;
}
const
std
::
string
&
scalar
()
const
{
return
m_scalar
;
}
void
append
(
node
&
node
,
shared_memory_holder
pMemory
);
// indexing
// indexing
template
<
typename
Key
>
node
&
get
(
const
Key
&
key
,
shared_memory_holder
pMemory
)
const
;
template
<
typename
Key
>
node
&
get
(
const
Key
&
key
,
shared_memory_holder
pMemory
)
const
;
template
<
typename
Key
>
node
&
get
(
const
Key
&
key
,
shared_memory_holder
pMemory
);
template
<
typename
Key
>
node
&
get
(
const
Key
&
key
,
shared_memory_holder
pMemory
);
...
...
include/yaml-cpp/value/detail/node_ref.h
View file @
d3bbd082
...
@@ -30,6 +30,8 @@ namespace YAML
...
@@ -30,6 +30,8 @@ namespace YAML
void
set_null
()
{
m_pData
->
set_null
();
}
void
set_null
()
{
m_pData
->
set_null
();
}
void
set_scalar
(
const
std
::
string
&
scalar
)
{
m_pData
->
set_scalar
(
scalar
);
}
void
set_scalar
(
const
std
::
string
&
scalar
)
{
m_pData
->
set_scalar
(
scalar
);
}
void
append
(
node
&
node
,
shared_memory_holder
pMemory
)
{
m_pData
->
append
(
node
,
pMemory
);
}
// indexing
// indexing
template
<
typename
Key
>
node
&
get
(
const
Key
&
key
,
shared_memory_holder
pMemory
)
const
{
return
static_cast
<
const
node_data
&>
(
*
m_pData
).
get
(
key
,
pMemory
);
}
template
<
typename
Key
>
node
&
get
(
const
Key
&
key
,
shared_memory_holder
pMemory
)
const
{
return
static_cast
<
const
node_data
&>
(
*
m_pData
).
get
(
key
,
pMemory
);
}
template
<
typename
Key
>
node
&
get
(
const
Key
&
key
,
shared_memory_holder
pMemory
)
{
return
m_pData
->
get
(
key
,
pMemory
);
}
template
<
typename
Key
>
node
&
get
(
const
Key
&
key
,
shared_memory_holder
pMemory
)
{
return
m_pData
->
get
(
key
,
pMemory
);
}
...
...
include/yaml-cpp/value/impl.h
View file @
d3bbd082
...
@@ -150,6 +150,19 @@ namespace YAML
...
@@ -150,6 +150,19 @@ namespace YAML
return
iterator
();
return
iterator
();
}
}
// sequence
template
<
typename
T
>
inline
void
Value
::
append
(
const
T
&
rhs
)
{
append
(
Value
(
rhs
));
}
inline
void
Value
::
append
(
const
Value
&
rhs
)
{
m_pNode
->
append
(
*
rhs
.
m_pNode
,
m_pMemory
);
m_pMemory
->
merge
(
*
rhs
.
m_pMemory
);
}
// indexing
// indexing
template
<
typename
Key
>
template
<
typename
Key
>
inline
const
Value
Value
::
operator
[](
const
Key
&
key
)
const
inline
const
Value
Value
::
operator
[](
const
Key
&
key
)
const
...
...
include/yaml-cpp/value/value.h
View file @
d3bbd082
...
@@ -45,6 +45,10 @@ namespace YAML
...
@@ -45,6 +45,10 @@ namespace YAML
const_iterator
end
()
const
;
const_iterator
end
()
const
;
iterator
end
();
iterator
end
();
// sequence
template
<
typename
T
>
void
append
(
const
T
&
rhs
);
void
append
(
const
Value
&
rhs
);
// indexing
// indexing
template
<
typename
Key
>
const
Value
operator
[](
const
Key
&
key
)
const
;
template
<
typename
Key
>
const
Value
operator
[](
const
Key
&
key
)
const
;
template
<
typename
Key
>
Value
operator
[](
const
Key
&
key
);
template
<
typename
Key
>
Value
operator
[](
const
Key
&
key
);
...
...
src/value/detail/node_data.cpp
View file @
d3bbd082
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#include "yaml-cpp/value/detail/memory.h"
#include "yaml-cpp/value/detail/memory.h"
#include "yaml-cpp/value/detail/node.h"
#include "yaml-cpp/value/detail/node.h"
#include <sstream>
#include <sstream>
#include <stdexcept>
namespace
YAML
namespace
YAML
{
{
...
@@ -57,6 +58,14 @@ namespace YAML
...
@@ -57,6 +58,14 @@ namespace YAML
m_scalar
=
scalar
;
m_scalar
=
scalar
;
}
}
void
node_data
::
append
(
node
&
node
,
shared_memory_holder
/* pMemory */
)
{
if
(
m_type
!=
ValueType
::
Sequence
)
throw
std
::
runtime_error
(
"Can't append to a non-sequence node"
);
m_sequence
.
push_back
(
&
node
);
}
// indexing
// indexing
node
&
node_data
::
get
(
node
&
key
,
shared_memory_holder
pMemory
)
const
node
&
node_data
::
get
(
node
&
key
,
shared_memory_holder
pMemory
)
const
{
{
...
...
util/value.cpp
View file @
d3bbd082
...
@@ -22,7 +22,11 @@ int main()
...
@@ -22,7 +22,11 @@ int main()
value
[
"this"
]
=
value
;
value
[
"this"
]
=
value
;
value
[
"this"
][
"change"
]
=
value
;
value
[
"this"
][
"change"
]
=
value
;
value
[
"this"
][
"change"
]
=
5
;
value
[
"seq"
]
=
YAML
::
Value
(
YAML
::
ValueType
::
Sequence
);
value
[
"seq"
].
append
(
2
);
value
[
"seq"
].
append
(
3
);
value
[
"seq"
].
append
(
"five"
);
return
0
;
return
0
;
}
}
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