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
8dcd96db
Commit
8dcd96db
authored
Sep 13, 2011
by
beder
Browse files
Added tags to Node
parent
535f81a3
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
35 additions
and
7 deletions
+35
-7
include/yaml-cpp/node/convert.h
include/yaml-cpp/node/convert.h
+2
-2
include/yaml-cpp/node/detail/node.h
include/yaml-cpp/node/detail/node.h
+5
-0
include/yaml-cpp/node/detail/node_data.h
include/yaml-cpp/node/detail/node_data.h
+3
-0
include/yaml-cpp/node/detail/node_ref.h
include/yaml-cpp/node/detail/node_ref.h
+2
-0
include/yaml-cpp/node/impl.h
include/yaml-cpp/node/impl.h
+13
-2
include/yaml-cpp/node/node.h
include/yaml-cpp/node/node.h
+5
-3
src/node/detail/node_data.cpp
src/node/detail/node_data.cpp
+5
-0
No files found.
include/yaml-cpp/node/convert.h
View file @
8dcd96db
...
...
@@ -26,7 +26,7 @@ namespace YAML
static
bool
decode
(
const
Node
&
node
,
std
::
string
&
rhs
)
{
if
(
node
.
Type
()
!=
NodeType
::
Scalar
)
return
false
;
rhs
=
node
.
s
calar
();
rhs
=
node
.
S
calar
();
return
true
;
}
};
...
...
@@ -54,7 +54,7 @@ namespace YAML
static bool decode(const Node& node, type& rhs) {\
if(node.Type() != NodeType::Scalar)\
return false;\
std::stringstream stream(node.
s
calar());\
std::stringstream stream(node.
S
calar());\
stream >> rhs;\
return !!stream;\
}\
...
...
include/yaml-cpp/node/detail/node.h
View file @
8dcd96db
...
...
@@ -29,6 +29,7 @@ namespace YAML
NodeType
::
value
type
()
const
{
return
m_pRef
->
type
();
}
const
std
::
string
&
scalar
()
const
{
return
m_pRef
->
scalar
();
}
const
std
::
string
&
tag
()
const
{
return
m_pRef
->
tag
();
}
void
mark_defined
()
{
if
(
is_defined
())
...
...
@@ -71,6 +72,10 @@ namespace YAML
mark_defined
();
m_pRef
->
set_scalar
(
scalar
);
}
void
set_tag
(
const
std
::
string
&
tag
)
{
mark_defined
();
m_pRef
->
set_tag
(
tag
);
}
// size/iterator
std
::
size_t
size
()
const
{
return
m_pRef
->
size
();
}
...
...
include/yaml-cpp/node/detail/node_data.h
View file @
8dcd96db
...
...
@@ -26,12 +26,14 @@ namespace YAML
void
mark_defined
();
void
set_type
(
NodeType
::
value
type
);
void
set_tag
(
const
std
::
string
&
tag
);
void
set_null
();
void
set_scalar
(
const
std
::
string
&
scalar
);
bool
is_defined
()
const
{
return
m_isDefined
;
}
NodeType
::
value
type
()
const
{
return
m_isDefined
?
m_type
:
NodeType
::
Undefined
;
}
const
std
::
string
&
scalar
()
const
{
return
m_scalar
;
}
const
std
::
string
&
tag
()
const
{
return
m_tag
;
}
// size/iterator
std
::
size_t
size
()
const
;
...
...
@@ -78,6 +80,7 @@ namespace YAML
private:
bool
m_isDefined
;
NodeType
::
value
m_type
;
std
::
string
m_tag
;
// scalar
std
::
string
m_scalar
;
...
...
include/yaml-cpp/node/detail/node_ref.h
View file @
8dcd96db
...
...
@@ -24,11 +24,13 @@ namespace YAML
bool
is_defined
()
const
{
return
m_pData
->
is_defined
();
}
NodeType
::
value
type
()
const
{
return
m_pData
->
type
();
}
const
std
::
string
&
scalar
()
const
{
return
m_pData
->
scalar
();
}
const
std
::
string
&
tag
()
const
{
return
m_pData
->
tag
();
}
void
mark_defined
()
{
m_pData
->
mark_defined
();
}
void
set_data
(
const
node_ref
&
rhs
)
{
m_pData
=
rhs
.
m_pData
;
}
void
set_type
(
NodeType
::
value
type
)
{
m_pData
->
set_type
(
type
);
}
void
set_tag
(
const
std
::
string
&
tag
)
{
m_pData
->
set_tag
(
tag
);
}
void
set_null
()
{
m_pData
->
set_null
();
}
void
set_scalar
(
const
std
::
string
&
scalar
)
{
m_pData
->
set_scalar
(
scalar
);
}
...
...
include/yaml-cpp/node/impl.h
View file @
8dcd96db
...
...
@@ -73,14 +73,25 @@ namespace YAML
{
if
(
Type
()
!=
NodeType
::
Scalar
)
throw
std
::
runtime_error
(
"Unable to convert to string, not a scalar"
);
return
s
calar
();
return
S
calar
();
}
inline
const
std
::
string
&
Node
::
s
calar
()
const
inline
const
std
::
string
&
Node
::
S
calar
()
const
{
return
m_pNode
?
m_pNode
->
scalar
()
:
detail
::
node_data
::
empty_scalar
;
}
inline
const
std
::
string
&
Node
::
Tag
()
const
{
return
m_pNode
?
m_pNode
->
tag
()
:
detail
::
node_data
::
empty_scalar
;
}
inline
void
Node
::
SetTag
(
const
std
::
string
&
tag
)
{
EnsureNodeExists
();
m_pNode
->
set_tag
(
tag
);
}
// assignment
inline
bool
Node
::
is
(
const
Node
&
rhs
)
const
{
...
...
include/yaml-cpp/node/node.h
View file @
8dcd96db
...
...
@@ -32,7 +32,9 @@ namespace YAML
// access
template
<
typename
T
>
const
T
as
()
const
;
const
std
::
string
&
scalar
()
const
;
const
std
::
string
&
Scalar
()
const
;
const
std
::
string
&
Tag
()
const
;
void
SetTag
(
const
std
::
string
&
tag
);
// assignment
bool
is
(
const
Node
&
rhs
)
const
;
...
...
src/node/detail/node_data.cpp
View file @
8dcd96db
...
...
@@ -54,6 +54,11 @@ namespace YAML
}
}
void
node_data
::
set_tag
(
const
std
::
string
&
tag
)
{
m_tag
=
tag
;
}
void
node_data
::
set_null
()
{
m_isDefined
=
true
;
...
...
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