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
d63ec48c
Commit
d63ec48c
authored
Mar 22, 2014
by
Jesse Beder
Browse files
Run clang-format
parent
3355bbb3
Changes
40
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1796 additions
and
1718 deletions
+1796
-1718
include/yaml-cpp/dll.h
include/yaml-cpp/dll.h
+1
-1
include/yaml-cpp/exceptions.h
include/yaml-cpp/exceptions.h
+213
-194
include/yaml-cpp/node/convert.h
include/yaml-cpp/node/convert.h
+238
-243
include/yaml-cpp/node/detail/bool_type.h
include/yaml-cpp/node/detail/bool_type.h
+17
-17
include/yaml-cpp/node/detail/impl.h
include/yaml-cpp/node/detail/impl.h
+164
-156
include/yaml-cpp/node/detail/iterator.h
include/yaml-cpp/node/detail/iterator.h
+50
-48
include/yaml-cpp/node/detail/iterator_fwd.h
include/yaml-cpp/node/detail/iterator_fwd.h
+14
-13
include/yaml-cpp/node/detail/memory.h
include/yaml-cpp/node/detail/memory.h
+27
-27
include/yaml-cpp/node/detail/node.h
include/yaml-cpp/node/detail/node.h
+132
-115
include/yaml-cpp/node/detail/node_data.h
include/yaml-cpp/node/detail/node_data.h
+97
-93
include/yaml-cpp/node/detail/node_iterator.h
include/yaml-cpp/node/detail/node_iterator.h
+141
-123
include/yaml-cpp/node/detail/node_ref.h
include/yaml-cpp/node/detail/node_ref.h
+77
-53
include/yaml-cpp/node/emit.h
include/yaml-cpp/node/emit.h
+12
-12
include/yaml-cpp/node/impl.h
include/yaml-cpp/node/impl.h
+406
-438
include/yaml-cpp/node/iterator.h
include/yaml-cpp/node/iterator.h
+15
-12
include/yaml-cpp/node/node.h
include/yaml-cpp/node/node.h
+113
-101
include/yaml-cpp/node/parse.h
include/yaml-cpp/node/parse.h
+15
-15
include/yaml-cpp/node/ptr.h
include/yaml-cpp/node/ptr.h
+17
-17
include/yaml-cpp/node/type.h
include/yaml-cpp/node/type.h
+14
-6
include/yaml-cpp/parser.h
include/yaml-cpp/parser.h
+33
-34
No files found.
include/yaml-cpp/dll.h
View file @
d63ec48c
...
...
@@ -30,7 +30,7 @@
// #pragma message( "Defining YAML_CPP_API for DLL import" )
#define YAML_CPP_API __declspec(dllimport)
#endif // yaml_cpp_EXPORTS
#else // YAML_CPP_DLL
#else
// YAML_CPP_DLL
#define YAML_CPP_API
#endif // YAML_CPP_DLL
...
...
include/yaml-cpp/exceptions.h
View file @
d63ec48c
#ifndef EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define EXCEPTIONS_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
#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/mark.h"
#include "yaml-cpp/traits.h"
#include <stdexcept>
#include <string>
#include <sstream>
namespace
YAML
{
// error messages
namespace
ErrorMsg
{
const
char
*
const
YAML_DIRECTIVE_ARGS
=
"YAML directives must have exactly one argument"
;
const
char
*
const
YAML_VERSION
=
"bad YAML version: "
;
const
char
*
const
YAML_MAJOR_VERSION
=
"YAML major version too large"
;
const
char
*
const
REPEATED_YAML_DIRECTIVE
=
"repeated YAML directive"
;
const
char
*
const
TAG_DIRECTIVE_ARGS
=
"TAG directives must have exactly two arguments"
;
const
char
*
const
REPEATED_TAG_DIRECTIVE
=
"repeated TAG directive"
;
const
char
*
const
CHAR_IN_TAG_HANDLE
=
"illegal character found while scanning tag handle"
;
const
char
*
const
TAG_WITH_NO_SUFFIX
=
"tag handle with no suffix"
;
const
char
*
const
END_OF_VERBATIM_TAG
=
"end of verbatim tag not found"
;
const
char
*
const
END_OF_MAP
=
"end of map not found"
;
const
char
*
const
END_OF_MAP_FLOW
=
"end of map flow not found"
;
const
char
*
const
END_OF_SEQ
=
"end of sequence not found"
;
const
char
*
const
END_OF_SEQ_FLOW
=
"end of sequence flow not found"
;
const
char
*
const
MULTIPLE_TAGS
=
"cannot assign multiple tags to the same node"
;
const
char
*
const
MULTIPLE_ANCHORS
=
"cannot assign multiple anchors to the same node"
;
const
char
*
const
MULTIPLE_ALIASES
=
"cannot assign multiple aliases to the same node"
;
const
char
*
const
ALIAS_CONTENT
=
"aliases can't have any content, *including* tags"
;
const
char
*
const
INVALID_HEX
=
"bad character found while scanning hex number"
;
const
char
*
const
INVALID_UNICODE
=
"invalid unicode: "
;
const
char
*
const
INVALID_ESCAPE
=
"unknown escape character: "
;
const
char
*
const
UNKNOWN_TOKEN
=
"unknown token"
;
const
char
*
const
DOC_IN_SCALAR
=
"illegal document indicator in scalar"
;
const
char
*
const
EOF_IN_SCALAR
=
"illegal EOF in scalar"
;
const
char
*
const
CHAR_IN_SCALAR
=
"illegal character in scalar"
;
const
char
*
const
TAB_IN_INDENTATION
=
"illegal tab when looking for indentation"
;
const
char
*
const
FLOW_END
=
"illegal flow end"
;
const
char
*
const
BLOCK_ENTRY
=
"illegal block entry"
;
const
char
*
const
MAP_KEY
=
"illegal map key"
;
const
char
*
const
MAP_VALUE
=
"illegal map value"
;
const
char
*
const
ALIAS_NOT_FOUND
=
"alias not found after *"
;
const
char
*
const
ANCHOR_NOT_FOUND
=
"anchor not found after &"
;
const
char
*
const
CHAR_IN_ALIAS
=
"illegal character found while scanning alias"
;
const
char
*
const
CHAR_IN_ANCHOR
=
"illegal character found while scanning anchor"
;
const
char
*
const
ZERO_INDENT_IN_BLOCK
=
"cannot set zero indentation for a block scalar"
;
const
char
*
const
CHAR_IN_BLOCK
=
"unexpected character in block scalar"
;
const
char
*
const
AMBIGUOUS_ANCHOR
=
"cannot assign the same alias to multiple nodes"
;
const
char
*
const
UNKNOWN_ANCHOR
=
"the referenced anchor is not defined"
;
const
char
*
const
INVALID_NODE
=
"invalid node; this may result from using a map iterator as a sequence iterator, or vice-versa"
;
const
char
*
const
INVALID_SCALAR
=
"invalid scalar"
;
const
char
*
const
KEY_NOT_FOUND
=
"key not found"
;
const
char
*
const
BAD_CONVERSION
=
"bad conversion"
;
const
char
*
const
BAD_DEREFERENCE
=
"bad dereference"
;
const
char
*
const
BAD_SUBSCRIPT
=
"operator[] call on a scalar"
;
const
char
*
const
BAD_PUSHBACK
=
"appending to a non-sequence"
;
const
char
*
const
BAD_INSERT
=
"inserting in a non-convertible-to-map"
;
const
char
*
const
UNMATCHED_GROUP_TAG
=
"unmatched group tag"
;
const
char
*
const
UNEXPECTED_END_SEQ
=
"unexpected end sequence token"
;
const
char
*
const
UNEXPECTED_END_MAP
=
"unexpected end map token"
;
const
char
*
const
SINGLE_QUOTED_CHAR
=
"invalid character in single-quoted string"
;
const
char
*
const
INVALID_ANCHOR
=
"invalid anchor"
;
const
char
*
const
INVALID_ALIAS
=
"invalid alias"
;
const
char
*
const
INVALID_TAG
=
"invalid tag"
;
const
char
*
const
BAD_FILE
=
"bad file"
;
template
<
typename
T
>
inline
const
std
::
string
KEY_NOT_FOUND_WITH_KEY
(
const
T
&
,
typename
disable_if
<
is_numeric
<
T
>
>::
type
*
=
0
)
{
return
KEY_NOT_FOUND
;
}
inline
const
std
::
string
KEY_NOT_FOUND_WITH_KEY
(
const
std
::
string
&
key
)
{
std
::
stringstream
stream
;
stream
<<
KEY_NOT_FOUND
<<
": "
<<
key
;
return
stream
.
str
();
}
template
<
typename
T
>
inline
const
std
::
string
KEY_NOT_FOUND_WITH_KEY
(
const
T
&
key
,
typename
enable_if
<
is_numeric
<
T
>
>::
type
*
=
0
)
{
std
::
stringstream
stream
;
stream
<<
KEY_NOT_FOUND
<<
": "
<<
key
;
return
stream
.
str
();
}
}
class
Exception
:
public
std
::
runtime_error
{
public:
Exception
(
const
Mark
&
mark_
,
const
std
::
string
&
msg_
)
:
std
::
runtime_error
(
build_what
(
mark_
,
msg_
)),
mark
(
mark_
),
msg
(
msg_
)
{}
virtual
~
Exception
()
throw
()
{}
Mark
mark
;
std
::
string
msg
;
private:
static
const
std
::
string
build_what
(
const
Mark
&
mark
,
const
std
::
string
&
msg
)
{
std
::
stringstream
output
;
output
<<
"yaml-cpp: error at line "
<<
mark
.
line
+
1
<<
", column "
<<
mark
.
column
+
1
<<
": "
<<
msg
;
return
output
.
str
();
}
};
class
ParserException
:
public
Exception
{
public:
ParserException
(
const
Mark
&
mark_
,
const
std
::
string
&
msg_
)
:
Exception
(
mark_
,
msg_
)
{}
};
class
RepresentationException
:
public
Exception
{
public:
RepresentationException
(
const
Mark
&
mark_
,
const
std
::
string
&
msg_
)
:
Exception
(
mark_
,
msg_
)
{}
};
// representation exceptions
class
InvalidScalar
:
public
RepresentationException
{
public:
InvalidScalar
(
const
Mark
&
mark_
)
:
RepresentationException
(
mark_
,
ErrorMsg
::
INVALID_SCALAR
)
{}
};
class
KeyNotFound
:
public
RepresentationException
{
public:
template
<
typename
T
>
KeyNotFound
(
const
Mark
&
mark_
,
const
T
&
key_
)
:
RepresentationException
(
mark_
,
ErrorMsg
::
KEY_NOT_FOUND_WITH_KEY
(
key_
))
{}
};
template
<
typename
T
>
class
TypedKeyNotFound
:
public
KeyNotFound
{
public:
TypedKeyNotFound
(
const
Mark
&
mark_
,
const
T
&
key_
)
:
KeyNotFound
(
mark_
,
key_
),
key
(
key_
)
{}
virtual
~
TypedKeyNotFound
()
throw
()
{}
T
key
;
};
template
<
typename
T
>
inline
TypedKeyNotFound
<
T
>
MakeTypedKeyNotFound
(
const
Mark
&
mark
,
const
T
&
key
)
{
return
TypedKeyNotFound
<
T
>
(
mark
,
key
);
}
class
InvalidNode
:
public
RepresentationException
{
public:
InvalidNode
()
:
RepresentationException
(
Mark
::
null_mark
(),
ErrorMsg
::
INVALID_NODE
)
{}
};
class
BadConversion
:
public
RepresentationException
{
public:
BadConversion
()
:
RepresentationException
(
Mark
::
null_mark
(),
ErrorMsg
::
BAD_CONVERSION
)
{}
};
template
<
typename
T
>
class
TypedBadConversion
:
public
BadConversion
{
public:
TypedBadConversion
()
:
BadConversion
()
{}
};
class
BadDereference
:
public
RepresentationException
{
public:
BadDereference
()
:
RepresentationException
(
Mark
::
null_mark
(),
ErrorMsg
::
BAD_DEREFERENCE
)
{}
};
class
BadSubscript
:
public
RepresentationException
{
public:
BadSubscript
()
:
RepresentationException
(
Mark
::
null_mark
(),
ErrorMsg
::
BAD_SUBSCRIPT
)
{}
};
class
BadPushback
:
public
RepresentationException
{
public:
BadPushback
()
:
RepresentationException
(
Mark
::
null_mark
(),
ErrorMsg
::
BAD_PUSHBACK
)
{}
};
class
BadInsert
:
public
RepresentationException
{
public:
BadInsert
()
:
RepresentationException
(
Mark
::
null_mark
(),
ErrorMsg
::
BAD_INSERT
)
{}
};
class
EmitterException
:
public
Exception
{
public:
EmitterException
(
const
std
::
string
&
msg_
)
:
Exception
(
Mark
::
null_mark
(),
msg_
)
{}
};
class
BadFile
:
public
Exception
{
public:
BadFile
()
:
Exception
(
Mark
::
null_mark
(),
ErrorMsg
::
BAD_FILE
)
{}
};
namespace
YAML
{
// error messages
namespace
ErrorMsg
{
const
char
*
const
YAML_DIRECTIVE_ARGS
=
"YAML directives must have exactly one argument"
;
const
char
*
const
YAML_VERSION
=
"bad YAML version: "
;
const
char
*
const
YAML_MAJOR_VERSION
=
"YAML major version too large"
;
const
char
*
const
REPEATED_YAML_DIRECTIVE
=
"repeated YAML directive"
;
const
char
*
const
TAG_DIRECTIVE_ARGS
=
"TAG directives must have exactly two arguments"
;
const
char
*
const
REPEATED_TAG_DIRECTIVE
=
"repeated TAG directive"
;
const
char
*
const
CHAR_IN_TAG_HANDLE
=
"illegal character found while scanning tag handle"
;
const
char
*
const
TAG_WITH_NO_SUFFIX
=
"tag handle with no suffix"
;
const
char
*
const
END_OF_VERBATIM_TAG
=
"end of verbatim tag not found"
;
const
char
*
const
END_OF_MAP
=
"end of map not found"
;
const
char
*
const
END_OF_MAP_FLOW
=
"end of map flow not found"
;
const
char
*
const
END_OF_SEQ
=
"end of sequence not found"
;
const
char
*
const
END_OF_SEQ_FLOW
=
"end of sequence flow not found"
;
const
char
*
const
MULTIPLE_TAGS
=
"cannot assign multiple tags to the same node"
;
const
char
*
const
MULTIPLE_ANCHORS
=
"cannot assign multiple anchors to the same node"
;
const
char
*
const
MULTIPLE_ALIASES
=
"cannot assign multiple aliases to the same node"
;
const
char
*
const
ALIAS_CONTENT
=
"aliases can't have any content, *including* tags"
;
const
char
*
const
INVALID_HEX
=
"bad character found while scanning hex number"
;
const
char
*
const
INVALID_UNICODE
=
"invalid unicode: "
;
const
char
*
const
INVALID_ESCAPE
=
"unknown escape character: "
;
const
char
*
const
UNKNOWN_TOKEN
=
"unknown token"
;
const
char
*
const
DOC_IN_SCALAR
=
"illegal document indicator in scalar"
;
const
char
*
const
EOF_IN_SCALAR
=
"illegal EOF in scalar"
;
const
char
*
const
CHAR_IN_SCALAR
=
"illegal character in scalar"
;
const
char
*
const
TAB_IN_INDENTATION
=
"illegal tab when looking for indentation"
;
const
char
*
const
FLOW_END
=
"illegal flow end"
;
const
char
*
const
BLOCK_ENTRY
=
"illegal block entry"
;
const
char
*
const
MAP_KEY
=
"illegal map key"
;
const
char
*
const
MAP_VALUE
=
"illegal map value"
;
const
char
*
const
ALIAS_NOT_FOUND
=
"alias not found after *"
;
const
char
*
const
ANCHOR_NOT_FOUND
=
"anchor not found after &"
;
const
char
*
const
CHAR_IN_ALIAS
=
"illegal character found while scanning alias"
;
const
char
*
const
CHAR_IN_ANCHOR
=
"illegal character found while scanning anchor"
;
const
char
*
const
ZERO_INDENT_IN_BLOCK
=
"cannot set zero indentation for a block scalar"
;
const
char
*
const
CHAR_IN_BLOCK
=
"unexpected character in block scalar"
;
const
char
*
const
AMBIGUOUS_ANCHOR
=
"cannot assign the same alias to multiple nodes"
;
const
char
*
const
UNKNOWN_ANCHOR
=
"the referenced anchor is not defined"
;
const
char
*
const
INVALID_NODE
=
"invalid node; this may result from using a map iterator as a sequence "
"iterator, or vice-versa"
;
const
char
*
const
INVALID_SCALAR
=
"invalid scalar"
;
const
char
*
const
KEY_NOT_FOUND
=
"key not found"
;
const
char
*
const
BAD_CONVERSION
=
"bad conversion"
;
const
char
*
const
BAD_DEREFERENCE
=
"bad dereference"
;
const
char
*
const
BAD_SUBSCRIPT
=
"operator[] call on a scalar"
;
const
char
*
const
BAD_PUSHBACK
=
"appending to a non-sequence"
;
const
char
*
const
BAD_INSERT
=
"inserting in a non-convertible-to-map"
;
const
char
*
const
UNMATCHED_GROUP_TAG
=
"unmatched group tag"
;
const
char
*
const
UNEXPECTED_END_SEQ
=
"unexpected end sequence token"
;
const
char
*
const
UNEXPECTED_END_MAP
=
"unexpected end map token"
;
const
char
*
const
SINGLE_QUOTED_CHAR
=
"invalid character in single-quoted string"
;
const
char
*
const
INVALID_ANCHOR
=
"invalid anchor"
;
const
char
*
const
INVALID_ALIAS
=
"invalid alias"
;
const
char
*
const
INVALID_TAG
=
"invalid tag"
;
const
char
*
const
BAD_FILE
=
"bad file"
;
template
<
typename
T
>
inline
const
std
::
string
KEY_NOT_FOUND_WITH_KEY
(
const
T
&
,
typename
disable_if
<
is_numeric
<
T
>
>::
type
*
=
0
)
{
return
KEY_NOT_FOUND
;
}
inline
const
std
::
string
KEY_NOT_FOUND_WITH_KEY
(
const
std
::
string
&
key
)
{
std
::
stringstream
stream
;
stream
<<
KEY_NOT_FOUND
<<
": "
<<
key
;
return
stream
.
str
();
}
template
<
typename
T
>
inline
const
std
::
string
KEY_NOT_FOUND_WITH_KEY
(
const
T
&
key
,
typename
enable_if
<
is_numeric
<
T
>
>::
type
*
=
0
)
{
std
::
stringstream
stream
;
stream
<<
KEY_NOT_FOUND
<<
": "
<<
key
;
return
stream
.
str
();
}
}
class
Exception
:
public
std
::
runtime_error
{
public:
Exception
(
const
Mark
&
mark_
,
const
std
::
string
&
msg_
)
:
std
::
runtime_error
(
build_what
(
mark_
,
msg_
)),
mark
(
mark_
),
msg
(
msg_
)
{}
virtual
~
Exception
()
throw
()
{}
Mark
mark
;
std
::
string
msg
;
private:
static
const
std
::
string
build_what
(
const
Mark
&
mark
,
const
std
::
string
&
msg
)
{
std
::
stringstream
output
;
output
<<
"yaml-cpp: error at line "
<<
mark
.
line
+
1
<<
", column "
<<
mark
.
column
+
1
<<
": "
<<
msg
;
return
output
.
str
();
}
};
class
ParserException
:
public
Exception
{
public:
ParserException
(
const
Mark
&
mark_
,
const
std
::
string
&
msg_
)
:
Exception
(
mark_
,
msg_
)
{}
};
class
RepresentationException
:
public
Exception
{
public:
RepresentationException
(
const
Mark
&
mark_
,
const
std
::
string
&
msg_
)
:
Exception
(
mark_
,
msg_
)
{}
};
// representation exceptions
class
InvalidScalar
:
public
RepresentationException
{
public:
InvalidScalar
(
const
Mark
&
mark_
)
:
RepresentationException
(
mark_
,
ErrorMsg
::
INVALID_SCALAR
)
{}
};
class
KeyNotFound
:
public
RepresentationException
{
public:
template
<
typename
T
>
KeyNotFound
(
const
Mark
&
mark_
,
const
T
&
key_
)
:
RepresentationException
(
mark_
,
ErrorMsg
::
KEY_NOT_FOUND_WITH_KEY
(
key_
))
{
}
};
template
<
typename
T
>
class
TypedKeyNotFound
:
public
KeyNotFound
{
public:
TypedKeyNotFound
(
const
Mark
&
mark_
,
const
T
&
key_
)
:
KeyNotFound
(
mark_
,
key_
),
key
(
key_
)
{}
virtual
~
TypedKeyNotFound
()
throw
()
{}
T
key
;
};
template
<
typename
T
>
inline
TypedKeyNotFound
<
T
>
MakeTypedKeyNotFound
(
const
Mark
&
mark
,
const
T
&
key
)
{
return
TypedKeyNotFound
<
T
>
(
mark
,
key
);
}
class
InvalidNode
:
public
RepresentationException
{
public:
InvalidNode
()
:
RepresentationException
(
Mark
::
null_mark
(),
ErrorMsg
::
INVALID_NODE
)
{}
};
class
BadConversion
:
public
RepresentationException
{
public:
BadConversion
()
:
RepresentationException
(
Mark
::
null_mark
(),
ErrorMsg
::
BAD_CONVERSION
)
{}
};
template
<
typename
T
>
class
TypedBadConversion
:
public
BadConversion
{
public:
TypedBadConversion
()
:
BadConversion
()
{}
};
class
BadDereference
:
public
RepresentationException
{
public:
BadDereference
()
:
RepresentationException
(
Mark
::
null_mark
(),
ErrorMsg
::
BAD_DEREFERENCE
)
{}
};
class
BadSubscript
:
public
RepresentationException
{
public:
BadSubscript
()
:
RepresentationException
(
Mark
::
null_mark
(),
ErrorMsg
::
BAD_SUBSCRIPT
)
{}
};
class
BadPushback
:
public
RepresentationException
{
public:
BadPushback
()
:
RepresentationException
(
Mark
::
null_mark
(),
ErrorMsg
::
BAD_PUSHBACK
)
{}
};
class
BadInsert
:
public
RepresentationException
{
public:
BadInsert
()
:
RepresentationException
(
Mark
::
null_mark
(),
ErrorMsg
::
BAD_INSERT
)
{}
};
class
EmitterException
:
public
Exception
{
public:
EmitterException
(
const
std
::
string
&
msg_
)
:
Exception
(
Mark
::
null_mark
(),
msg_
)
{}
};
class
BadFile
:
public
Exception
{
public:
BadFile
()
:
Exception
(
Mark
::
null_mark
(),
ErrorMsg
::
BAD_FILE
)
{}
};
}
#endif // EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif
// EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/convert.h
View file @
d63ec48c
#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
#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/binary.h"
#include "yaml-cpp/node/node.h"
#include "yaml-cpp/node/iterator.h"
...
...
@@ -16,265 +17,259 @@
#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
;
}
};
// C-strings can only be encoded
template
<
>
struct
convert
<
const
char
*>
{
static
Node
encode
(
const
char
*&
rhs
)
{
return
Node
(
rhs
);
}
};
template
<
std
::
size_t
N
>
struct
convert
<
const
char
[
N
]
>
{
static
Node
encode
(
const
char
(
&
rhs
)[
N
])
{
return
Node
(
rhs
);
}
};
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, negative_op)\
template<>\
struct convert<type> {\
static Node encode(const type& rhs) {\
std::stringstream stream;\
stream.precision(std::numeric_limits<type>::digits10 + 1);\
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 >> std::noskipws >> 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 = negative_op 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;\
}\
}
#define YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(type)\
YAML_DEFINE_CONVERT_STREAMABLE(type, -)
#define YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(type)\
YAML_DEFINE_CONVERT_STREAMABLE(type, +)
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED
(
int
);
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED
(
short
);
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED
(
long
);
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED
(
long
long
);
YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED
(
unsigned
);
YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED
(
unsigned
short
);
YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED
(
unsigned
long
);
YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED
(
unsigned
long
long
);
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED
(
char
);
YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED
(
unsigned
char
);
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED
(
float
);
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED
(
double
);
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED
(
long
double
);
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
;
}
};
// C-strings can only be encoded
template
<
>
struct
convert
<
const
char
*>
{
static
Node
encode
(
const
char
*&
rhs
)
{
return
Node
(
rhs
);
}
};
template
<
std
::
size_t
N
>
struct
convert
<
const
char
[
N
]
>
{
static
Node
encode
(
const
char
(
&
rhs
)[
N
])
{
return
Node
(
rhs
);
}
};
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, negative_op) \
template <> \
struct convert<type> { \
static Node encode(const type& rhs) { \
std::stringstream stream; \
stream.precision(std::numeric_limits<type>::digits10 + 1); \
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 >> std::noskipws >> 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 = negative_op 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; \
} \
}
#define YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(type) \
YAML_DEFINE_CONVERT_STREAMABLE(type, -)
#define YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(type) \
YAML_DEFINE_CONVERT_STREAMABLE(type, +)
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED
(
int
);
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED
(
short
);
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED
(
long
);
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED
(
long
long
);
YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED
(
unsigned
);
YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED
(
unsigned
short
);
YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED
(
unsigned
long
);
YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED
(
unsigned
long
long
);
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED
(
char
);
YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED
(
unsigned
char
);
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED
(
float
);
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED
(
double
);
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED
(
long
double
);
#undef YAML_DEFINE_CONVERT_STREAMABLE_SIGNED
#undef YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED
#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
.
force_insert
(
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
)
// 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
.
force_insert
(
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
)
#if defined(__GNUC__) && __GNUC__ < 4
//workaround for GCC 3:
rhs
[
it
->
first
.
template
as
<
K
>()]
=
it
->
second
.
template
as
<
V
>();
//
workaround for GCC 3:
rhs
[
it
->
first
.
template
as
<
K
>()]
=
it
->
second
.
template
as
<
V
>();
#else
rhs
[
it
->
first
.
as
<
K
>
()]
=
it
->
second
.
as
<
V
>
();
rhs
[
it
->
first
.
as
<
K
>
()]
=
it
->
second
.
as
<
V
>
();
#endif
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
.
push_back
(
*
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
)
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
.
push_back
(
*
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
)
#if defined(__GNUC__) && __GNUC__ < 4
//workaround for GCC 3:
rhs
.
push_back
(
it
->
template
as
<
T
>());
//
workaround for GCC 3:
rhs
.
push_back
(
it
->
template
as
<
T
>());
#else
rhs
.
push_back
(
it
->
as
<
T
>
());
rhs
.
push_back
(
it
->
as
<
T
>
());
#endif
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
.
push_back
(
*
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
)
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
.
push_back
(
*
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
)
#if defined(__GNUC__) && __GNUC__ < 4
//workaround for GCC 3:
rhs
.
push_back
(
it
->
template
as
<
T
>());
//
workaround for GCC 3:
rhs
.
push_back
(
it
->
template
as
<
T
>());
#else
rhs
.
push_back
(
it
->
as
<
T
>
());
rhs
.
push_back
(
it
->
as
<
T
>
());
#endif
return
true
;
}
};
// std::pair
template
<
typename
T
,
typename
U
>
struct
convert
<
std
::
pair
<
T
,
U
>
>
{
static
Node
encode
(
const
std
::
pair
<
T
,
U
>&
rhs
)
{
Node
node
(
NodeType
::
Sequence
);
node
.
push_back
(
rhs
.
first
);
node
.
push_back
(
rhs
.
second
);
return
node
;
}
static
bool
decode
(
const
Node
&
node
,
std
::
pair
<
T
,
U
>&
rhs
)
{
if
(
!
node
.
IsSequence
())
return
false
;
if
(
node
.
size
()
!=
2
)
return
false
;
return
true
;
}
};
// std::pair
template
<
typename
T
,
typename
U
>
struct
convert
<
std
::
pair
<
T
,
U
>
>
{
static
Node
encode
(
const
std
::
pair
<
T
,
U
>&
rhs
)
{
Node
node
(
NodeType
::
Sequence
);
node
.
push_back
(
rhs
.
first
);
node
.
push_back
(
rhs
.
second
);
return
node
;
}
static
bool
decode
(
const
Node
&
node
,
std
::
pair
<
T
,
U
>&
rhs
)
{
if
(
!
node
.
IsSequence
())
return
false
;
if
(
node
.
size
()
!=
2
)
return
false
;
#if defined(__GNUC__) && __GNUC__ < 4
//workaround for GCC 3:
rhs
.
first
=
node
[
0
].
template
as
<
T
>();
//
workaround for GCC 3:
rhs
.
first
=
node
[
0
].
template
as
<
T
>();
#else
rhs
.
first
=
node
[
0
].
as
<
T
>
();
rhs
.
first
=
node
[
0
].
as
<
T
>
();
#endif
#if defined(__GNUC__) && __GNUC__ < 4
//workaround for GCC 3:
rhs
.
second
=
node
[
1
].
template
as
<
U
>();
//
workaround for GCC 3:
rhs
.
second
=
node
[
1
].
template
as
<
U
>();
#else
rhs
.
second
=
node
[
1
].
as
<
U
>
();
rhs
.
second
=
node
[
1
].
as
<
U
>
();
#endif
return
true
;
}
};
// binary
template
<
>
struct
convert
<
Binary
>
{
static
Node
encode
(
const
Binary
&
rhs
)
{
return
Node
(
EncodeBase64
(
rhs
.
data
(),
rhs
.
size
()));
}
static
bool
decode
(
const
Node
&
node
,
Binary
&
rhs
)
{
if
(
!
node
.
IsScalar
())
return
false
;
std
::
vector
<
unsigned
char
>
data
=
DecodeBase64
(
node
.
Scalar
());
if
(
data
.
empty
()
&&
!
node
.
Scalar
().
empty
())
return
false
;
rhs
.
swap
(
data
);
return
true
;
}
};
return
true
;
}
};
// binary
template
<
>
struct
convert
<
Binary
>
{
static
Node
encode
(
const
Binary
&
rhs
)
{
return
Node
(
EncodeBase64
(
rhs
.
data
(),
rhs
.
size
()));
}
static
bool
decode
(
const
Node
&
node
,
Binary
&
rhs
)
{
if
(
!
node
.
IsScalar
())
return
false
;
std
::
vector
<
unsigned
char
>
data
=
DecodeBase64
(
node
.
Scalar
());
if
(
data
.
empty
()
&&
!
node
.
Scalar
().
empty
())
return
false
;
rhs
.
swap
(
data
);
return
true
;
}
};
}
#endif // NODE_CONVERT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif
// NODE_CONVERT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/detail/bool_type.h
View file @
d63ec48c
#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
#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
*
);
}
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
#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
View file @
d63ec48c
#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
#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_c
<
boost
::
is_unsigned
<
Key
>::
value
&&
!
boost
::
is_same
<
Key
,
bool
>::
value
>::
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
BadSubscript
();
}
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
BadSubscript
();
}
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
;
}
// map
template
<
typename
Key
,
typename
Value
>
inline
void
node_data
::
force_insert
(
const
Key
&
key
,
const
Value
&
value
,
shared_memory_holder
pMemory
)
{
switch
(
m_type
)
{
case
NodeType
::
Map
:
break
;
case
NodeType
::
Undefined
:
case
NodeType
::
Null
:
case
NodeType
::
Sequence
:
convert_to_map
(
pMemory
);
break
;
case
NodeType
::
Scalar
:
throw
BadInsert
();
}
node
&
k
=
convert_to_node
(
key
,
pMemory
);
node
&
v
=
convert_to_node
(
value
,
pMemory
);
insert_map_pair
(
k
,
v
);
}
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
;
}
inline
bool
node_data
::
equals
(
node
&
node
,
const
char
*
rhs
,
shared_memory_holder
pMemory
)
{
return
equals
<
std
::
string
>
(
node
,
rhs
,
pMemory
);
}
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
;
}
}
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_c
<
boost
::
is_unsigned
<
Key
>::
value
&&
!
boost
::
is_same
<
Key
,
bool
>::
value
>::
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
BadSubscript
();
}
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
BadSubscript
();
}
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
;
}
// map
template
<
typename
Key
,
typename
Value
>
inline
void
node_data
::
force_insert
(
const
Key
&
key
,
const
Value
&
value
,
shared_memory_holder
pMemory
)
{
switch
(
m_type
)
{
case
NodeType
::
Map
:
break
;
case
NodeType
::
Undefined
:
case
NodeType
::
Null
:
case
NodeType
::
Sequence
:
convert_to_map
(
pMemory
);
break
;
case
NodeType
::
Scalar
:
throw
BadInsert
();
}
node
&
k
=
convert_to_node
(
key
,
pMemory
);
node
&
v
=
convert_to_node
(
value
,
pMemory
);
insert_map_pair
(
k
,
v
);
}
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
;
}
inline
bool
node_data
::
equals
(
node
&
node
,
const
char
*
rhs
,
shared_memory_holder
pMemory
)
{
return
equals
<
std
::
string
>
(
node
,
rhs
,
pMemory
);
}
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
#endif
// NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/detail/iterator.h
View file @
d63ec48c
#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
#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
;
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
::
base_type
base_type
;
public:
typedef
typename
iterator_base
::
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
<
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
::
base_type
base_type
;
public:
typedef
typename
iterator_base
::
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
;
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
)
{}
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
;
};
}
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
#endif
// VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/detail/iterator_fwd.h
View file @
d63ec48c
#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
#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
;
}
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
;
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
#endif
// VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/detail/memory.h
View file @
d63ec48c
#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
#if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once
#endif
...
...
@@ -9,31 +11,29 @@
#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
;
};
}
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
#endif
// VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/detail/node.h
View file @
d63ec48c
#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
#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"
...
...
@@ -13,118 +14,134 @@
#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
push_back
(
node
&
node
,
shared_memory_holder
pMemory
)
{
m_pRef
->
push_back
(
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
);
}
// map
template
<
typename
Key
,
typename
Value
>
void
force_insert
(
const
Key
&
key
,
const
Value
&
value
,
shared_memory_holder
pMemory
){
m_pRef
->
force_insert
(
key
,
value
,
pMemory
);
}
private:
shared_node_ref
m_pRef
;
typedef
std
::
set
<
node
*>
nodes
;
nodes
m_dependencies
;
};
}
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
push_back
(
node
&
node
,
shared_memory_holder
pMemory
)
{
m_pRef
->
push_back
(
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
);
}
// map
template
<
typename
Key
,
typename
Value
>
void
force_insert
(
const
Key
&
key
,
const
Value
&
value
,
shared_memory_holder
pMemory
)
{
m_pRef
->
force_insert
(
key
,
value
,
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
#endif
// NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/detail/node_data.h
View file @
d63ec48c
#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
#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"
...
...
@@ -15,96 +16,99 @@
#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
push_back
(
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
);
// map
template
<
typename
Key
,
typename
Value
>
void
force_insert
(
const
Key
&
key
,
const
Value
&
value
,
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
);
static
bool
equals
(
node
&
node
,
const
char
*
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
;
};
}
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
push_back
(
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
);
// map
template
<
typename
Key
,
typename
Value
>
void
force_insert
(
const
Key
&
key
,
const
Value
&
value
,
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
);
static
bool
equals
(
node
&
node
,
const
char
*
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
#endif
// VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/detail/node_iterator.h
View file @
d63ec48c
#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
#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>
...
...
@@ -14,126 +15,143 @@
#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
;
}
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
#endif
// VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/detail/node_ref.h
View file @
d63ec48c
#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
#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
();
}
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
();
}
// sequence
void
push_back
(
node
&
node
,
shared_memory_holder
pMemory
)
{
m_pData
->
push_back
(
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
);
}
// map
template
<
typename
Key
,
typename
Value
>
void
force_insert
(
const
Key
&
key
,
const
Value
&
value
,
shared_memory_holder
pMemory
)
{
m_pData
->
force_insert
(
key
,
value
,
pMemory
);
}
const_node_iterator
end
()
const
{
return
static_cast
<
const
node_data
&>
(
*
m_pData
).
end
();
}
node_iterator
end
()
{
return
m_pData
->
end
();
}
private:
shared_node_data
m_pData
;
};
}
// sequence
void
push_back
(
node
&
node
,
shared_memory_holder
pMemory
)
{
m_pData
->
push_back
(
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
);
}
// map
template
<
typename
Key
,
typename
Value
>
void
force_insert
(
const
Key
&
key
,
const
Value
&
value
,
shared_memory_holder
pMemory
)
{
m_pData
->
force_insert
(
key
,
value
,
pMemory
);
}
private:
shared_node_data
m_pData
;
};
}
}
#endif // VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif
// VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/emit.h
View file @
d63ec48c
#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
#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
);
}
namespace
YAML
{
class
Emitter
;
class
Node
;
Emitter
&
operator
<<
(
Emitter
&
out
,
const
Node
&
node
);
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
Node
&
node
);
#endif // NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
std
::
string
Dump
(
const
Node
&
node
);
}
#endif // NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/impl.h
View file @
d63ec48c
This diff is collapsed.
Click to expand it.
include/yaml-cpp/node/iterator.h
View file @
d63ec48c
#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
#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"
...
...
@@ -14,15 +15,17 @@
#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
),
std
::
pair
<
Node
,
Node
>
(
Node
(
Node
::
ZombieNode
),
Node
(
Node
::
ZombieNode
))
{}
explicit
iterator_value
(
const
Node
&
key
,
const
Node
&
value
)
:
Node
(
Node
::
ZombieNode
),
std
::
pair
<
Node
,
Node
>
(
key
,
value
)
{}
};
}
namespace
YAML
{
namespace
detail
{
struct
iterator_value
:
public
Node
,
std
::
pair
<
Node
,
Node
>
{
iterator_value
()
{}
explicit
iterator_value
(
const
Node
&
rhs
)
:
Node
(
rhs
),
std
::
pair
<
Node
,
Node
>
(
Node
(
Node
::
ZombieNode
),
Node
(
Node
::
ZombieNode
))
{}
explicit
iterator_value
(
const
Node
&
key
,
const
Node
&
value
)
:
Node
(
Node
::
ZombieNode
),
std
::
pair
<
Node
,
Node
>
(
key
,
value
)
{}
};
}
}
#endif // VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif
// VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/node.h
View file @
d63ec48c
#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
#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"
...
...
@@ -13,104 +14,115 @@
#include "yaml-cpp/node/detail/bool_type.h"
#include <stdexcept>
namespace
YAML
{
class
Node
{
public:
friend
class
NodeBuilder
;
friend
class
NodeEvents
;
friend
struct
detail
::
iterator_value
;
friend
class
detail
::
node_data
;
template
<
typename
>
friend
class
detail
::
iterator_base
;
template
<
typename
T
,
typename
S
>
friend
struct
as_if
;
typedef
YAML
::
iterator
iterator
;
typedef
YAML
::
const_iterator
const_iterator
;
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
);
void
reset
(
const
Node
&
rhs
=
Node
());
// size/iterator
std
::
size_t
size
()
const
;
const_iterator
begin
()
const
;
iterator
begin
();
const_iterator
end
()
const
;
iterator
end
();
// sequence
template
<
typename
T
>
void
push_back
(
const
T
&
rhs
);
void
push_back
(
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
);
// map
template
<
typename
Key
,
typename
Value
>
void
force_insert
(
const
Key
&
key
,
const
Value
&
value
);
private:
enum
Zombie
{
ZombieNode
};
explicit
Node
(
Zombie
);
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:
bool
m_isValid
;
mutable
detail
::
shared_memory_holder
m_pMemory
;
mutable
detail
::
node
*
m_pNode
;
};
bool
operator
==
(
const
Node
&
lhs
,
const
Node
&
rhs
);
Node
Clone
(
const
Node
&
node
);
template
<
typename
T
>
struct
convert
;
namespace
YAML
{
class
Node
{
public:
friend
class
NodeBuilder
;
friend
class
NodeEvents
;
friend
struct
detail
::
iterator_value
;
friend
class
detail
::
node_data
;
template
<
typename
>
friend
class
detail
::
iterator_base
;
template
<
typename
T
,
typename
S
>
friend
struct
as_if
;
typedef
YAML
::
iterator
iterator
;
typedef
YAML
::
const_iterator
const_iterator
;
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
);
void
reset
(
const
Node
&
rhs
=
Node
());
// size/iterator
std
::
size_t
size
()
const
;
const_iterator
begin
()
const
;
iterator
begin
();
const_iterator
end
()
const
;
iterator
end
();
// sequence
template
<
typename
T
>
void
push_back
(
const
T
&
rhs
);
void
push_back
(
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
);
// map
template
<
typename
Key
,
typename
Value
>
void
force_insert
(
const
Key
&
key
,
const
Value
&
value
);
private:
enum
Zombie
{
ZombieNode
};
explicit
Node
(
Zombie
);
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:
bool
m_isValid
;
mutable
detail
::
shared_memory_holder
m_pMemory
;
mutable
detail
::
node
*
m_pNode
;
};
bool
operator
==
(
const
Node
&
lhs
,
const
Node
&
rhs
);
Node
Clone
(
const
Node
&
node
);
template
<
typename
T
>
struct
convert
;
}
#endif // NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif
// NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/parse.h
View file @
d63ec48c
#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
#if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once
#endif
...
...
@@ -9,20 +11,18 @@
#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
);
namespace
YAML
{
class
Node
;
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
);
}
Node
Load
(
const
std
::
string
&
input
);
Node
Load
(
const
char
*
input
);
Node
Load
(
std
::
istream
&
input
);
Node
LoadFile
(
const
std
::
string
&
filename
);
#endif // VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
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
View file @
d63ec48c
#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
#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
;
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
;
}
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
#endif
// VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/node/type.h
View file @
d63ec48c
#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
#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
};
};
namespace
YAML
{
struct
NodeType
{
enum
value
{
Undefined
,
Null
,
Scalar
,
Sequence
,
Map
};
};
}
#endif // VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif
// VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/parser.h
View file @
d63ec48c
#ifndef PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define PARSER_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
#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/noncopyable.h"
#include <ios>
#include <memory>
namespace
YAML
{
struct
Directives
;
struct
Token
;
class
EventHandler
;
class
Scanner
;
class
YAML_CPP_API
Parser
:
private
noncopyable
{
public:
Parser
();
Parser
(
std
::
istream
&
in
);
~
Parser
();
operator
bool
()
const
;
void
Load
(
std
::
istream
&
in
);
bool
HandleNextDocument
(
EventHandler
&
eventHandler
);
void
PrintTokens
(
std
::
ostream
&
out
);
private:
void
ParseDirectives
();
void
HandleDirective
(
const
Token
&
token
);
void
HandleYamlDirective
(
const
Token
&
token
);
void
HandleTagDirective
(
const
Token
&
token
);
private:
std
::
auto_ptr
<
Scanner
>
m_pScanner
;
std
::
auto_ptr
<
Directives
>
m_pDirectives
;
};
namespace
YAML
{
struct
Directives
;
struct
Token
;
class
EventHandler
;
class
Scanner
;
class
YAML_CPP_API
Parser
:
private
noncopyable
{
public:
Parser
();
Parser
(
std
::
istream
&
in
);
~
Parser
();
operator
bool
()
const
;
void
Load
(
std
::
istream
&
in
);
bool
HandleNextDocument
(
EventHandler
&
eventHandler
);
void
PrintTokens
(
std
::
ostream
&
out
);
private:
void
ParseDirectives
();
void
HandleDirective
(
const
Token
&
token
);
void
HandleYamlDirective
(
const
Token
&
token
);
void
HandleTagDirective
(
const
Token
&
token
);
private:
std
::
auto_ptr
<
Scanner
>
m_pScanner
;
std
::
auto_ptr
<
Directives
>
m_pDirectives
;
};
}
#endif // PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif
// PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
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