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
a530630f
Commit
a530630f
authored
Sep 07, 2011
by
Jesse Beder
Browse files
Started implementing node_data
parent
00e4a56d
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
68 additions
and
6 deletions
+68
-6
CMakeLists.txt
CMakeLists.txt
+5
-1
include/yaml-cpp/value/detail/node.h
include/yaml-cpp/value/detail/node.h
+7
-0
include/yaml-cpp/value/detail/node_data.h
include/yaml-cpp/value/detail/node_data.h
+22
-1
include/yaml-cpp/value/impl.h
include/yaml-cpp/value/impl.h
+6
-0
include/yaml-cpp/value/type.h
include/yaml-cpp/value/type.h
+14
-0
include/yaml-cpp/value/value.h
include/yaml-cpp/value/value.h
+2
-3
src/value/detail/node_data.cpp
src/value/detail/node_data.cpp
+11
-0
util/value.cpp
util/value.cpp
+1
-1
No files found.
CMakeLists.txt
View file @
a530630f
...
@@ -55,7 +55,11 @@ option(MSVC_STHREADED_RT "MSVC: Build with single-threaded static runtime libs (
...
@@ -55,7 +55,11 @@ option(MSVC_STHREADED_RT "MSVC: Build with single-threaded static runtime libs (
###
###
### Sources, headers, directories and libs
### Sources, headers, directories and libs
###
###
file
(
GLOB sources
"src/[a-zA-Z]*.cpp"
)
file
(
GLOB sources
"src/[a-zA-Z]*.cpp"
"src/value/[a-zA-Z]*.cpp"
"src/value/detail/[a-zA-Z]*.cpp"
)
file
(
GLOB public_headers
file
(
GLOB public_headers
"include/yaml-cpp/[a-zA-Z]*.h"
"include/yaml-cpp/[a-zA-Z]*.h"
"include/yaml-cpp/value/[a-zA-Z]*.h"
"include/yaml-cpp/value/[a-zA-Z]*.h"
...
...
include/yaml-cpp/value/detail/node.h
View file @
a530630f
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
#include "yaml-cpp/dll.h"
#include "yaml-cpp/dll.h"
#include "yaml-cpp/value/type.h"
#include "yaml-cpp/value/ptr.h"
#include "yaml-cpp/value/ptr.h"
#include "yaml-cpp/value/detail/node_data.h"
#include "yaml-cpp/value/detail/node_data.h"
...
@@ -19,6 +20,7 @@ namespace YAML
...
@@ -19,6 +20,7 @@ namespace YAML
public:
public:
node
();
node
();
ValueType
::
value
type
()
const
;
void
assign_data
(
const
node
&
rhs
);
void
assign_data
(
const
node
&
rhs
);
void
set_scalar
(
const
std
::
string
&
data
);
void
set_scalar
(
const
std
::
string
&
data
);
...
@@ -30,6 +32,11 @@ namespace YAML
...
@@ -30,6 +32,11 @@ namespace YAML
{
{
}
}
inline
ValueType
::
value
node
::
type
()
const
{
return
m_pData
?
m_pData
->
type
()
:
ValueType
::
Null
;
}
inline
void
node
::
assign_data
(
const
node
&
rhs
)
inline
void
node
::
assign_data
(
const
node
&
rhs
)
{
{
m_pData
=
rhs
.
m_pData
;
m_pData
=
rhs
.
m_pData
;
...
...
include/yaml-cpp/value/detail/node_data.h
View file @
a530630f
...
@@ -7,7 +7,10 @@
...
@@ -7,7 +7,10 @@
#include "yaml-cpp/dll.h"
#include "yaml-cpp/dll.h"
#include "yaml-cpp/value/type.h"
#include "yaml-cpp/value/ptr.h"
#include "yaml-cpp/value/ptr.h"
#include <pair>
#include <vector>
namespace
YAML
namespace
YAML
{
{
...
@@ -16,7 +19,25 @@ namespace YAML
...
@@ -16,7 +19,25 @@ namespace YAML
class
node_data
class
node_data
{
{
public:
public:
explicit
node_data
(
const
std
::
string
&
data
)
{}
explicit
node_data
(
const
std
::
string
&
scalar
);
ValueType
::
value
type
()
const
{
return
m_type
;
}
const
std
::
string
scalar
()
const
{
return
m_data
;
}
private:
ValueType
::
value
m_type
;
// scalar
std
::
string
m_scalar
;
// sequence
typedef
std
::
vector
<
shared_node
>
node_seq
;
node_seq
m_sequence
;
// map
typedef
std
::
pair
<
shared_node
,
shared_node
>
kv_pair
;
typedef
std
::
vector
<
kv_pair
>
node_map
;
node_map
m_map
;
};
};
}
}
}
}
...
...
include/yaml-cpp/value/impl.h
View file @
a530630f
...
@@ -14,6 +14,7 @@ namespace YAML
...
@@ -14,6 +14,7 @@ namespace YAML
{
{
inline
Value
::
Value
()
:
m_pMemory
(
new
detail
::
memory_holder
)
inline
Value
::
Value
()
:
m_pMemory
(
new
detail
::
memory_holder
)
{
{
EnsureNodeExists
();
}
}
template
<
typename
T
>
template
<
typename
T
>
...
@@ -30,6 +31,11 @@ namespace YAML
...
@@ -30,6 +31,11 @@ namespace YAML
{
{
}
}
inline
ValueType
::
value
Value
::
Type
()
const
{
return
m_pNode
?
m_pNode
->
type
()
:
ValueType
::
Undefined
;
}
// access
// access
template
<
typename
T
>
template
<
typename
T
>
inline
const
T
Value
::
as
()
const
inline
const
T
Value
::
as
()
const
...
...
include/yaml-cpp/value/type.h
0 → 100644
View file @
a530630f
#ifndef VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once
#endif
namespace
YAML
{
struct
ValueType
{
enum
value
{
Undefined
,
Null
,
Scalar
,
Sequence
,
Map
};
};
}
#endif // VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/value/value.h
View file @
a530630f
...
@@ -7,14 +7,13 @@
...
@@ -7,14 +7,13 @@
#include "yaml-cpp/dll.h"
#include "yaml-cpp/dll.h"
#include "yaml-cpp/value/ptr.h"
#include "yaml-cpp/value/iterator.h"
#include "yaml-cpp/value/iterator.h"
#include "yaml-cpp/value/ptr.h"
#include "yaml-cpp/value/type.h"
#include <stdexcept>
#include <stdexcept>
namespace
YAML
namespace
YAML
{
{
struct
ValueType
{
enum
value
{
Undefined
,
Null
,
Scalar
,
Sequence
,
Map
};
};
class
Value
class
Value
{
{
public:
public:
...
...
src/value/detail/node_data.cpp
0 → 100644
View file @
a530630f
#include "yaml-cpp/value/detail/node_data.h"
namespace
YAML
{
namespace
detail
{
node_data
::
node_data
(
const
std
::
string
&
scalar
)
:
m_type
(
ValueType
::
Scalar
),
m_scalar
(
scalar
)
{
}
}
}
util/value.cpp
View file @
a530630f
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
int
main
()
int
main
()
{
{
YAML
::
Value
value
;
YAML
::
Value
value
;
value
=
"Hello
"
;
value
[
"key"
]
=
"value
"
;
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