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
1723523c
Commit
1723523c
authored
Jan 20, 2012
by
Jesse Beder
Browse files
Removed the new API from the default branch
parent
d772361f
Changes
36
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
3 additions
and
1648 deletions
+3
-1648
CMakeLists.txt
CMakeLists.txt
+3
-31
include/yaml-cpp/node/convert.h
include/yaml-cpp/node/convert.h
+0
-188
include/yaml-cpp/node/detail/bool_type.h
include/yaml-cpp/node/detail/bool_type.h
+0
-26
include/yaml-cpp/node/detail/impl.h
include/yaml-cpp/node/detail/impl.h
+0
-142
include/yaml-cpp/node/detail/iterator.h
include/yaml-cpp/node/detail/iterator.h
+0
-62
include/yaml-cpp/node/detail/iterator_fwd.h
include/yaml-cpp/node/detail/iterator_fwd.h
+0
-27
include/yaml-cpp/node/detail/memory.h
include/yaml-cpp/node/detail/memory.h
+0
-39
include/yaml-cpp/node/detail/node.h
include/yaml-cpp/node/detail/node.h
+0
-126
include/yaml-cpp/node/detail/node_data.h
include/yaml-cpp/node/detail/node_data.h
+0
-105
include/yaml-cpp/node/detail/node_iterator.h
include/yaml-cpp/node/detail/node_iterator.h
+0
-139
include/yaml-cpp/node/detail/node_ref.h
include/yaml-cpp/node/detail/node_ref.h
+0
-65
include/yaml-cpp/node/emit.h
include/yaml-cpp/node/emit.h
+0
-23
include/yaml-cpp/node/impl.h
include/yaml-cpp/node/impl.h
+0
-354
include/yaml-cpp/node/iterator.h
include/yaml-cpp/node/iterator.h
+0
-28
include/yaml-cpp/node/node.h
include/yaml-cpp/node/node.h
+0
-110
include/yaml-cpp/node/parse.h
include/yaml-cpp/node/parse.h
+0
-28
include/yaml-cpp/node/ptr.h
include/yaml-cpp/node/ptr.h
+0
-29
include/yaml-cpp/node/type.h
include/yaml-cpp/node/type.h
+0
-14
src/node/convert.cpp
src/node/convert.cpp
+0
-83
src/node/detail/memory.cpp
src/node/detail/memory.cpp
+0
-29
No files found.
CMakeLists.txt
View file @
1723523c
...
...
@@ -35,7 +35,6 @@ enable_testing()
## Project stuff
option
(
YAML_CPP_BUILD_TOOLS
"Enable testing and parse tools"
ON
)
option
(
YAML_CPP_BUILD_CONTRIB
"Enable contrib stuff in library"
ON
)
option
(
YAML_CPP_BUILD_OLD_API
"Enable building the old API"
ON
)
## Build options
# --> General
...
...
@@ -52,50 +51,23 @@ option(APPLE_UNIVERSAL_BIN "Apple: Build universal binary" OFF)
option
(
MSVC_SHARED_RT
"MSVC: Build with shared runtime libs (/MD)"
ON
)
option
(
MSVC_STHREADED_RT
"MSVC: Build with single-threaded static runtime libs (/ML until VS .NET 2003)"
OFF
)
###
### Configure the main header
###
if
(
YAML_CPP_BUILD_OLD_API
)
set
(
API_DEFINE
"#define YAML_CPP_OLD_API"
)
endif
()
configure_file
(
${
YAML_CPP_SOURCE_DIR
}
/include/yaml-cpp/yaml.h.cmake
${
YAML_CPP_SOURCE_DIR
}
/include/yaml-cpp/yaml.h @ONLY
)
###
### Sources, headers, directories and libs
###
set
(
header_directory
"include/yaml-cpp/"
)
file
(
GLOB common_sources
"src/[a-zA-Z]*.cpp"
)
file
(
GLOB new_api_sources
"src/node/[a-zA-Z]*.cpp"
"src/node/detail/[a-zA-Z]*.cpp"
)
file
(
GLOB old_api_sources
"src/old-api/[a-zA-Z]*.cpp"
)
file
(
GLOB common_public_headers
"include/yaml-cpp/[a-zA-Z]*.h"
)
file
(
GLOB new_api_public_headers
"include/yaml-cpp/node/[a-zA-Z]*.h"
"include/yaml-cpp/node/detail/[a-zA-Z]*.h"
)
file
(
GLOB old_api_public_headers
"include/yaml-cpp/old-api/[a-zA-Z]*.h"
)
file
(
GLOB common_private_headers
"src/[a-zA-Z]*.h"
)
file
(
GLOB new_api_private_headers
"src/node/[a-zA-Z]*.h"
)
file
(
GLOB old_api_private_headers
"src/old-api/[a-zA-Z]*.h"
)
if
(
YAML_CPP_BUILD_OLD_API
)
list
(
APPEND sources
${
common_sources
}
${
old_api_sources
}
)
list
(
APPEND public_headers
${
common_public_headers
}
${
old_api_public_headers
}
)
list
(
APPEND private_headers
${
common_private_headers
}
${
old_api_private_headers
}
)
add_definitions
(
-DYAML_CPP_OLD_API
)
else
()
find_package
(
Boost REQUIRED
)
include_directories
(
${
Boost_INCLUDE_DIRS
}
)
list
(
APPEND sources
${
common_sources
}
${
new_api_sources
}
)
list
(
APPEND public_headers
${
common_public_headers
}
${
new_api_public_headers
}
)
list
(
APPEND private_headers
${
common_private_headers
}
${
new_api_private_headers
}
)
endif
()
list
(
APPEND sources
${
common_sources
}
${
old_api_sources
}
)
list
(
APPEND public_headers
${
common_public_headers
}
${
old_api_public_headers
}
)
list
(
APPEND private_headers
${
common_private_headers
}
${
old_api_private_headers
}
)
if
(
YAML_CPP_BUILD_CONTRIB
)
file
(
GLOB contrib_sources
"src/contrib/[a-zA-Z]*.cpp"
)
...
...
include/yaml-cpp/node/convert.h
deleted
100644 → 0
View file @
d772361f
#ifndef NODE_CONVERT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define NODE_CONVERT_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
#include "yaml-cpp/node/node.h"
#include "yaml-cpp/node/iterator.h"
#include "yaml-cpp/null.h"
#include <limits>
#include <list>
#include <map>
#include <sstream>
#include <vector>
namespace
YAML
{
namespace
conversion
{
inline
bool
IsInfinity
(
const
std
::
string
&
input
)
{
return
input
==
".inf"
||
input
==
".Inf"
||
input
==
".INF"
||
input
==
"+.inf"
||
input
==
"+.Inf"
||
input
==
"+.INF"
;
}
inline
bool
IsNegativeInfinity
(
const
std
::
string
&
input
)
{
return
input
==
"-.inf"
||
input
==
"-.Inf"
||
input
==
"-.INF"
;
}
inline
bool
IsNaN
(
const
std
::
string
&
input
)
{
return
input
==
".nan"
||
input
==
".NaN"
||
input
==
".NAN"
;
}
}
// std::string
template
<
>
struct
convert
<
std
::
string
>
{
static
Node
encode
(
const
std
::
string
&
rhs
)
{
return
Node
(
rhs
);
}
static
bool
decode
(
const
Node
&
node
,
std
::
string
&
rhs
)
{
if
(
!
node
.
IsScalar
())
return
false
;
rhs
=
node
.
Scalar
();
return
true
;
}
};
template
<
>
struct
convert
<
_Null
>
{
static
Node
encode
(
const
_Null
&
/* rhs */
)
{
return
Node
();
}
static
bool
decode
(
const
Node
&
node
,
_Null
&
/* rhs */
)
{
return
node
.
IsNull
();
}
};
#define YAML_DEFINE_CONVERT_STREAMABLE(type)\
template<>\
struct convert<type> {\
static Node encode(const type& rhs) {\
std::stringstream stream;\
stream << rhs;\
return Node(stream.str());\
}\
\
static bool decode(const Node& node, type& rhs) {\
if(node.Type() != NodeType::Scalar)\
return false;\
const std::string& input = node.Scalar();\
std::stringstream stream(input);\
stream.unsetf(std::ios::dec);\
if((stream >> rhs) && (stream >> std::ws).eof())\
return true;\
if(std::numeric_limits<type>::has_infinity) {\
if(conversion::IsInfinity(input)) {\
rhs = std::numeric_limits<type>::infinity();\
return true;\
} else if(conversion::IsNegativeInfinity(input)) {\
rhs = -std::numeric_limits<type>::infinity();\
return true;\
}\
}\
\
if(std::numeric_limits<type>::has_quiet_NaN && conversion::IsNaN(input)) {\
rhs = std::numeric_limits<type>::quiet_NaN();\
return true;\
}\
\
return false;\
}\
}
YAML_DEFINE_CONVERT_STREAMABLE
(
int
);
YAML_DEFINE_CONVERT_STREAMABLE
(
unsigned
);
YAML_DEFINE_CONVERT_STREAMABLE
(
short
);
YAML_DEFINE_CONVERT_STREAMABLE
(
unsigned
short
);
YAML_DEFINE_CONVERT_STREAMABLE
(
long
);
YAML_DEFINE_CONVERT_STREAMABLE
(
unsigned
long
);
YAML_DEFINE_CONVERT_STREAMABLE
(
long
long
);
YAML_DEFINE_CONVERT_STREAMABLE
(
unsigned
long
long
);
YAML_DEFINE_CONVERT_STREAMABLE
(
char
);
YAML_DEFINE_CONVERT_STREAMABLE
(
unsigned
char
);
YAML_DEFINE_CONVERT_STREAMABLE
(
float
);
YAML_DEFINE_CONVERT_STREAMABLE
(
double
);
YAML_DEFINE_CONVERT_STREAMABLE
(
long
double
);
#undef YAML_DEFINE_CONVERT_STREAMABLE
// bool
template
<
>
struct
convert
<
bool
>
{
static
Node
encode
(
bool
rhs
)
{
return
rhs
?
Node
(
"true"
)
:
Node
(
"false"
);
}
static
bool
decode
(
const
Node
&
node
,
bool
&
rhs
);
};
// std::map
template
<
typename
K
,
typename
V
>
struct
convert
<
std
::
map
<
K
,
V
>
>
{
static
Node
encode
(
const
std
::
map
<
K
,
V
>&
rhs
)
{
Node
node
(
NodeType
::
Map
);
for
(
typename
std
::
map
<
K
,
V
>::
const_iterator
it
=
rhs
.
begin
();
it
!=
rhs
.
end
();
++
it
)
node
[
it
->
first
]
=
it
->
second
;
return
node
;
}
static
bool
decode
(
const
Node
&
node
,
std
::
map
<
K
,
V
>&
rhs
)
{
if
(
!
node
.
IsMap
())
return
false
;
rhs
.
clear
();
for
(
const_iterator
it
=
node
.
begin
();
it
!=
node
.
end
();
++
it
)
rhs
[
it
->
first
.
as
<
K
>
()]
=
it
->
second
.
as
<
V
>
();
return
true
;
}
};
// std::vector
template
<
typename
T
>
struct
convert
<
std
::
vector
<
T
>
>
{
static
Node
encode
(
const
std
::
vector
<
T
>&
rhs
)
{
Node
node
(
NodeType
::
Sequence
);
for
(
typename
std
::
vector
<
T
>::
const_iterator
it
=
rhs
.
begin
();
it
!=
rhs
.
end
();
++
it
)
node
.
append
(
*
it
);
return
node
;
}
static
bool
decode
(
const
Node
&
node
,
std
::
vector
<
T
>&
rhs
)
{
if
(
!
node
.
IsSequence
())
return
false
;
rhs
.
clear
();
for
(
const_iterator
it
=
node
.
begin
();
it
!=
node
.
end
();
++
it
)
rhs
.
push_back
(
it
->
as
<
T
>
());
return
true
;
}
};
// std::list
template
<
typename
T
>
struct
convert
<
std
::
list
<
T
>
>
{
static
Node
encode
(
const
std
::
list
<
T
>&
rhs
)
{
Node
node
(
NodeType
::
Sequence
);
for
(
typename
std
::
list
<
T
>::
const_iterator
it
=
rhs
.
begin
();
it
!=
rhs
.
end
();
++
it
)
node
.
append
(
*
it
);
return
node
;
}
static
bool
decode
(
const
Node
&
node
,
std
::
list
<
T
>&
rhs
)
{
if
(
!
node
.
IsSequence
())
return
false
;
rhs
.
clear
();
for
(
const_iterator
it
=
node
.
begin
();
it
!=
node
.
end
();
++
it
)
rhs
.
push_back
(
it
->
as
<
T
>
());
return
true
;
}
};
}
#endif // NODE_CONVERT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/detail/bool_type.h
deleted
100644 → 0
View file @
d772361f
#ifndef NODE_DETAIL_BOOL_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define NODE_DETAIL_BOOL_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
{
namespace
detail
{
struct
unspecified_bool
{
struct
NOT_ALLOWED
;
static
void
true_value
(
NOT_ALLOWED
*
)
{}
};
typedef
void
(
*
unspecified_bool_type
)(
unspecified_bool
::
NOT_ALLOWED
*
);
}
}
#define YAML_CPP_OPERATOR_BOOL()\
operator YAML::detail::unspecified_bool_type() const\
{\
return this->operator!() ? 0 : &YAML::detail::unspecified_bool::true_value;\
}
#endif // NODE_DETAIL_BOOL_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/detail/impl.h
deleted
100644 → 0
View file @
d772361f
#ifndef NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define NODE_DETAIL_IMPL_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
#include "yaml-cpp/node/detail/node.h"
#include "yaml-cpp/node/detail/node_data.h"
#include <boost/type_traits.hpp>
namespace
YAML
{
namespace
detail
{
template
<
typename
Key
,
typename
Enable
=
void
>
struct
get_idx
{
static
node
*
get
(
const
std
::
vector
<
node
*>&
/* sequence */
,
const
Key
&
/* key */
,
shared_memory_holder
/* pMemory */
)
{
return
0
;
}
};
template
<
typename
Key
>
struct
get_idx
<
Key
,
typename
boost
::
enable_if
<
boost
::
is_unsigned
<
Key
>
>::
type
>
{
static
node
*
get
(
const
std
::
vector
<
node
*>&
sequence
,
const
Key
&
key
,
shared_memory_holder
/* pMemory */
)
{
return
key
<
sequence
.
size
()
?
sequence
[
key
]
:
0
;
}
static
node
*
get
(
std
::
vector
<
node
*>&
sequence
,
const
Key
&
key
,
shared_memory_holder
pMemory
)
{
if
(
key
>
sequence
.
size
())
return
0
;
if
(
key
==
sequence
.
size
())
sequence
.
push_back
(
&
pMemory
->
create_node
());
return
sequence
[
key
];
}
};
template
<
typename
Key
>
struct
get_idx
<
Key
,
typename
boost
::
enable_if
<
boost
::
is_signed
<
Key
>
>::
type
>
{
static
node
*
get
(
const
std
::
vector
<
node
*>&
sequence
,
const
Key
&
key
,
shared_memory_holder
pMemory
)
{
return
key
>=
0
?
get_idx
<
std
::
size_t
>::
get
(
sequence
,
static_cast
<
std
::
size_t
>
(
key
),
pMemory
)
:
0
;
}
static
node
*
get
(
std
::
vector
<
node
*>&
sequence
,
const
Key
&
key
,
shared_memory_holder
pMemory
)
{
return
key
>=
0
?
get_idx
<
std
::
size_t
>::
get
(
sequence
,
static_cast
<
std
::
size_t
>
(
key
),
pMemory
)
:
0
;
}
};
// indexing
template
<
typename
Key
>
inline
node
&
node_data
::
get
(
const
Key
&
key
,
shared_memory_holder
pMemory
)
const
{
switch
(
m_type
)
{
case
NodeType
::
Map
:
break
;
case
NodeType
::
Undefined
:
case
NodeType
::
Null
:
return
pMemory
->
create_node
();
case
NodeType
::
Sequence
:
if
(
node
*
pNode
=
get_idx
<
Key
>::
get
(
m_sequence
,
key
,
pMemory
))
return
*
pNode
;
return
pMemory
->
create_node
();
case
NodeType
::
Scalar
:
throw
std
::
runtime_error
(
"Can't call operator[] on a scalar"
);
}
for
(
node_map
::
const_iterator
it
=
m_map
.
begin
();
it
!=
m_map
.
end
();
++
it
)
{
if
(
equals
(
*
it
->
first
,
key
,
pMemory
))
return
*
it
->
second
;
}
return
pMemory
->
create_node
();
}
template
<
typename
Key
>
inline
node
&
node_data
::
get
(
const
Key
&
key
,
shared_memory_holder
pMemory
)
{
switch
(
m_type
)
{
case
NodeType
::
Map
:
break
;
case
NodeType
::
Undefined
:
case
NodeType
::
Null
:
case
NodeType
::
Sequence
:
if
(
node
*
pNode
=
get_idx
<
Key
>::
get
(
m_sequence
,
key
,
pMemory
))
{
m_type
=
NodeType
::
Sequence
;
return
*
pNode
;
}
convert_to_map
(
pMemory
);
break
;
case
NodeType
::
Scalar
:
throw
std
::
runtime_error
(
"Can't call operator[] on a scalar"
);
}
for
(
node_map
::
const_iterator
it
=
m_map
.
begin
();
it
!=
m_map
.
end
();
++
it
)
{
if
(
equals
(
*
it
->
first
,
key
,
pMemory
))
return
*
it
->
second
;
}
node
&
k
=
convert_to_node
(
key
,
pMemory
);
node
&
v
=
pMemory
->
create_node
();
insert_map_pair
(
k
,
v
);
return
v
;
}
template
<
typename
Key
>
inline
bool
node_data
::
remove
(
const
Key
&
key
,
shared_memory_holder
pMemory
)
{
if
(
m_type
!=
NodeType
::
Map
)
return
false
;
for
(
node_map
::
iterator
it
=
m_map
.
begin
();
it
!=
m_map
.
end
();
++
it
)
{
if
(
equals
(
*
it
->
first
,
key
,
pMemory
))
{
m_map
.
erase
(
it
);
return
true
;
}
}
return
false
;
}
template
<
typename
T
>
inline
bool
node_data
::
equals
(
node
&
node
,
const
T
&
rhs
,
shared_memory_holder
pMemory
)
{
T
lhs
;
if
(
convert
<
T
>::
decode
(
Node
(
node
,
pMemory
),
lhs
))
return
lhs
==
rhs
;
return
false
;
}
template
<
typename
T
>
inline
node
&
node_data
::
convert_to_node
(
const
T
&
rhs
,
shared_memory_holder
pMemory
)
{
Node
value
=
convert
<
T
>::
encode
(
rhs
);
value
.
EnsureNodeExists
();
pMemory
->
merge
(
*
value
.
m_pMemory
);
return
*
value
.
m_pNode
;
}
}
}
#endif // NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/detail/iterator.h
deleted
100644 → 0
View file @
d772361f
#ifndef VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_DETAIL_ITERATOR_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
#include "yaml-cpp/dll.h"
#include "yaml-cpp/node/ptr.h"
#include "yaml-cpp/node/detail/node_iterator.h"
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/utility.hpp>
namespace
YAML
{
namespace
detail
{
struct
iterator_value
;
template
<
typename
V
>
class
iterator_base
:
public
boost
::
iterator_adaptor
<
iterator_base
<
V
>
,
node_iterator
,
V
,
std
::
forward_iterator_tag
,
V
>
{
private:
template
<
typename
>
friend
class
iterator_base
;
struct
enabler
{};
typedef
typename
iterator_base
::
iterator_adaptor_
::
base_type
base_type
;
typedef
typename
iterator_base
::
iterator_adaptor_
::
value_type
value_type
;
public:
iterator_base
()
{}
explicit
iterator_base
(
base_type
rhs
,
shared_memory_holder
pMemory
)
:
iterator_base
::
iterator_adaptor_
(
rhs
),
m_pMemory
(
pMemory
)
{}
template
<
class
W
>
iterator_base
(
const
iterator_base
<
W
>&
rhs
,
typename
boost
::
enable_if
<
boost
::
is_convertible
<
W
*
,
V
*>
,
enabler
>::
type
=
enabler
())
:
iterator_base
::
iterator_adaptor_
(
rhs
.
base
()),
m_pMemory
(
rhs
.
m_pMemory
)
{}
private:
friend
class
boost
::
iterator_core_access
;
void
increment
()
{
this
->
base_reference
()
=
boost
::
next
(
this
->
base
());
}
value_type
dereference
()
const
{
const
typename
base_type
::
value_type
&
v
=
*
this
->
base
();
if
(
v
.
pNode
)
return
value_type
(
Node
(
*
v
,
m_pMemory
));
if
(
v
.
first
&&
v
.
second
)
return
value_type
(
Node
(
*
v
.
first
,
m_pMemory
),
Node
(
*
v
.
second
,
m_pMemory
));
return
value_type
();
}
private:
shared_memory_holder
m_pMemory
;
};
}
}
#endif // VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/detail/iterator_fwd.h
deleted
100644 → 0
View file @
d772361f
#ifndef VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_DETAIL_ITERATOR_FWD_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
#include "yaml-cpp/dll.h"
#include <list>
#include <utility>
#include <vector>
namespace
YAML
{
class
node
;
namespace
detail
{
struct
iterator_value
;
template
<
typename
V
>
class
iterator_base
;
}
typedef
detail
::
iterator_base
<
detail
::
iterator_value
>
iterator
;
typedef
detail
::
iterator_base
<
const
detail
::
iterator_value
>
const_iterator
;
}
#endif // VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/detail/memory.h
deleted
100644 → 0
View file @
d772361f
#ifndef VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_DETAIL_MEMORY_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
#include "yaml-cpp/node/ptr.h"
#include <set>
#include <boost/shared_ptr.hpp>
namespace
YAML
{
namespace
detail
{
class
memory
{
public:
node
&
create_node
();
void
merge
(
const
memory
&
rhs
);
private:
typedef
std
::
set
<
shared_node
>
Nodes
;
Nodes
m_nodes
;
};
class
memory_holder
{
public:
memory_holder
()
:
m_pMemory
(
new
memory
)
{}
node
&
create_node
()
{
return
m_pMemory
->
create_node
();
}
void
merge
(
memory_holder
&
rhs
);
private:
boost
::
shared_ptr
<
memory
>
m_pMemory
;
};
}
}
#endif // VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/detail/node.h
deleted
100644 → 0
View file @
d772361f
#ifndef NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define NODE_DETAIL_NODE_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
#include "yaml-cpp/dll.h"
#include "yaml-cpp/node/type.h"
#include "yaml-cpp/node/ptr.h"
#include "yaml-cpp/node/detail/node_ref.h"
#include <set>
#include <boost/utility.hpp>
namespace
YAML
{
namespace
detail
{
class
node
:
private
boost
::
noncopyable
{
public:
node
()
:
m_pRef
(
new
node_ref
)
{}
bool
is
(
const
node
&
rhs
)
const
{
return
m_pRef
==
rhs
.
m_pRef
;
}
const
node_ref
*
ref
()
const
{
return
m_pRef
.
get
();
}
bool
is_defined
()
const
{
return
m_pRef
->
is_defined
();
}
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
())
return
;
m_pRef
->
mark_defined
();
for
(
nodes
::
iterator
it
=
m_dependencies
.
begin
();
it
!=
m_dependencies
.
end
();
++
it
)
(
*
it
)
->
mark_defined
();
m_dependencies
.
clear
();
}
void
add_dependency
(
node
&
rhs
)
{
if
(
is_defined
())
rhs
.
mark_defined
();
else
m_dependencies
.
insert
(
&
rhs
);
}
void
set_ref
(
const
node
&
rhs
)
{
if
(
rhs
.
is_defined
())
mark_defined
();
m_pRef
=
rhs
.
m_pRef
;
}
void
set_data
(
const
node
&
rhs
)
{
if
(
rhs
.
is_defined
())
mark_defined
();
m_pRef
->
set_data
(
*
rhs
.
m_pRef
);
}
void
set_type
(
NodeType
::
value
type
)
{
if
(
type
!=
NodeType
::
Undefined
)
mark_defined
();
m_pRef
->
set_type
(
type
);
}
void
set_null
()
{
mark_defined
();
m_pRef
->
set_null
();
}
void
set_scalar
(
const
std
::
string
&
scalar
)
{
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
();
}
const_node_iterator
begin
()
const
{
return
static_cast
<
const
node_ref
&>
(
*
m_pRef
).
begin
();
}
node_iterator
begin
()
{
return
m_pRef
->
begin
();
}
const_node_iterator
end
()
const
{
return
static_cast
<
const
node_ref
&>
(
*
m_pRef
).
end
();
}
node_iterator
end
()
{
return
m_pRef
->
end
();
}
// sequence
void
append
(
node
&
node
,
shared_memory_holder
pMemory
)
{
m_pRef
->
append
(
node
,
pMemory
);
node
.
add_dependency
(
*
this
);
}
void
insert
(
node
&
key
,
node
&
value
,
shared_memory_holder
pMemory
)
{
m_pRef
->
insert
(
key
,
value
,
pMemory
);
key
.
add_dependency
(
*
this
);
value
.
add_dependency
(
*
this
);
}
// 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
)
{
node
&
value
=
m_pRef
->
get
(
key
,
pMemory
);
value
.
add_dependency
(
*
this
);
return
value
;
}
template
<
typename
Key
>
bool
remove
(
const
Key
&
key
,
shared_memory_holder
pMemory
)
{
return
m_pRef
->
remove
(
key
,
pMemory
);
}
node
&
get
(
node
&
key
,
shared_memory_holder
pMemory
)
const
{
return
static_cast
<
const
node_ref
&>
(
*
m_pRef
).
get
(
key
,
pMemory
);
}
node
&
get
(
node
&
key
,
shared_memory_holder
pMemory
)
{
node
&
value
=
m_pRef
->
get
(
key
,
pMemory
);
key
.
add_dependency
(
*
this
);
value
.
add_dependency
(
*
this
);
return
value
;
}
bool
remove
(
node
&
key
,
shared_memory_holder
pMemory
)
{
return
m_pRef
->
remove
(
key
,
pMemory
);
}
private:
shared_node_ref
m_pRef
;
typedef
std
::
set
<
node
*>
nodes
;
nodes
m_dependencies
;
};
}
}
#endif // NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/detail/node_data.h
deleted
100644 → 0
View file @
d772361f
#ifndef VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_DETAIL_NODE_DATA_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
#include "yaml-cpp/dll.h"
#include "yaml-cpp/node/iterator.h"
#include "yaml-cpp/node/ptr.h"
#include "yaml-cpp/node/type.h"
#include <boost/utility.hpp>
#include <list>
#include <utility>
#include <vector>
namespace
YAML
{
namespace
detail
{
class
node_data
:
private
boost
::
noncopyable
{
public:
node_data
();
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
;
const_node_iterator
begin
()
const
;
node_iterator
begin
();
const_node_iterator
end
()
const
;
node_iterator
end
();
// sequence
void
append
(
node
&
node
,
shared_memory_holder
pMemory
);
void
insert
(
node
&
key
,
node
&
value
,
shared_memory_holder
pMemory
);
// 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
);
template
<
typename
Key
>
bool
remove
(
const
Key
&
key
,
shared_memory_holder
pMemory
);
node
&
get
(
node
&
key
,
shared_memory_holder
pMemory
)
const
;
node
&
get
(
node
&
key
,
shared_memory_holder
pMemory
);
bool
remove
(
node
&
key
,
shared_memory_holder
pMemory
);
public:
static
std
::
string
empty_scalar
;
private:
void
compute_seq_size
()
const
;
void
compute_map_size
()
const
;
void
reset_sequence
();
void
reset_map
();
void
insert_map_pair
(
node
&
key
,
node
&
value
);
void
convert_to_map
(
shared_memory_holder
pMemory
);
void
convert_sequence_to_map
(
shared_memory_holder
pMemory
);
template
<
typename
T
>
static
bool
equals
(
node
&
node
,
const
T
&
rhs
,
shared_memory_holder
pMemory
);
template
<
typename
T
>
static
node
&
convert_to_node
(
const
T
&
rhs
,
shared_memory_holder
pMemory
);
private:
bool
m_isDefined
;
NodeType
::
value
m_type
;
std
::
string
m_tag
;
// scalar
std
::
string
m_scalar
;
// sequence
typedef
std
::
vector
<
node
*>
node_seq
;
node_seq
m_sequence
;
mutable
std
::
size_t
m_seqSize
;
// map
typedef
std
::
map
<
node
*
,
node
*>
node_map
;
node_map
m_map
;
typedef
std
::
pair
<
node
*
,
node
*>
kv_pair
;
typedef
std
::
list
<
kv_pair
>
kv_pairs
;
mutable
kv_pairs
m_undefinedPairs
;
};
}
}
#endif // VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/detail/node_iterator.h
deleted
100644 → 0
View file @
d772361f
#ifndef VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_DETAIL_NODE_ITERATOR_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
#include "yaml-cpp/dll.h"
#include "yaml-cpp/node/ptr.h"
#include <boost/iterator/iterator_facade.hpp>
#include <boost/utility/enable_if.hpp>
#include <map>
#include <utility>
#include <vector>
namespace
YAML
{
namespace
detail
{
struct
iterator_type
{
enum
value
{
None
,
Sequence
,
Map
};
};
template
<
typename
V
>
struct
node_iterator_value
:
public
std
::
pair
<
V
*
,
V
*>
{
typedef
std
::
pair
<
V
*
,
V
*>
kv
;
node_iterator_value
()
:
kv
(),
pNode
(
0
)
{}
explicit
node_iterator_value
(
V
&
rhs
)
:
kv
(),
pNode
(
&
rhs
)
{}
explicit
node_iterator_value
(
V
&
key
,
V
&
value
)
:
kv
(
&
key
,
&
value
),
pNode
(
0
)
{}
V
&
operator
*
()
const
{
return
*
pNode
;
}
V
&
operator
->
()
const
{
return
*
pNode
;
}
V
*
pNode
;
};
typedef
std
::
vector
<
node
*>
node_seq
;
typedef
std
::
map
<
node
*
,
node
*>
node_map
;
template
<
typename
V
>
struct
node_iterator_type
{
typedef
node_seq
::
iterator
seq
;
typedef
node_map
::
iterator
map
;
};
template
<
typename
V
>
struct
node_iterator_type
<
const
V
>
{
typedef
node_seq
::
const_iterator
seq
;
typedef
node_map
::
const_iterator
map
;
};
template
<
typename
V
>
class
node_iterator_base
:
public
boost
::
iterator_facade
<
node_iterator_base
<
V
>
,
node_iterator_value
<
V
>
,
std
::
forward_iterator_tag
,
node_iterator_value
<
V
>
>
{
private:
struct
enabler
{};
public:
typedef
typename
node_iterator_type
<
V
>::
seq
SeqIter
;
typedef
typename
node_iterator_type
<
V
>::
map
MapIter
;
typedef
node_iterator_value
<
V
>
value_type
;
node_iterator_base
()
:
m_type
(
iterator_type
::
None
)
{}
explicit
node_iterator_base
(
SeqIter
seqIt
)
:
m_type
(
iterator_type
::
Sequence
),
m_seqIt
(
seqIt
)
{}
explicit
node_iterator_base
(
MapIter
mapIt
,
MapIter
mapEnd
)
:
m_type
(
iterator_type
::
Map
),
m_mapIt
(
mapIt
),
m_mapEnd
(
mapEnd
)
{
m_mapIt
=
increment_until_defined
(
m_mapIt
);
}
template
<
typename
W
>
node_iterator_base
(
const
node_iterator_base
<
W
>&
rhs
,
typename
boost
::
enable_if
<
boost
::
is_convertible
<
W
*
,
V
*>
,
enabler
>::
type
=
enabler
())
:
m_type
(
rhs
.
m_type
),
m_seqIt
(
rhs
.
m_seqIt
),
m_mapIt
(
rhs
.
m_mapIt
),
m_mapEnd
(
rhs
.
m_mapEnd
)
{}
private:
friend
class
boost
::
iterator_core_access
;
template
<
typename
>
friend
class
node_iterator_base
;
template
<
typename
W
>
bool
equal
(
const
node_iterator_base
<
W
>&
rhs
)
const
{
if
(
m_type
!=
rhs
.
m_type
)
return
false
;
switch
(
m_type
)
{
case
iterator_type
::
None
:
return
true
;
case
iterator_type
::
Sequence
:
return
m_seqIt
==
rhs
.
m_seqIt
;
case
iterator_type
::
Map
:
return
m_mapIt
==
rhs
.
m_mapIt
;
}
return
true
;
}
void
increment
()
{
switch
(
m_type
)
{
case
iterator_type
::
None
:
break
;
case
iterator_type
::
Sequence
:
++
m_seqIt
;
break
;
case
iterator_type
::
Map
:
++
m_mapIt
;
m_mapIt
=
increment_until_defined
(
m_mapIt
);
break
;
}
}
value_type
dereference
()
const
{
switch
(
m_type
)
{
case
iterator_type
::
None
:
return
value_type
();
case
iterator_type
::
Sequence
:
return
value_type
(
**
m_seqIt
);
case
iterator_type
::
Map
:
return
value_type
(
*
m_mapIt
->
first
,
*
m_mapIt
->
second
);
}
return
value_type
();
}
MapIter
increment_until_defined
(
MapIter
it
)
{
while
(
it
!=
m_mapEnd
&&
!
is_defined
(
it
))
++
it
;
return
it
;
}
bool
is_defined
(
MapIter
it
)
const
{
return
it
->
first
->
is_defined
()
&&
it
->
second
->
is_defined
();
}
private:
typename
iterator_type
::
value
m_type
;
SeqIter
m_seqIt
;
MapIter
m_mapIt
,
m_mapEnd
;
};
typedef
node_iterator_base
<
node
>
node_iterator
;
typedef
node_iterator_base
<
const
node
>
const_node_iterator
;
}
}
#endif // VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/detail/node_ref.h
deleted
100644 → 0
View file @
d772361f
#ifndef VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_DETAIL_NODE_REF_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
#include "yaml-cpp/dll.h"
#include "yaml-cpp/node/type.h"
#include "yaml-cpp/node/ptr.h"
#include "yaml-cpp/node/detail/node_data.h"
#include <boost/utility.hpp>
namespace
YAML
{
namespace
detail
{
class
node_ref
:
private
boost
::
noncopyable
{
public:
node_ref
()
:
m_pData
(
new
node_data
)
{}
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
);
}
// size/iterator
std
::
size_t
size
()
const
{
return
m_pData
->
size
();
}
const_node_iterator
begin
()
const
{
return
static_cast
<
const
node_data
&>
(
*
m_pData
).
begin
();
}
node_iterator
begin
()
{
return
m_pData
->
begin
();
}
const_node_iterator
end
()
const
{
return
static_cast
<
const
node_data
&>
(
*
m_pData
).
end
();
}
node_iterator
end
()
{
return
m_pData
->
end
();
}
// sequence
void
append
(
node
&
node
,
shared_memory_holder
pMemory
)
{
m_pData
->
append
(
node
,
pMemory
);
}
void
insert
(
node
&
key
,
node
&
value
,
shared_memory_holder
pMemory
)
{
m_pData
->
insert
(
key
,
value
,
pMemory
);
}
// 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
)
{
return
m_pData
->
get
(
key
,
pMemory
);
}
template
<
typename
Key
>
bool
remove
(
const
Key
&
key
,
shared_memory_holder
pMemory
)
{
return
m_pData
->
remove
(
key
,
pMemory
);
}
node
&
get
(
node
&
key
,
shared_memory_holder
pMemory
)
const
{
return
static_cast
<
const
node_data
&>
(
*
m_pData
).
get
(
key
,
pMemory
);
}
node
&
get
(
node
&
key
,
shared_memory_holder
pMemory
)
{
return
m_pData
->
get
(
key
,
pMemory
);
}
bool
remove
(
node
&
key
,
shared_memory_holder
pMemory
)
{
return
m_pData
->
remove
(
key
,
pMemory
);
}
private:
shared_node_data
m_pData
;
};
}
}
#endif // VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/emit.h
deleted
100644 → 0
View file @
d772361f
#ifndef NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define NODE_EMIT_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
#include <string>
#include <iosfwd>
namespace
YAML
{
class
Emitter
;
class
Node
;
Emitter
&
operator
<<
(
Emitter
&
out
,
const
Node
&
node
);
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
Node
&
node
);
std
::
string
Dump
(
const
Node
&
node
);
}
#endif // NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/impl.h
deleted
100644 → 0
View file @
d772361f
#ifndef NODE_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define NODE_IMPL_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
#include "yaml-cpp/node/node.h"
#include "yaml-cpp/node/iterator.h"
#include "yaml-cpp/node/detail/memory.h"
#include "yaml-cpp/node/detail/node.h"
#include <string>
namespace
YAML
{
inline
Node
::
Node
()
:
m_pNode
(
0
)
{
}
inline
Node
::
Node
(
NodeType
::
value
type
)
:
m_pMemory
(
new
detail
::
memory_holder
),
m_pNode
(
&
m_pMemory
->
create_node
())
{
m_pNode
->
set_type
(
type
);
}
template
<
typename
T
>
inline
Node
::
Node
(
const
T
&
rhs
)
:
m_pMemory
(
new
detail
::
memory_holder
),
m_pNode
(
&
m_pMemory
->
create_node
())
{
Assign
(
rhs
);
}
inline
Node
::
Node
(
const
detail
::
iterator_value
&
rhs
)
:
m_pMemory
(
rhs
.
m_pMemory
),
m_pNode
(
rhs
.
m_pNode
)
{
}
inline
Node
::
Node
(
const
Node
&
rhs
)
:
m_pMemory
(
rhs
.
m_pMemory
),
m_pNode
(
rhs
.
m_pNode
)
{
}
inline
Node
::
Node
(
detail
::
node
&
node
,
detail
::
shared_memory_holder
pMemory
)
:
m_pMemory
(
pMemory
),
m_pNode
(
&
node
)
{
}
inline
Node
::~
Node
()
{
}
inline
void
Node
::
EnsureNodeExists
()
const
{
if
(
!
m_pNode
)
{
m_pMemory
.
reset
(
new
detail
::
memory_holder
);
m_pNode
=
&
m_pMemory
->
create_node
();
m_pNode
->
set_null
();
}
}
inline
bool
Node
::
IsDefined
()
const
{
return
m_pNode
?
m_pNode
->
is_defined
()
:
true
;
}
inline
NodeType
::
value
Node
::
Type
()
const
{
return
m_pNode
?
m_pNode
->
type
()
:
NodeType
::
Null
;
}
// access
// template helpers
template
<
typename
T
,
typename
S
>
struct
as_if
{
explicit
as_if
(
const
Node
&
node_
)
:
node
(
node_
)
{}
const
Node
&
node
;
const
T
operator
()(
const
S
&
fallback
)
const
{
if
(
!
node
.
m_pNode
)
return
fallback
;
T
t
;
if
(
convert
<
T
>::
decode
(
node
,
t
))
return
t
;
return
fallback
;
}
};
template
<
typename
S
>
struct
as_if
<
std
::
string
,
S
>
{
explicit
as_if
(
const
Node
&
node_
)
:
node
(
node_
)
{}
const
Node
&
node
;
const
std
::
string
operator
()(
const
S
&
fallback
)
const
{
if
(
node
.
Type
()
!=
NodeType
::
Scalar
)
return
fallback
;
return
node
.
Scalar
();
}
};
template
<
typename
T
>
struct
as_if
<
T
,
void
>
{
explicit
as_if
(
const
Node
&
node_
)
:
node
(
node_
)
{}
const
Node
&
node
;
const
T
operator
()()
const
{
if
(
!
node
.
m_pNode
)
throw
std
::
runtime_error
(
"Unable to convert to type"
);
T
t
;
if
(
convert
<
T
>::
decode
(
node
,
t
))
return
t
;
throw
std
::
runtime_error
(
"Unable to convert to type"
);
}
};
template
<
>
struct
as_if
<
std
::
string
,
void
>
{
explicit
as_if
(
const
Node
&
node_
)
:
node
(
node_
)
{}
const
Node
&
node
;
const
std
::
string
operator
()()
const
{
if
(
node
.
Type
()
!=
NodeType
::
Scalar
)
throw
std
::
runtime_error
(
"Unable to convert to string, not a scalar"
);
return
node
.
Scalar
();
}
};
// access functions
template
<
typename
T
>
inline
const
T
Node
::
as
()
const
{
return
as_if
<
T
,
void
>
(
*
this
)();
}
template
<
typename
T
,
typename
S
>
inline
const
T
Node
::
as
(
const
S
&
fallback
)
const
{
return
as_if
<
T
,
S
>
(
*
this
)(
fallback
);
}
inline
const
std
::
string
&
Node
::
Scalar
()
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
{
if
(
!
m_pNode
||
!
rhs
.
m_pNode
)
return
false
;
return
m_pNode
->
is
(
*
rhs
.
m_pNode
);
}
template
<
typename
T
>
inline
Node
&
Node
::
operator
=
(
const
T
&
rhs
)
{
Assign
(
rhs
);
return
*
this
;
}
template
<
typename
T
>
inline
void
Node
::
Assign
(
const
T
&
rhs
)
{
AssignData
(
convert
<
T
>::
encode
(
rhs
));
}
template
<
>
inline
void
Node
::
Assign
(
const
std
::
string
&
rhs
)
{
EnsureNodeExists
();
m_pNode
->
set_scalar
(
rhs
);
}
inline
void
Node
::
Assign
(
const
char
*
rhs
)
{
EnsureNodeExists
();
m_pNode
->
set_scalar
(
rhs
);
}
inline
void
Node
::
Assign
(
char
*
rhs
)
{
EnsureNodeExists
();
m_pNode
->
set_scalar
(
rhs
);
}
inline
Node
&
Node
::
operator
=
(
const
Node
&
rhs
)
{
if
(
is
(
rhs
))
return
*
this
;
AssignNode
(
rhs
);
return
*
this
;
}
inline
void
Node
::
AssignData
(
const
Node
&
rhs
)
{
EnsureNodeExists
();
rhs
.
EnsureNodeExists
();
m_pNode
->
set_data
(
*
rhs
.
m_pNode
);
m_pMemory
->
merge
(
*
rhs
.
m_pMemory
);
}
inline
void
Node
::
AssignNode
(
const
Node
&
rhs
)
{
rhs
.
EnsureNodeExists
();
if
(
!
m_pNode
)
{
m_pNode
=
rhs
.
m_pNode
;
m_pMemory
=
rhs
.
m_pMemory
;
return
;
}
m_pNode
->
set_ref
(
*
rhs
.
m_pNode
);
m_pMemory
->
merge
(
*
rhs
.
m_pMemory
);
m_pNode
=
rhs
.
m_pNode
;
}
// size/iterator
inline
std
::
size_t
Node
::
size
()
const
{
return
m_pNode
?
m_pNode
->
size
()
:
0
;
}
inline
const_iterator
Node
::
begin
()
const
{
return
m_pNode
?
const_iterator
(
m_pNode
->
begin
(),
m_pMemory
)
:
const_iterator
();
}
inline
iterator
Node
::
begin
()
{
return
m_pNode
?
iterator
(
m_pNode
->
begin
(),
m_pMemory
)
:
iterator
();
}
inline
const_iterator
Node
::
end
()
const
{
return
m_pNode
?
const_iterator
(
m_pNode
->
end
(),
m_pMemory
)
:
const_iterator
();
}
inline
iterator
Node
::
end
()
{
return
m_pNode
?
iterator
(
m_pNode
->
end
(),
m_pMemory
)
:
iterator
();
}
// sequence
template
<
typename
T
>
inline
void
Node
::
append
(
const
T
&
rhs
)
{
append
(
Node
(
rhs
));
}
inline
void
Node
::
append
(
const
Node
&
rhs
)
{
EnsureNodeExists
();
rhs
.
EnsureNodeExists
();
m_pNode
->
append
(
*
rhs
.
m_pNode
,
m_pMemory
);
m_pMemory
->
merge
(
*
rhs
.
m_pMemory
);
}
// indexing
template
<
typename
Key
>
inline
const
Node
Node
::
operator
[](
const
Key
&
key
)
const
{
EnsureNodeExists
();
detail
::
node
&
value
=
static_cast
<
const
detail
::
node
&>
(
*
m_pNode
).
get
(
key
,
m_pMemory
);
return
Node
(
value
,
m_pMemory
);
}
template
<
typename
Key
>
inline
Node
Node
::
operator
[](
const
Key
&
key
)
{
EnsureNodeExists
();
detail
::
node
&
value
=
m_pNode
->
get
(
key
,
m_pMemory
);
return
Node
(
value
,
m_pMemory
);
}
template
<
typename
Key
>
inline
bool
Node
::
remove
(
const
Key
&
key
)
{
EnsureNodeExists
();
return
m_pNode
->
remove
(
key
,
m_pMemory
);
}
inline
const
Node
Node
::
operator
[](
const
Node
&
key
)
const
{
EnsureNodeExists
();
key
.
EnsureNodeExists
();
detail
::
node
&
value
=
static_cast
<
const
detail
::
node
&>
(
*
m_pNode
).
get
(
*
key
.
m_pNode
,
m_pMemory
);
return
Node
(
value
,
m_pMemory
);
}
inline
Node
Node
::
operator
[](
const
Node
&
key
)
{
EnsureNodeExists
();
key
.
EnsureNodeExists
();
detail
::
node
&
value
=
m_pNode
->
get
(
*
key
.
m_pNode
,
m_pMemory
);
return
Node
(
value
,
m_pMemory
);
}
inline
bool
Node
::
remove
(
const
Node
&
key
)
{
EnsureNodeExists
();
key
.
EnsureNodeExists
();
return
m_pNode
->
remove
(
*
key
.
m_pNode
,
m_pMemory
);
}
inline
const
Node
Node
::
operator
[](
const
char
*
key
)
const
{
return
operator
[](
std
::
string
(
key
));
}
inline
Node
Node
::
operator
[](
const
char
*
key
)
{
return
operator
[](
std
::
string
(
key
));
}
inline
bool
Node
::
remove
(
const
char
*
key
)
{
return
remove
(
std
::
string
(
key
));
}
inline
const
Node
Node
::
operator
[](
char
*
key
)
const
{
return
operator
[](
static_cast
<
const
char
*>
(
key
));
}
inline
Node
Node
::
operator
[](
char
*
key
)
{
return
operator
[](
static_cast
<
const
char
*>
(
key
));
}
inline
bool
Node
::
remove
(
char
*
key
)
{
return
remove
(
static_cast
<
const
char
*>
(
key
));
}
// free functions
inline
bool
operator
==
(
const
Node
&
lhs
,
const
Node
&
rhs
)
{
return
lhs
.
is
(
rhs
);
}
}
#endif // NODE_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/iterator.h
deleted
100644 → 0
View file @
d772361f
#ifndef VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_ITERATOR_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
#include "yaml-cpp/dll.h"
#include "yaml-cpp/node/node.h"
#include "yaml-cpp/node/detail/iterator_fwd.h"
#include "yaml-cpp/node/detail/iterator.h"
#include <list>
#include <utility>
#include <vector>
namespace
YAML
{
namespace
detail
{
struct
iterator_value
:
public
Node
,
std
::
pair
<
Node
,
Node
>
{
iterator_value
()
{}
explicit
iterator_value
(
const
Node
&
rhs
)
:
Node
(
rhs
)
{}
explicit
iterator_value
(
const
Node
&
key
,
const
Node
&
value
)
:
std
::
pair
<
Node
,
Node
>
(
key
,
value
)
{}
};
}
}
#endif // VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/node.h
deleted
100644 → 0
View file @
d772361f
#ifndef NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define NODE_NODE_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
#include "yaml-cpp/dll.h"
#include "yaml-cpp/node/ptr.h"
#include "yaml-cpp/node/type.h"
#include "yaml-cpp/node/detail/iterator_fwd.h"
#include "yaml-cpp/node/detail/bool_type.h"
#include <stdexcept>
namespace
YAML
{
class
Node
{
public:
friend
class
NodeBuilder
;
friend
class
NodeEvents
;
friend
class
detail
::
node_data
;
template
<
typename
>
friend
class
detail
::
iterator_base
;
template
<
typename
T
,
typename
S
>
friend
struct
as_if
;
Node
();
explicit
Node
(
NodeType
::
value
type
);
template
<
typename
T
>
explicit
Node
(
const
T
&
rhs
);
explicit
Node
(
const
detail
::
iterator_value
&
rhs
);
Node
(
const
Node
&
rhs
);
~
Node
();
NodeType
::
value
Type
()
const
;
bool
IsDefined
()
const
;
bool
IsNull
()
const
{
return
Type
()
==
NodeType
::
Null
;
}
bool
IsScalar
()
const
{
return
Type
()
==
NodeType
::
Scalar
;
}
bool
IsSequence
()
const
{
return
Type
()
==
NodeType
::
Sequence
;
}
bool
IsMap
()
const
{
return
Type
()
==
NodeType
::
Map
;
}
// bool conversions
YAML_CPP_OPERATOR_BOOL
();
bool
operator
!
()
const
{
return
!
IsDefined
();
}
// access
template
<
typename
T
>
const
T
as
()
const
;
template
<
typename
T
,
typename
S
>
const
T
as
(
const
S
&
fallback
)
const
;
const
std
::
string
&
Scalar
()
const
;
const
std
::
string
&
Tag
()
const
;
void
SetTag
(
const
std
::
string
&
tag
);
// assignment
bool
is
(
const
Node
&
rhs
)
const
;
template
<
typename
T
>
Node
&
operator
=
(
const
T
&
rhs
);
Node
&
operator
=
(
const
Node
&
rhs
);
// size/iterator
std
::
size_t
size
()
const
;
const_iterator
begin
()
const
;
iterator
begin
();
const_iterator
end
()
const
;
iterator
end
();
// sequence
template
<
typename
T
>
void
append
(
const
T
&
rhs
);
void
append
(
const
Node
&
rhs
);
// indexing
template
<
typename
Key
>
const
Node
operator
[](
const
Key
&
key
)
const
;
template
<
typename
Key
>
Node
operator
[](
const
Key
&
key
);
template
<
typename
Key
>
bool
remove
(
const
Key
&
key
);
const
Node
operator
[](
const
Node
&
key
)
const
;
Node
operator
[](
const
Node
&
key
);
bool
remove
(
const
Node
&
key
);
const
Node
operator
[](
const
char
*
key
)
const
;
Node
operator
[](
const
char
*
key
);
bool
remove
(
const
char
*
key
);
const
Node
operator
[](
char
*
key
)
const
;
Node
operator
[](
char
*
key
);
bool
remove
(
char
*
key
);
private:
explicit
Node
(
detail
::
node
&
node
,
detail
::
shared_memory_holder
pMemory
);
void
EnsureNodeExists
()
const
;
template
<
typename
T
>
void
Assign
(
const
T
&
rhs
);
void
Assign
(
const
char
*
rhs
);
void
Assign
(
char
*
rhs
);
void
AssignData
(
const
Node
&
rhs
);
void
AssignNode
(
const
Node
&
rhs
);
private:
mutable
detail
::
shared_memory_holder
m_pMemory
;
mutable
detail
::
node
*
m_pNode
;
};
bool
operator
==
(
const
Node
&
lhs
,
const
Node
&
rhs
);
template
<
typename
T
>
struct
convert
;
}
#endif // NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/parse.h
deleted
100644 → 0
View file @
d772361f
#ifndef VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_PARSE_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
#include <iosfwd>
#include <string>
#include <vector>
namespace
YAML
{
class
Node
;
Node
Load
(
const
std
::
string
&
input
);
Node
Load
(
const
char
*
input
);
Node
Load
(
std
::
istream
&
input
);
Node
LoadFile
(
const
std
::
string
&
filename
);
std
::
vector
<
Node
>
LoadAll
(
const
std
::
string
&
input
);
std
::
vector
<
Node
>
LoadAll
(
const
char
*
input
);
std
::
vector
<
Node
>
LoadAll
(
std
::
istream
&
input
);
std
::
vector
<
Node
>
LoadAllFromFile
(
const
std
::
string
&
filename
);
}
#endif // VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/ptr.h
deleted
100644 → 0
View file @
d772361f
#ifndef VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_PTR_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
#include "yaml-cpp/dll.h"
#include <boost/shared_ptr.hpp>
namespace
YAML
{
namespace
detail
{
class
node
;
class
node_ref
;
class
node_data
;
class
memory
;
class
memory_holder
;
typedef
boost
::
shared_ptr
<
node
>
shared_node
;
typedef
boost
::
shared_ptr
<
node_ref
>
shared_node_ref
;
typedef
boost
::
shared_ptr
<
node_data
>
shared_node_data
;
typedef
boost
::
shared_ptr
<
memory_holder
>
shared_memory_holder
;
typedef
boost
::
shared_ptr
<
memory
>
shared_memory
;
}
}
#endif // VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/type.h
deleted
100644 → 0
View file @
d772361f
#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
NodeType
{
enum
value
{
Undefined
,
Null
,
Scalar
,
Sequence
,
Map
};
};
}
#endif // VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
src/node/convert.cpp
deleted
100644 → 0
View file @
d772361f
#include "yaml-cpp/node/convert.h"
#include "yaml-cpp/node/impl.h"
#include <algorithm>
namespace
{
// we're not gonna mess with the mess that is all the isupper/etc. functions
bool
IsLower
(
char
ch
)
{
return
'a'
<=
ch
&&
ch
<=
'z'
;
}
bool
IsUpper
(
char
ch
)
{
return
'A'
<=
ch
&&
ch
<=
'Z'
;
}
char
ToLower
(
char
ch
)
{
return
IsUpper
(
ch
)
?
ch
+
'a'
-
'A'
:
ch
;
}
std
::
string
tolower
(
const
std
::
string
&
str
)
{
std
::
string
s
(
str
);
std
::
transform
(
s
.
begin
(),
s
.
end
(),
s
.
begin
(),
ToLower
);
return
s
;
}
template
<
typename
T
>
bool
IsEntirely
(
const
std
::
string
&
str
,
T
func
)
{
for
(
std
::
size_t
i
=
0
;
i
<
str
.
size
();
i
++
)
if
(
!
func
(
str
[
i
]))
return
false
;
return
true
;
}
// IsFlexibleCase
// . Returns true if 'str' is:
// . UPPERCASE
// . lowercase
// . Capitalized
bool
IsFlexibleCase
(
const
std
::
string
&
str
)
{
if
(
str
.
empty
())
return
true
;
if
(
IsEntirely
(
str
,
IsLower
))
return
true
;
bool
firstcaps
=
IsUpper
(
str
[
0
]);
std
::
string
rest
=
str
.
substr
(
1
);
return
firstcaps
&&
(
IsEntirely
(
rest
,
IsLower
)
||
IsEntirely
(
rest
,
IsUpper
));
}
}
namespace
YAML
{
bool
convert
<
bool
>::
decode
(
const
Node
&
node
,
bool
&
rhs
)
{
if
(
!
node
.
IsScalar
())
return
false
;
// we can't use iostream bool extraction operators as they don't
// recognize all possible values in the table below (taken from
// http://yaml.org/type/bool.html)
static
const
struct
{
std
::
string
truename
,
falsename
;
}
names
[]
=
{
{
"y"
,
"n"
},
{
"yes"
,
"no"
},
{
"true"
,
"false"
},
{
"on"
,
"off"
},
};
if
(
!
IsFlexibleCase
(
node
.
Scalar
()))
return
false
;
for
(
unsigned
i
=
0
;
i
<
sizeof
(
names
)
/
sizeof
(
names
[
0
]);
i
++
)
{
if
(
names
[
i
].
truename
==
tolower
(
node
.
Scalar
()))
{
rhs
=
true
;
return
true
;
}
if
(
names
[
i
].
falsename
==
tolower
(
node
.
Scalar
()))
{
rhs
=
false
;
return
true
;
}
}
return
false
;
}
}
src/node/detail/memory.cpp
deleted
100644 → 0
View file @
d772361f
#include "yaml-cpp/node/detail/memory.h"
#include "yaml-cpp/node/detail/node.h"
namespace
YAML
{
namespace
detail
{
void
memory_holder
::
merge
(
memory_holder
&
rhs
)
{
if
(
m_pMemory
==
rhs
.
m_pMemory
)
return
;
m_pMemory
->
merge
(
*
rhs
.
m_pMemory
);
rhs
.
m_pMemory
=
m_pMemory
;
}
node
&
memory
::
create_node
()
{
shared_node
pNode
(
new
node
);
m_nodes
.
insert
(
pNode
);
return
*
pNode
;
}
void
memory
::
merge
(
const
memory
&
rhs
)
{
m_nodes
.
insert
(
rhs
.
m_nodes
.
begin
(),
rhs
.
m_nodes
.
end
());
}
}
}
Prev
1
2
Next
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