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
3355bbb3
Commit
3355bbb3
authored
Mar 22, 2014
by
Jesse Beder
Browse files
Merge clang-format from core
parents
5b889311
9b4db068
Changes
72
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1156 additions
and
1002 deletions
+1156
-1002
include/yaml-cpp/anchor.h
include/yaml-cpp/anchor.h
+7
-6
include/yaml-cpp/binary.h
include/yaml-cpp/binary.h
+53
-51
include/yaml-cpp/contrib/anchordict.h
include/yaml-cpp/contrib/anchordict.h
+24
-29
include/yaml-cpp/contrib/graphbuilder.h
include/yaml-cpp/contrib/graphbuilder.h
+135
-121
include/yaml-cpp/dll.h
include/yaml-cpp/dll.h
+26
-17
include/yaml-cpp/emitfromevents.h
include/yaml-cpp/emitfromevents.h
+43
-34
include/yaml-cpp/emitter.h
include/yaml-cpp/emitter.h
+230
-192
include/yaml-cpp/emitterdef.h
include/yaml-cpp/emitterdef.h
+16
-5
include/yaml-cpp/emittermanip.h
include/yaml-cpp/emittermanip.h
+130
-138
include/yaml-cpp/eventhandler.h
include/yaml-cpp/eventhandler.h
+27
-25
include/yaml-cpp/mark.h
include/yaml-cpp/mark.h
+17
-16
include/yaml-cpp/noncopyable.h
include/yaml-cpp/noncopyable.h
+15
-15
include/yaml-cpp/null.h
include/yaml-cpp/null.h
+14
-15
include/yaml-cpp/ostream_wrapper.h
include/yaml-cpp/ostream_wrapper.h
+56
-55
include/yaml-cpp/stlemitter.h
include/yaml-cpp/stlemitter.h
+38
-38
include/yaml-cpp/traits.h
include/yaml-cpp/traits.h
+117
-39
src/binary.cpp
src/binary.cpp
+85
-86
src/collectionstack.h
src/collectionstack.h
+34
-23
src/contrib/graphbuilder.cpp
src/contrib/graphbuilder.cpp
+9
-10
src/contrib/graphbuilderadapter.cpp
src/contrib/graphbuilderadapter.cpp
+80
-87
No files found.
include/yaml-cpp/anchor.h
View file @
3355bbb3
#ifndef ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define ANCHOR_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 <cstddef>
namespace
YAML
{
typedef
std
::
size_t
anchor_t
;
const
anchor_t
NullAnchor
=
0
;
namespace
YAML
{
typedef
std
::
size_t
anchor_t
;
const
anchor_t
NullAnchor
=
0
;
}
#endif // ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif
// ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/binary.h
View file @
3355bbb3
#ifndef BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define BASE64_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 <vector>
namespace
YAML
{
std
::
string
EncodeBase64
(
const
unsigned
char
*
data
,
std
::
size_t
size
);
std
::
vector
<
unsigned
char
>
DecodeBase64
(
const
std
::
string
&
input
);
class
Binary
{
public:
Binary
(
)
:
m_unownedData
(
0
),
m_unownedSize
(
0
)
{}
Binary
(
const
unsigned
char
*
data_
,
std
::
size_t
size_
)
:
m_unownedData
(
data_
),
m_unownedSize
(
size_
)
{}
bool
owned
()
const
{
return
!
m_unownedData
;
}
std
::
size_t
size
()
const
{
return
owned
()
?
m_data
.
size
()
:
m_unownedSize
;
}
const
unsigned
char
*
data
()
const
{
return
owned
()
?
&
m_data
[
0
]
:
m_unownedData
;
}
void
swap
(
std
::
vector
<
unsigned
char
>&
rhs
)
{
if
(
m_unownedData
)
{
m_data
.
swap
(
rhs
)
;
rhs
.
clear
();
rhs
.
resize
(
m_unownedSize
);
std
::
copy
(
m_unownedData
,
m_unownedData
+
m_unownedSize
,
&
rhs
[
0
]
);
m_unowned
Data
=
0
;
m_unownedSize
=
0
;
}
else
{
m_data
.
swap
(
rhs
)
;
}
}
bool
operator
==
(
const
Binary
&
rhs
)
const
{
const
std
::
size_t
s
=
size
();
if
(
s
!=
rhs
.
size
())
return
false
;
const
unsigned
char
*
d1
=
data
()
;
const
unsigned
char
*
d2
=
rhs
.
data
()
;
for
(
std
::
size_t
i
=
0
;
i
<
s
;
i
++
)
{
if
(
*
d1
++
!=
*
d2
++
)
return
false
;
}
return
tru
e
;
}
bool
operator
!=
(
const
Binary
&
rhs
)
const
{
return
!
(
*
this
==
rhs
);
}
private:
std
::
vector
<
unsigned
char
>
m_data
;
const
unsigned
char
*
m_unownedData
;
std
::
size_t
m_unownedSize
;
};
namespace
YAML
{
std
::
string
EncodeBase64
(
const
unsigned
char
*
data
,
std
::
size_t
size
);
std
::
vector
<
unsigned
char
>
DecodeBase64
(
const
std
::
string
&
input
);
class
Binary
{
public:
Binary
()
:
m_unownedData
(
0
),
m_unownedSize
(
0
)
{}
Binary
(
const
unsigned
char
*
data_
,
std
::
size_t
size_
)
:
m_unownedData
(
data_
),
m_unownedSize
(
size_
)
{}
bool
owned
()
const
{
return
!
m_unownedData
;
}
std
::
size_t
size
()
const
{
return
owned
()
?
m_data
.
size
()
:
m_unownedSize
;
}
const
unsigned
char
*
data
()
const
{
return
owned
()
?
&
m_data
[
0
]
:
m_unownedData
;
}
void
swap
(
std
::
vector
<
unsigned
char
>
&
rhs
)
{
if
(
m_unownedData
)
{
m_data
.
swap
(
rhs
);
rhs
.
clear
(
);
rhs
.
resize
(
m_unowned
Size
)
;
std
::
copy
(
m_unownedData
,
m_unownedData
+
m_unownedSize
,
&
rhs
[
0
])
;
m_unownedData
=
0
;
m_unownedSize
=
0
;
}
else
{
m_data
.
swap
(
rhs
);
}
}
bool
operator
==
(
const
Binary
&
rhs
)
const
{
const
std
::
size_t
s
=
size
()
;
if
(
s
!=
rhs
.
size
()
)
return
false
;
const
unsigned
char
*
d1
=
data
();
const
unsigned
char
*
d2
=
rhs
.
data
();
for
(
std
::
size_t
i
=
0
;
i
<
s
;
i
++
)
{
if
(
*
d1
++
!=
*
d2
++
)
return
fals
e
;
}
return
true
;
}
bool
operator
!=
(
const
Binary
&
rhs
)
const
{
return
!
(
*
this
==
rhs
);
}
private:
std
::
vector
<
unsigned
char
>
m_data
;
const
unsigned
char
*
m_unownedData
;
std
::
size_t
m_unownedSize
;
};
}
#endif // BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif
// BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/contrib/anchordict.h
View file @
3355bbb3
#ifndef ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define ANCHORDICT_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,34 +11,27 @@
#include "../anchor.h"
namespace
YAML
{
/// AnchorDict
/// . An object that stores and retrieves values correlating to anchor_t
/// values.
/// . Efficient implementation that can make assumptions about how anchor_t
/// values are assigned by the Parser class.
template
<
class
T
>
class
AnchorDict
{
public:
void
Register
(
anchor_t
anchor
,
T
value
)
{
if
(
anchor
>
m_data
.
size
())
{
m_data
.
resize
(
anchor
);
}
m_data
[
anchor
-
1
]
=
value
;
namespace
YAML
{
/// AnchorDict
/// . An object that stores and retrieves values correlating to anchor_t
/// values.
/// . Efficient implementation that can make assumptions about how anchor_t
/// values are assigned by the Parser class.
template
<
class
T
>
class
AnchorDict
{
public:
void
Register
(
anchor_t
anchor
,
T
value
)
{
if
(
anchor
>
m_data
.
size
())
{
m_data
.
resize
(
anchor
);
}
T
Get
(
anchor_t
anchor
)
const
{
return
m_data
[
anchor
-
1
];
}
private:
std
::
vector
<
T
>
m_data
;
};
m_data
[
anchor
-
1
]
=
value
;
}
T
Get
(
anchor_t
anchor
)
const
{
return
m_data
[
anchor
-
1
];
}
private:
std
::
vector
<
T
>
m_data
;
};
}
#endif // ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif
// ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/contrib/graphbuilder.h
View file @
3355bbb3
#ifndef GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define GRAPHBUILDER_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 <string>
namespace
YAML
{
class
Parser
;
// GraphBuilderInterface
// . Abstraction of node creation
// . pParentNode is always NULL or the return value of one of the NewXXX()
// functions.
class
GraphBuilderInterface
{
public:
// Create and return a new node with a null value.
virtual
void
*
NewNull
(
const
Mark
&
mark
,
void
*
pParentNode
)
=
0
;
// Create and return a new node with the given tag and value.
virtual
void
*
NewScalar
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
void
*
pParentNode
,
const
std
::
string
&
value
)
=
0
;
// Create and return a new sequence node
virtual
void
*
NewSequence
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
void
*
pParentNode
)
=
0
;
// Add pNode to pSequence. pNode was created with one of the NewXxx()
// functions and pSequence with NewSequence().
virtual
void
AppendToSequence
(
void
*
pSequence
,
void
*
pNode
)
=
0
;
// Note that no moew entries will be added to pSequence
virtual
void
SequenceComplete
(
void
*
pSequence
)
{(
void
)
pSequence
;}
// Create and return a new map node
virtual
void
*
NewMap
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
void
*
pParentNode
)
=
0
;
// Add the pKeyNode => pValueNode mapping to pMap. pKeyNode and pValueNode
// were created with one of the NewXxx() methods and pMap with NewMap().
virtual
void
AssignInMap
(
void
*
pMap
,
void
*
pKeyNode
,
void
*
pValueNode
)
=
0
;
// Note that no more assignments will be made in pMap
virtual
void
MapComplete
(
void
*
pMap
)
{(
void
)
pMap
;}
// Return the node that should be used in place of an alias referencing
// pNode (pNode by default)
virtual
void
*
AnchorReference
(
const
Mark
&
mark
,
void
*
pNode
)
{(
void
)
mark
;
return
pNode
;}
};
// Typesafe wrapper for GraphBuilderInterface. Assumes that Impl defines
// Node, Sequence, and Map types. Sequence and Map must derive from Node
// (unless Node is defined as void). Impl must also implement function with
// all of the same names as the virtual functions in GraphBuilderInterface
// -- including the ones with default implementations -- but with the
// prototypes changed to accept an explicit Node*, Sequence*, or Map* where
// appropriate.
template
<
class
Impl
>
class
GraphBuilder
:
public
GraphBuilderInterface
{
public:
typedef
typename
Impl
::
Node
Node
;
typedef
typename
Impl
::
Sequence
Sequence
;
typedef
typename
Impl
::
Map
Map
;
GraphBuilder
(
Impl
&
impl
)
:
m_impl
(
impl
)
{
Map
*
pMap
=
NULL
;
Sequence
*
pSeq
=
NULL
;
Node
*
pNode
=
NULL
;
// Type consistency checks
pNode
=
pMap
;
pNode
=
pSeq
;
}
GraphBuilderInterface
&
AsBuilderInterface
()
{
return
*
this
;}
virtual
void
*
NewNull
(
const
Mark
&
mark
,
void
*
pParentNode
)
{
return
CheckType
<
Node
>
(
m_impl
.
NewNull
(
mark
,
AsNode
(
pParentNode
)));
}
virtual
void
*
NewScalar
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
void
*
pParentNode
,
const
std
::
string
&
value
)
{
return
CheckType
<
Node
>
(
m_impl
.
NewScalar
(
mark
,
tag
,
AsNode
(
pParentNode
),
value
));
}
virtual
void
*
NewSequence
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
void
*
pParentNode
)
{
return
CheckType
<
Sequence
>
(
m_impl
.
NewSequence
(
mark
,
tag
,
AsNode
(
pParentNode
)));
}
virtual
void
AppendToSequence
(
void
*
pSequence
,
void
*
pNode
)
{
m_impl
.
AppendToSequence
(
AsSequence
(
pSequence
),
AsNode
(
pNode
));
}
virtual
void
SequenceComplete
(
void
*
pSequence
)
{
m_impl
.
SequenceComplete
(
AsSequence
(
pSequence
));
}
virtual
void
*
NewMap
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
void
*
pParentNode
)
{
return
CheckType
<
Map
>
(
m_impl
.
NewMap
(
mark
,
tag
,
AsNode
(
pParentNode
)));
}
virtual
void
AssignInMap
(
void
*
pMap
,
void
*
pKeyNode
,
void
*
pValueNode
)
{
m_impl
.
AssignInMap
(
AsMap
(
pMap
),
AsNode
(
pKeyNode
),
AsNode
(
pValueNode
));
}
virtual
void
MapComplete
(
void
*
pMap
)
{
m_impl
.
MapComplete
(
AsMap
(
pMap
));
}
virtual
void
*
AnchorReference
(
const
Mark
&
mark
,
void
*
pNode
)
{
return
CheckType
<
Node
>
(
m_impl
.
AnchorReference
(
mark
,
AsNode
(
pNode
)));
}
private:
Impl
&
m_impl
;
// Static check for pointer to T
template
<
class
T
,
class
U
>
static
T
*
CheckType
(
U
*
p
)
{
return
p
;}
static
Node
*
AsNode
(
void
*
pNode
)
{
return
static_cast
<
Node
*>
(
pNode
);}
static
Sequence
*
AsSequence
(
void
*
pSeq
)
{
return
static_cast
<
Sequence
*>
(
pSeq
);}
static
Map
*
AsMap
(
void
*
pMap
)
{
return
static_cast
<
Map
*>
(
pMap
);}
};
void
*
BuildGraphOfNextDocument
(
Parser
&
parser
,
GraphBuilderInterface
&
graphBuilder
);
template
<
class
Impl
>
typename
Impl
::
Node
*
BuildGraphOfNextDocument
(
Parser
&
parser
,
Impl
&
impl
)
{
GraphBuilder
<
Impl
>
graphBuilder
(
impl
);
return
static_cast
<
typename
Impl
::
Node
*>
(
BuildGraphOfNextDocument
(
parser
,
graphBuilder
));
namespace
YAML
{
class
Parser
;
// GraphBuilderInterface
// . Abstraction of node creation
// . pParentNode is always NULL or the return value of one of the NewXXX()
// functions.
class
GraphBuilderInterface
{
public:
// Create and return a new node with a null value.
virtual
void
*
NewNull
(
const
Mark
&
mark
,
void
*
pParentNode
)
=
0
;
// Create and return a new node with the given tag and value.
virtual
void
*
NewScalar
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
void
*
pParentNode
,
const
std
::
string
&
value
)
=
0
;
// Create and return a new sequence node
virtual
void
*
NewSequence
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
void
*
pParentNode
)
=
0
;
// Add pNode to pSequence. pNode was created with one of the NewXxx()
// functions and pSequence with NewSequence().
virtual
void
AppendToSequence
(
void
*
pSequence
,
void
*
pNode
)
=
0
;
// Note that no moew entries will be added to pSequence
virtual
void
SequenceComplete
(
void
*
pSequence
)
{
(
void
)
pSequence
;
}
// Create and return a new map node
virtual
void
*
NewMap
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
void
*
pParentNode
)
=
0
;
// Add the pKeyNode => pValueNode mapping to pMap. pKeyNode and pValueNode
// were created with one of the NewXxx() methods and pMap with NewMap().
virtual
void
AssignInMap
(
void
*
pMap
,
void
*
pKeyNode
,
void
*
pValueNode
)
=
0
;
// Note that no more assignments will be made in pMap
virtual
void
MapComplete
(
void
*
pMap
)
{
(
void
)
pMap
;
}
// Return the node that should be used in place of an alias referencing
// pNode (pNode by default)
virtual
void
*
AnchorReference
(
const
Mark
&
mark
,
void
*
pNode
)
{
(
void
)
mark
;
return
pNode
;
}
};
// Typesafe wrapper for GraphBuilderInterface. Assumes that Impl defines
// Node, Sequence, and Map types. Sequence and Map must derive from Node
// (unless Node is defined as void). Impl must also implement function with
// all of the same names as the virtual functions in GraphBuilderInterface
// -- including the ones with default implementations -- but with the
// prototypes changed to accept an explicit Node*, Sequence*, or Map* where
// appropriate.
template
<
class
Impl
>
class
GraphBuilder
:
public
GraphBuilderInterface
{
public:
typedef
typename
Impl
::
Node
Node
;
typedef
typename
Impl
::
Sequence
Sequence
;
typedef
typename
Impl
::
Map
Map
;
GraphBuilder
(
Impl
&
impl
)
:
m_impl
(
impl
)
{
Map
*
pMap
=
NULL
;
Sequence
*
pSeq
=
NULL
;
Node
*
pNode
=
NULL
;
// Type consistency checks
pNode
=
pMap
;
pNode
=
pSeq
;
}
GraphBuilderInterface
&
AsBuilderInterface
()
{
return
*
this
;
}
virtual
void
*
NewNull
(
const
Mark
&
mark
,
void
*
pParentNode
)
{
return
CheckType
<
Node
>
(
m_impl
.
NewNull
(
mark
,
AsNode
(
pParentNode
)));
}
virtual
void
*
NewScalar
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
void
*
pParentNode
,
const
std
::
string
&
value
)
{
return
CheckType
<
Node
>
(
m_impl
.
NewScalar
(
mark
,
tag
,
AsNode
(
pParentNode
),
value
));
}
virtual
void
*
NewSequence
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
void
*
pParentNode
)
{
return
CheckType
<
Sequence
>
(
m_impl
.
NewSequence
(
mark
,
tag
,
AsNode
(
pParentNode
)));
}
virtual
void
AppendToSequence
(
void
*
pSequence
,
void
*
pNode
)
{
m_impl
.
AppendToSequence
(
AsSequence
(
pSequence
),
AsNode
(
pNode
));
}
virtual
void
SequenceComplete
(
void
*
pSequence
)
{
m_impl
.
SequenceComplete
(
AsSequence
(
pSequence
));
}
virtual
void
*
NewMap
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
void
*
pParentNode
)
{
return
CheckType
<
Map
>
(
m_impl
.
NewMap
(
mark
,
tag
,
AsNode
(
pParentNode
)));
}
virtual
void
AssignInMap
(
void
*
pMap
,
void
*
pKeyNode
,
void
*
pValueNode
)
{
m_impl
.
AssignInMap
(
AsMap
(
pMap
),
AsNode
(
pKeyNode
),
AsNode
(
pValueNode
));
}
virtual
void
MapComplete
(
void
*
pMap
)
{
m_impl
.
MapComplete
(
AsMap
(
pMap
));
}
virtual
void
*
AnchorReference
(
const
Mark
&
mark
,
void
*
pNode
)
{
return
CheckType
<
Node
>
(
m_impl
.
AnchorReference
(
mark
,
AsNode
(
pNode
)));
}
private:
Impl
&
m_impl
;
// Static check for pointer to T
template
<
class
T
,
class
U
>
static
T
*
CheckType
(
U
*
p
)
{
return
p
;
}
static
Node
*
AsNode
(
void
*
pNode
)
{
return
static_cast
<
Node
*>
(
pNode
);
}
static
Sequence
*
AsSequence
(
void
*
pSeq
)
{
return
static_cast
<
Sequence
*>
(
pSeq
);
}
static
Map
*
AsMap
(
void
*
pMap
)
{
return
static_cast
<
Map
*>
(
pMap
);
}
};
void
*
BuildGraphOfNextDocument
(
Parser
&
parser
,
GraphBuilderInterface
&
graphBuilder
);
template
<
class
Impl
>
typename
Impl
::
Node
*
BuildGraphOfNextDocument
(
Parser
&
parser
,
Impl
&
impl
)
{
GraphBuilder
<
Impl
>
graphBuilder
(
impl
);
return
static_cast
<
typename
Impl
::
Node
*>
(
BuildGraphOfNextDocument
(
parser
,
graphBuilder
));
}
}
#endif // GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif
// GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/dll.h
View file @
3355bbb3
#ifndef DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define DLL_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
// The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the yaml_cpp_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// YAML_CPP_API functions as being imported from a DLL, whereas this DLL sees symbols
// The following ifdef block is the standard way of creating macros which make
// exporting
// from a DLL simpler. All files within this DLL are compiled with the
// yaml_cpp_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any
// project
// that uses this DLL. This way any other project whose source files include
// this file see
// YAML_CPP_API functions as being imported from a DLL, whereas this DLL sees
// symbols
// defined with this macro as being exported.
#undef YAML_CPP_API
#ifdef YAML_CPP_DLL // Using or Building YAML-CPP DLL (definition defined manually)
#ifdef yaml_cpp_EXPORTS // Building YAML-CPP DLL (definition created by CMake or defined manually)
// #pragma message( "Defining YAML_CPP_API for DLL export" )
#define YAML_CPP_API __declspec(dllexport)
#else // yaml_cpp_EXPORTS
// #pragma message( "Defining YAML_CPP_API for DLL import" )
#define YAML_CPP_API __declspec(dllimport)
#endif // yaml_cpp_EXPORTS
#else //YAML_CPP_DLL
#ifdef YAML_CPP_DLL // Using or Building YAML-CPP DLL (definition defined
// manually)
#ifdef yaml_cpp_EXPORTS // Building YAML-CPP DLL (definition created by CMake
// or defined manually)
// #pragma message( "Defining YAML_CPP_API for DLL export" )
#define YAML_CPP_API __declspec(dllexport)
#else // yaml_cpp_EXPORTS
// #pragma message( "Defining YAML_CPP_API for DLL import" )
#define YAML_CPP_API __declspec(dllimport)
#endif // yaml_cpp_EXPORTS
#else // YAML_CPP_DLL
#define YAML_CPP_API
#endif // YAML_CPP_DLL
#endif
// YAML_CPP_DLL
#endif // DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif
// DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/emitfromevents.h
View file @
3355bbb3
#ifndef EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define EMITFROMEVENTS_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/eventhandler.h"
#include <stack>
namespace
YAML
{
class
Emitter
;
class
EmitFromEvents
:
public
EventHandler
{
public:
EmitFromEvents
(
Emitter
&
emitter
);
virtual
void
OnDocumentStart
(
const
Mark
&
mark
);
virtual
void
OnDocumentEnd
();
virtual
void
OnNull
(
const
Mark
&
mark
,
anchor_t
anchor
);
virtual
void
OnAlias
(
const
Mark
&
mark
,
anchor_t
anchor
);
virtual
void
OnScalar
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
anchor_t
anchor
,
const
std
::
string
&
value
);
virtual
void
OnSequenceStart
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
anchor_t
anchor
);
virtual
void
OnSequenceEnd
();
virtual
void
OnMapStart
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
anchor_t
anchor
);
virtual
void
OnMapEnd
();
private:
void
BeginNode
();
void
EmitProps
(
const
std
::
string
&
tag
,
anchor_t
anchor
);
private:
Emitter
&
m_emitter
;
struct
State
{
enum
value
{
WaitingForSequenceEntry
,
WaitingForKey
,
WaitingForValue
};
};
std
::
stack
<
State
::
value
>
m_stateStack
;
};
namespace
YAML
{
class
Emitter
;
class
EmitFromEvents
:
public
EventHandler
{
public:
EmitFromEvents
(
Emitter
&
emitter
);
virtual
void
OnDocumentStart
(
const
Mark
&
mark
);
virtual
void
OnDocumentEnd
();
virtual
void
OnNull
(
const
Mark
&
mark
,
anchor_t
anchor
);
virtual
void
OnAlias
(
const
Mark
&
mark
,
anchor_t
anchor
);
virtual
void
OnScalar
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
anchor_t
anchor
,
const
std
::
string
&
value
);
virtual
void
OnSequenceStart
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
anchor_t
anchor
);
virtual
void
OnSequenceEnd
();
virtual
void
OnMapStart
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
anchor_t
anchor
);
virtual
void
OnMapEnd
();
private:
void
BeginNode
();
void
EmitProps
(
const
std
::
string
&
tag
,
anchor_t
anchor
);
private:
Emitter
&
m_emitter
;
struct
State
{
enum
value
{
WaitingForSequenceEntry
,
WaitingForKey
,
WaitingForValue
};
};
std
::
stack
<
State
::
value
>
m_stateStack
;
};
}
#endif // EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif
// EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/emitter.h
View file @
3355bbb3
#ifndef EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define EMITTER_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/binary.h"
#include "yaml-cpp/emitterdef.h"
...
...
@@ -17,193 +18,230 @@
#include <string>
#include <sstream>
namespace
YAML
{
class
EmitterState
;
class
YAML_CPP_API
Emitter
:
private
noncopyable
{
public:
Emitter
();
explicit
Emitter
(
std
::
ostream
&
stream
);
~
Emitter
();
// output
const
char
*
c_str
()
const
;
std
::
size_t
size
()
const
;
// state checking
bool
good
()
const
;
const
std
::
string
GetLastError
()
const
;
// global setters
bool
SetOutputCharset
(
EMITTER_MANIP
value
);
bool
SetStringFormat
(
EMITTER_MANIP
value
);
bool
SetBoolFormat
(
EMITTER_MANIP
value
);
bool
SetIntBase
(
EMITTER_MANIP
value
);
bool
SetSeqFormat
(
EMITTER_MANIP
value
);
bool
SetMapFormat
(
EMITTER_MANIP
value
);
bool
SetIndent
(
unsigned
n
);
bool
SetPreCommentIndent
(
unsigned
n
);
bool
SetPostCommentIndent
(
unsigned
n
);
bool
SetFloatPrecision
(
unsigned
n
);
bool
SetDoublePrecision
(
unsigned
n
);
// local setters
Emitter
&
SetLocalValue
(
EMITTER_MANIP
value
);
Emitter
&
SetLocalIndent
(
const
_Indent
&
indent
);
Emitter
&
SetLocalPrecision
(
const
_Precision
&
precision
);
// overloads of write
Emitter
&
Write
(
const
std
::
string
&
str
);
Emitter
&
Write
(
bool
b
);
Emitter
&
Write
(
char
ch
);
Emitter
&
Write
(
const
_Alias
&
alias
);
Emitter
&
Write
(
const
_Anchor
&
anchor
);
Emitter
&
Write
(
const
_Tag
&
tag
);
Emitter
&
Write
(
const
_Comment
&
comment
);
Emitter
&
Write
(
const
_Null
&
n
);
Emitter
&
Write
(
const
Binary
&
binary
);
template
<
typename
T
>
Emitter
&
WriteIntegralType
(
T
value
);
template
<
typename
T
>
Emitter
&
WriteStreamable
(
T
value
);
private:
template
<
typename
T
>
void
SetStreamablePrecision
(
std
::
stringstream
&
)
{}
unsigned
GetFloatPrecision
()
const
;
unsigned
GetDoublePrecision
()
const
;
void
PrepareIntegralStream
(
std
::
stringstream
&
stream
)
const
;
void
StartedScalar
();
private:
void
EmitBeginDoc
();
void
EmitEndDoc
();
void
EmitBeginSeq
();
void
EmitEndSeq
();
void
EmitBeginMap
();
void
EmitEndMap
();
void
EmitNewline
();
void
EmitKindTag
();
void
EmitTag
(
bool
verbatim
,
const
_Tag
&
tag
);
void
PrepareNode
(
EmitterNodeType
::
value
child
);
void
PrepareTopNode
(
EmitterNodeType
::
value
child
);
void
FlowSeqPrepareNode
(
EmitterNodeType
::
value
child
);
void
BlockSeqPrepareNode
(
EmitterNodeType
::
value
child
);
void
FlowMapPrepareNode
(
EmitterNodeType
::
value
child
);
void
FlowMapPrepareLongKey
(
EmitterNodeType
::
value
child
);
void
FlowMapPrepareLongKeyValue
(
EmitterNodeType
::
value
child
);
void
FlowMapPrepareSimpleKey
(
EmitterNodeType
::
value
child
);
void
FlowMapPrepareSimpleKeyValue
(
EmitterNodeType
::
value
child
);
void
BlockMapPrepareNode
(
EmitterNodeType
::
value
child
);
void
BlockMapPrepareLongKey
(
EmitterNodeType
::
value
child
);
void
BlockMapPrepareLongKeyValue
(
EmitterNodeType
::
value
child
);
void
BlockMapPrepareSimpleKey
(
EmitterNodeType
::
value
child
);
void
BlockMapPrepareSimpleKeyValue
(
EmitterNodeType
::
value
child
);
void
SpaceOrIndentTo
(
bool
requireSpace
,
unsigned
indent
);
const
char
*
ComputeFullBoolName
(
bool
b
)
const
;
bool
CanEmitNewline
()
const
;
private:
std
::
auto_ptr
<
EmitterState
>
m_pState
;
ostream_wrapper
m_stream
;
};
template
<
typename
T
>
inline
Emitter
&
Emitter
::
WriteIntegralType
(
T
value
)
{
if
(
!
good
())
return
*
this
;
PrepareNode
(
EmitterNodeType
::
Scalar
);
std
::
stringstream
stream
;
PrepareIntegralStream
(
stream
);
stream
<<
value
;
m_stream
<<
stream
.
str
();
StartedScalar
();
return
*
this
;
}
template
<
typename
T
>
inline
Emitter
&
Emitter
::
WriteStreamable
(
T
value
)
{
if
(
!
good
())
return
*
this
;
PrepareNode
(
EmitterNodeType
::
Scalar
);
std
::
stringstream
stream
;
SetStreamablePrecision
<
T
>
(
stream
);
stream
<<
value
;
m_stream
<<
stream
.
str
();
StartedScalar
();
return
*
this
;
}
template
<
>
inline
void
Emitter
::
SetStreamablePrecision
<
float
>
(
std
::
stringstream
&
stream
)
{
stream
.
precision
(
GetFloatPrecision
());
}
template
<
>
inline
void
Emitter
::
SetStreamablePrecision
<
double
>
(
std
::
stringstream
&
stream
)
{
stream
.
precision
(
GetDoublePrecision
());
}
// overloads of insertion
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
const
std
::
string
&
v
)
{
return
emitter
.
Write
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
bool
v
)
{
return
emitter
.
Write
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
char
v
)
{
return
emitter
.
Write
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
unsigned
char
v
)
{
return
emitter
.
Write
(
static_cast
<
char
>
(
v
));
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
const
_Alias
&
v
)
{
return
emitter
.
Write
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
const
_Anchor
&
v
)
{
return
emitter
.
Write
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
const
_Tag
&
v
)
{
return
emitter
.
Write
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
const
_Comment
&
v
)
{
return
emitter
.
Write
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
const
_Null
&
v
)
{
return
emitter
.
Write
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
const
Binary
&
b
)
{
return
emitter
.
Write
(
b
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
const
char
*
v
)
{
return
emitter
.
Write
(
std
::
string
(
v
));
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
int
v
)
{
return
emitter
.
WriteIntegralType
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
unsigned
int
v
)
{
return
emitter
.
WriteIntegralType
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
short
v
)
{
return
emitter
.
WriteIntegralType
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
unsigned
short
v
)
{
return
emitter
.
WriteIntegralType
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
long
v
)
{
return
emitter
.
WriteIntegralType
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
unsigned
long
v
)
{
return
emitter
.
WriteIntegralType
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
long
long
v
)
{
return
emitter
.
WriteIntegralType
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
unsigned
long
long
v
)
{
return
emitter
.
WriteIntegralType
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
float
v
)
{
return
emitter
.
WriteStreamable
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
double
v
)
{
return
emitter
.
WriteStreamable
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
EMITTER_MANIP
value
)
{
return
emitter
.
SetLocalValue
(
value
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
_Indent
indent
)
{
return
emitter
.
SetLocalIndent
(
indent
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
_Precision
precision
)
{
return
emitter
.
SetLocalPrecision
(
precision
);
}
}
#endif // EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
namespace
YAML
{
class
EmitterState
;
class
YAML_CPP_API
Emitter
:
private
noncopyable
{
public:
Emitter
();
explicit
Emitter
(
std
::
ostream
&
stream
);
~
Emitter
();
// output
const
char
*
c_str
()
const
;
std
::
size_t
size
()
const
;
// state checking
bool
good
()
const
;
const
std
::
string
GetLastError
()
const
;
// global setters
bool
SetOutputCharset
(
EMITTER_MANIP
value
);
bool
SetStringFormat
(
EMITTER_MANIP
value
);
bool
SetBoolFormat
(
EMITTER_MANIP
value
);
bool
SetIntBase
(
EMITTER_MANIP
value
);
bool
SetSeqFormat
(
EMITTER_MANIP
value
);
bool
SetMapFormat
(
EMITTER_MANIP
value
);
bool
SetIndent
(
unsigned
n
);
bool
SetPreCommentIndent
(
unsigned
n
);
bool
SetPostCommentIndent
(
unsigned
n
);
bool
SetFloatPrecision
(
unsigned
n
);
bool
SetDoublePrecision
(
unsigned
n
);
// local setters
Emitter
&
SetLocalValue
(
EMITTER_MANIP
value
);
Emitter
&
SetLocalIndent
(
const
_Indent
&
indent
);
Emitter
&
SetLocalPrecision
(
const
_Precision
&
precision
);
// overloads of write
Emitter
&
Write
(
const
std
::
string
&
str
);
Emitter
&
Write
(
bool
b
);
Emitter
&
Write
(
char
ch
);
Emitter
&
Write
(
const
_Alias
&
alias
);
Emitter
&
Write
(
const
_Anchor
&
anchor
);
Emitter
&
Write
(
const
_Tag
&
tag
);
Emitter
&
Write
(
const
_Comment
&
comment
);
Emitter
&
Write
(
const
_Null
&
n
);
Emitter
&
Write
(
const
Binary
&
binary
);
template
<
typename
T
>
Emitter
&
WriteIntegralType
(
T
value
);
template
<
typename
T
>
Emitter
&
WriteStreamable
(
T
value
);
private:
template
<
typename
T
>
void
SetStreamablePrecision
(
std
::
stringstream
&
)
{}
unsigned
GetFloatPrecision
()
const
;
unsigned
GetDoublePrecision
()
const
;
void
PrepareIntegralStream
(
std
::
stringstream
&
stream
)
const
;
void
StartedScalar
();
private:
void
EmitBeginDoc
();
void
EmitEndDoc
();
void
EmitBeginSeq
();
void
EmitEndSeq
();
void
EmitBeginMap
();
void
EmitEndMap
();
void
EmitNewline
();
void
EmitKindTag
();
void
EmitTag
(
bool
verbatim
,
const
_Tag
&
tag
);
void
PrepareNode
(
EmitterNodeType
::
value
child
);
void
PrepareTopNode
(
EmitterNodeType
::
value
child
);
void
FlowSeqPrepareNode
(
EmitterNodeType
::
value
child
);
void
BlockSeqPrepareNode
(
EmitterNodeType
::
value
child
);
void
FlowMapPrepareNode
(
EmitterNodeType
::
value
child
);
void
FlowMapPrepareLongKey
(
EmitterNodeType
::
value
child
);
void
FlowMapPrepareLongKeyValue
(
EmitterNodeType
::
value
child
);
void
FlowMapPrepareSimpleKey
(
EmitterNodeType
::
value
child
);
void
FlowMapPrepareSimpleKeyValue
(
EmitterNodeType
::
value
child
);
void
BlockMapPrepareNode
(
EmitterNodeType
::
value
child
);
void
BlockMapPrepareLongKey
(
EmitterNodeType
::
value
child
);
void
BlockMapPrepareLongKeyValue
(
EmitterNodeType
::
value
child
);
void
BlockMapPrepareSimpleKey
(
EmitterNodeType
::
value
child
);
void
BlockMapPrepareSimpleKeyValue
(
EmitterNodeType
::
value
child
);
void
SpaceOrIndentTo
(
bool
requireSpace
,
unsigned
indent
);
const
char
*
ComputeFullBoolName
(
bool
b
)
const
;
bool
CanEmitNewline
()
const
;
private:
std
::
auto_ptr
<
EmitterState
>
m_pState
;
ostream_wrapper
m_stream
;
};
template
<
typename
T
>
inline
Emitter
&
Emitter
::
WriteIntegralType
(
T
value
)
{
if
(
!
good
())
return
*
this
;
PrepareNode
(
EmitterNodeType
::
Scalar
);
std
::
stringstream
stream
;
PrepareIntegralStream
(
stream
);
stream
<<
value
;
m_stream
<<
stream
.
str
();
StartedScalar
();
return
*
this
;
}
template
<
typename
T
>
inline
Emitter
&
Emitter
::
WriteStreamable
(
T
value
)
{
if
(
!
good
())
return
*
this
;
PrepareNode
(
EmitterNodeType
::
Scalar
);
std
::
stringstream
stream
;
SetStreamablePrecision
<
T
>
(
stream
);
stream
<<
value
;
m_stream
<<
stream
.
str
();
StartedScalar
();
return
*
this
;
}
template
<
>
inline
void
Emitter
::
SetStreamablePrecision
<
float
>
(
std
::
stringstream
&
stream
)
{
stream
.
precision
(
GetFloatPrecision
());
}
template
<
>
inline
void
Emitter
::
SetStreamablePrecision
<
double
>
(
std
::
stringstream
&
stream
)
{
stream
.
precision
(
GetDoublePrecision
());
}
// overloads of insertion
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
const
std
::
string
&
v
)
{
return
emitter
.
Write
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
bool
v
)
{
return
emitter
.
Write
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
char
v
)
{
return
emitter
.
Write
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
unsigned
char
v
)
{
return
emitter
.
Write
(
static_cast
<
char
>
(
v
));
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
const
_Alias
&
v
)
{
return
emitter
.
Write
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
const
_Anchor
&
v
)
{
return
emitter
.
Write
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
const
_Tag
&
v
)
{
return
emitter
.
Write
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
const
_Comment
&
v
)
{
return
emitter
.
Write
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
const
_Null
&
v
)
{
return
emitter
.
Write
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
const
Binary
&
b
)
{
return
emitter
.
Write
(
b
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
const
char
*
v
)
{
return
emitter
.
Write
(
std
::
string
(
v
));
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
int
v
)
{
return
emitter
.
WriteIntegralType
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
unsigned
int
v
)
{
return
emitter
.
WriteIntegralType
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
short
v
)
{
return
emitter
.
WriteIntegralType
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
unsigned
short
v
)
{
return
emitter
.
WriteIntegralType
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
long
v
)
{
return
emitter
.
WriteIntegralType
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
unsigned
long
v
)
{
return
emitter
.
WriteIntegralType
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
long
long
v
)
{
return
emitter
.
WriteIntegralType
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
unsigned
long
long
v
)
{
return
emitter
.
WriteIntegralType
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
float
v
)
{
return
emitter
.
WriteStreamable
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
double
v
)
{
return
emitter
.
WriteStreamable
(
v
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
EMITTER_MANIP
value
)
{
return
emitter
.
SetLocalValue
(
value
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
_Indent
indent
)
{
return
emitter
.
SetLocalIndent
(
indent
);
}
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
_Precision
precision
)
{
return
emitter
.
SetLocalPrecision
(
precision
);
}
}
#endif // EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/emitterdef.h
View file @
3355bbb3
#ifndef EMITTERDEF_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define EMITTERDEF_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
EmitterNodeType
{
enum
value
{
None
,
Property
,
Scalar
,
FlowSeq
,
BlockSeq
,
FlowMap
,
BlockMap
};
};
namespace
YAML
{
struct
EmitterNodeType
{
enum
value
{
None
,
Property
,
Scalar
,
FlowSeq
,
BlockSeq
,
FlowMap
,
BlockMap
};
};
}
#endif // EMITTERDEF_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif
// EMITTERDEF_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/emittermanip.h
View file @
3355bbb3
#ifndef EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define EMITTERMANIP_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>
namespace
YAML
{
enum
EMITTER_MANIP
{
// general manipulators
Auto
,
TagByKind
,
Newline
,
// output character set
EmitNonAscii
,
EscapeNonAscii
,
// string manipulators
// Auto, // duplicate
SingleQuoted
,
DoubleQuoted
,
Literal
,
// bool manipulators
YesNoBool
,
// yes, no
TrueFalseBool
,
// true, false
OnOffBool
,
// on, off
UpperCase
,
// TRUE, N
LowerCase
,
// f, yes
CamelCase
,
// No, Off
LongBool
,
// yes, On
ShortBool
,
// y, t
// int manipulators
Dec
,
Hex
,
Oct
,
// document manipulators
BeginDoc
,
EndDoc
,
// sequence manipulators
BeginSeq
,
EndSeq
,
Flow
,
Block
,
// map manipulators
BeginMap
,
EndMap
,
Key
,
Value
,
// Flow, // duplicate
// Block, // duplicate
// Auto, // duplicate
LongKey
};
struct
_Indent
{
_Indent
(
int
value_
)
:
value
(
value_
)
{}
int
value
;
};
inline
_Indent
Indent
(
int
value
)
{
return
_Indent
(
value
);
}
struct
_Alias
{
_Alias
(
const
std
::
string
&
content_
)
:
content
(
content_
)
{}
std
::
string
content
;
};
inline
_Alias
Alias
(
const
std
::
string
content
)
{
return
_Alias
(
content
);
}
struct
_Anchor
{
_Anchor
(
const
std
::
string
&
content_
)
:
content
(
content_
)
{}
std
::
string
content
;
};
inline
_Anchor
Anchor
(
const
std
::
string
content
)
{
return
_Anchor
(
content
);
}
struct
_Tag
{
struct
Type
{
enum
value
{
Verbatim
,
PrimaryHandle
,
NamedHandle
};
};
explicit
_Tag
(
const
std
::
string
&
prefix_
,
const
std
::
string
&
content_
,
Type
::
value
type_
)
:
prefix
(
prefix_
),
content
(
content_
),
type
(
type_
)
{
}
std
::
string
prefix
;
std
::
string
content
;
Type
::
value
type
;
};
inline
_Tag
VerbatimTag
(
const
std
::
string
content
)
{
return
_Tag
(
""
,
content
,
_Tag
::
Type
::
Verbatim
);
}
inline
_Tag
LocalTag
(
const
std
::
string
content
)
{
return
_Tag
(
""
,
content
,
_Tag
::
Type
::
PrimaryHandle
);
}
inline
_Tag
LocalTag
(
const
std
::
string
&
prefix
,
const
std
::
string
content
)
{
return
_Tag
(
prefix
,
content
,
_Tag
::
Type
::
NamedHandle
);
}
inline
_Tag
SecondaryTag
(
const
std
::
string
content
)
{
return
_Tag
(
""
,
content
,
_Tag
::
Type
::
NamedHandle
);
}
struct
_Comment
{
_Comment
(
const
std
::
string
&
content_
)
:
content
(
content_
)
{}
std
::
string
content
;
};
inline
_Comment
Comment
(
const
std
::
string
content
)
{
return
_Comment
(
content
);
}
struct
_Precision
{
_Precision
(
int
floatPrecision_
,
int
doublePrecision_
)
:
floatPrecision
(
floatPrecision_
),
doublePrecision
(
doublePrecision_
)
{}
int
floatPrecision
;
int
doublePrecision
;
namespace
YAML
{
enum
EMITTER_MANIP
{
// general manipulators
Auto
,
TagByKind
,
Newline
,
// output character set
EmitNonAscii
,
EscapeNonAscii
,
// string manipulators
// Auto, // duplicate
SingleQuoted
,
DoubleQuoted
,
Literal
,
// bool manipulators
YesNoBool
,
// yes, no
TrueFalseBool
,
// true, false
OnOffBool
,
// on, off
UpperCase
,
// TRUE, N
LowerCase
,
// f, yes
CamelCase
,
// No, Off
LongBool
,
// yes, On
ShortBool
,
// y, t
// int manipulators
Dec
,
Hex
,
Oct
,
// document manipulators
BeginDoc
,
EndDoc
,
// sequence manipulators
BeginSeq
,
EndSeq
,
Flow
,
Block
,
// map manipulators
BeginMap
,
EndMap
,
Key
,
Value
,
// Flow, // duplicate
// Block, // duplicate
// Auto, // duplicate
LongKey
};
struct
_Indent
{
_Indent
(
int
value_
)
:
value
(
value_
)
{}
int
value
;
};
inline
_Indent
Indent
(
int
value
)
{
return
_Indent
(
value
);
}
struct
_Alias
{
_Alias
(
const
std
::
string
&
content_
)
:
content
(
content_
)
{}
std
::
string
content
;
};
inline
_Alias
Alias
(
const
std
::
string
content
)
{
return
_Alias
(
content
);
}
struct
_Anchor
{
_Anchor
(
const
std
::
string
&
content_
)
:
content
(
content_
)
{}
std
::
string
content
;
};
inline
_Anchor
Anchor
(
const
std
::
string
content
)
{
return
_Anchor
(
content
);
}
struct
_Tag
{
struct
Type
{
enum
value
{
Verbatim
,
PrimaryHandle
,
NamedHandle
};
inline
_Precision
FloatPrecision
(
int
n
)
{
return
_Precision
(
n
,
-
1
);
}
inline
_Precision
DoublePrecision
(
int
n
)
{
return
_Precision
(
-
1
,
n
);
}
inline
_Precision
Precision
(
int
n
)
{
return
_Precision
(
n
,
n
);
}
};
explicit
_Tag
(
const
std
::
string
&
prefix_
,
const
std
::
string
&
content_
,
Type
::
value
type_
)
:
prefix
(
prefix_
),
content
(
content_
),
type
(
type_
)
{}
std
::
string
prefix
;
std
::
string
content
;
Type
::
value
type
;
};
inline
_Tag
VerbatimTag
(
const
std
::
string
content
)
{
return
_Tag
(
""
,
content
,
_Tag
::
Type
::
Verbatim
);
}
inline
_Tag
LocalTag
(
const
std
::
string
content
)
{
return
_Tag
(
""
,
content
,
_Tag
::
Type
::
PrimaryHandle
);
}
inline
_Tag
LocalTag
(
const
std
::
string
&
prefix
,
const
std
::
string
content
)
{
return
_Tag
(
prefix
,
content
,
_Tag
::
Type
::
NamedHandle
);
}
inline
_Tag
SecondaryTag
(
const
std
::
string
content
)
{
return
_Tag
(
""
,
content
,
_Tag
::
Type
::
NamedHandle
);
}
struct
_Comment
{
_Comment
(
const
std
::
string
&
content_
)
:
content
(
content_
)
{}
std
::
string
content
;
};
inline
_Comment
Comment
(
const
std
::
string
content
)
{
return
_Comment
(
content
);
}
struct
_Precision
{
_Precision
(
int
floatPrecision_
,
int
doublePrecision_
)
:
floatPrecision
(
floatPrecision_
),
doublePrecision
(
doublePrecision_
)
{}
int
floatPrecision
;
int
doublePrecision
;
};
inline
_Precision
FloatPrecision
(
int
n
)
{
return
_Precision
(
n
,
-
1
);
}
inline
_Precision
DoublePrecision
(
int
n
)
{
return
_Precision
(
-
1
,
n
);
}
inline
_Precision
Precision
(
int
n
)
{
return
_Precision
(
n
,
n
);
}
}
#endif // EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif
// EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/eventhandler.h
View file @
3355bbb3
#ifndef EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define EVENTHANDLER_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/anchor.h"
#include <string>
namespace
YAML
{
struct
Mark
;
class
EventHandler
{
public:
virtual
~
EventHandler
()
{}
virtual
void
OnDocumentStart
(
const
Mark
&
mark
)
=
0
;
virtual
void
OnDocumentEnd
()
=
0
;
virtual
void
OnNull
(
const
Mark
&
mark
,
anchor_t
anchor
)
=
0
;
virtual
void
OnAlias
(
const
Mark
&
mark
,
anchor_t
anchor
)
=
0
;
virtual
void
OnScalar
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
anchor_t
anchor
,
const
std
::
string
&
value
)
=
0
;
virtual
void
OnSequenceStart
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
anchor_t
anchor
)
=
0
;
virtual
void
OnSequenceEnd
()
=
0
;
virtual
void
OnMapStart
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
anchor_t
anchor
)
=
0
;
virtual
void
OnMapEnd
()
=
0
;
};
}
namespace
YAML
{
struct
Mark
;
class
EventHandler
{
public:
virtual
~
EventHandler
()
{}
virtual
void
OnDocumentStart
(
const
Mark
&
mark
)
=
0
;
virtual
void
OnDocumentEnd
()
=
0
;
#endif // EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
virtual
void
OnNull
(
const
Mark
&
mark
,
anchor_t
anchor
)
=
0
;
virtual
void
OnAlias
(
const
Mark
&
mark
,
anchor_t
anchor
)
=
0
;
virtual
void
OnScalar
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
anchor_t
anchor
,
const
std
::
string
&
value
)
=
0
;
virtual
void
OnSequenceStart
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
anchor_t
anchor
)
=
0
;
virtual
void
OnSequenceEnd
()
=
0
;
virtual
void
OnMapStart
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
anchor_t
anchor
)
=
0
;
virtual
void
OnMapEnd
()
=
0
;
};
}
#endif // EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/mark.h
View file @
3355bbb3
#ifndef MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define MARK_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"
namespace
YAML
{
struct
YAML_CPP_API
Mark
{
Mark
()
:
pos
(
0
),
line
(
0
),
column
(
0
)
{}
static
const
Mark
null_mark
()
{
return
Mark
(
-
1
,
-
1
,
-
1
);
}
int
pos
;
int
line
,
column
;
private:
Mark
(
int
pos_
,
int
line_
,
int
column_
)
:
pos
(
pos_
),
line
(
line_
),
column
(
column_
)
{}
};
namespace
YAML
{
struct
YAML_CPP_API
Mark
{
Mark
()
:
pos
(
0
),
line
(
0
),
column
(
0
)
{
}
static
const
Mark
null_mark
()
{
return
Mark
(
-
1
,
-
1
,
-
1
);
}
int
pos
;
int
line
,
column
;
private:
Mark
(
int
pos_
,
int
line_
,
int
column_
)
:
pos
(
pos_
),
line
(
line_
),
column
(
column_
)
{}
};
}
#endif // MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif
// MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/noncopyable.h
View file @
3355bbb3
#ifndef NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define NONCOPYABLE_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"
namespace
YAML
{
// this is basically boost::noncopyable
class
YAML_CPP_API
noncopyable
{
protected:
noncopyable
()
{}
~
noncopyable
()
{}
private:
noncopyable
(
const
noncopyable
&
);
const
noncopyable
&
operator
=
(
const
noncopyable
&
);
};
namespace
YAML
{
// this is basically boost::noncopyable
class
YAML_CPP_API
noncopyable
{
protected:
noncopyable
()
{}
~
noncopyable
()
{}
private:
noncopyable
(
const
noncopyable
&
);
const
noncopyable
&
operator
=
(
const
noncopyable
&
);
};
}
#endif // NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif
// NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/null.h
View file @
3355bbb3
#ifndef NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define NULL_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"
namespace
YAML
{
class
Node
;
struct
YAML_CPP_API
_Null
{};
inline
bool
operator
==
(
const
_Null
&
,
const
_Null
&
)
{
return
true
;
}
inline
bool
operator
!=
(
const
_Null
&
,
const
_Null
&
)
{
return
false
;
}
YAML_CPP_API
bool
IsNull
(
const
Node
&
node
);
// old API only
extern
YAML_CPP_API
_Null
Null
;
}
namespace
YAML
{
class
Node
;
struct
YAML_CPP_API
_Null
{};
inline
bool
operator
==
(
const
_Null
&
,
const
_Null
&
)
{
return
true
;
}
inline
bool
operator
!=
(
const
_Null
&
,
const
_Null
&
)
{
return
false
;
}
#endif // NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
YAML_CPP_API
bool
IsNull
(
const
Node
&
node
);
// old API only
extern
YAML_CPP_API
_Null
Null
;
}
#endif // NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/ostream_wrapper.h
View file @
3355bbb3
#ifndef OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define OSTREAM_WRAPPER_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 <vector>
namespace
YAML
{
class
ostream_wrapper
{
public:
ostream_wrapper
();
explicit
ostream_wrapper
(
std
::
ostream
&
stream
);
~
ostream_wrapper
();
void
write
(
const
std
::
string
&
str
);
void
write
(
const
char
*
str
,
std
::
size_t
size
);
void
set_comment
()
{
m_comment
=
true
;
}
namespace
YAML
{
class
ostream_wrapper
{
public:
ostream_wrapper
();
explicit
ostream_wrapper
(
std
::
ostream
&
stream
);
~
ostream_wrapper
();
const
char
*
str
()
const
{
if
(
m_pStream
)
{
return
0
;
}
else
{
m_buffer
[
m_pos
]
=
'\0'
;
return
&
m_buffer
[
0
];
}
}
std
::
size_t
row
()
const
{
return
m_row
;
}
std
::
size_t
col
()
const
{
return
m_col
;
}
std
::
size_t
pos
()
const
{
return
m_pos
;
}
bool
comment
()
const
{
return
m_comment
;
}
private:
void
update_pos
(
char
ch
);
private:
mutable
std
::
vector
<
char
>
m_buffer
;
std
::
ostream
*
m_pStream
;
void
write
(
const
std
::
string
&
str
);
void
write
(
const
char
*
str
,
std
::
size_t
size
);
std
::
size_t
m_pos
;
std
::
size_t
m_row
,
m_col
;
bool
m_comment
;
};
template
<
std
::
size_t
N
>
inline
ostream_wrapper
&
operator
<<
(
ostream_wrapper
&
stream
,
const
char
(
&
str
)[
N
])
{
stream
.
write
(
str
,
N
-
1
);
return
stream
;
}
inline
ostream_wrapper
&
operator
<<
(
ostream_wrapper
&
stream
,
const
std
::
string
&
str
)
{
stream
.
write
(
str
);
return
stream
;
}
inline
ostream_wrapper
&
operator
<<
(
ostream_wrapper
&
stream
,
char
ch
)
{
stream
.
write
(
&
ch
,
1
);
return
stream
;
void
set_comment
()
{
m_comment
=
true
;
}
const
char
*
str
()
const
{
if
(
m_pStream
)
{
return
0
;
}
else
{
m_buffer
[
m_pos
]
=
'\0'
;
return
&
m_buffer
[
0
];
}
}
std
::
size_t
row
()
const
{
return
m_row
;
}
std
::
size_t
col
()
const
{
return
m_col
;
}
std
::
size_t
pos
()
const
{
return
m_pos
;
}
bool
comment
()
const
{
return
m_comment
;
}
private:
void
update_pos
(
char
ch
);
private:
mutable
std
::
vector
<
char
>
m_buffer
;
std
::
ostream
*
m_pStream
;
std
::
size_t
m_pos
;
std
::
size_t
m_row
,
m_col
;
bool
m_comment
;
};
template
<
std
::
size_t
N
>
inline
ostream_wrapper
&
operator
<<
(
ostream_wrapper
&
stream
,
const
char
(
&
str
)[
N
])
{
stream
.
write
(
str
,
N
-
1
);
return
stream
;
}
inline
ostream_wrapper
&
operator
<<
(
ostream_wrapper
&
stream
,
const
std
::
string
&
str
)
{
stream
.
write
(
str
);
return
stream
;
}
inline
ostream_wrapper
&
operator
<<
(
ostream_wrapper
&
stream
,
char
ch
)
{
stream
.
write
(
&
ch
,
1
);
return
stream
;
}
}
#endif // OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif
// OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/stlemitter.h
View file @
3355bbb3
#ifndef STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define STLEMITTER_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 <vector>
#include <list>
#include <set>
#include <map>
namespace
YAML
{
template
<
typename
Seq
>
inline
Emitter
&
EmitSeq
(
Emitter
&
emitter
,
const
Seq
&
seq
)
{
emitter
<<
BeginSeq
;
for
(
typename
Seq
::
const_iterator
it
=
seq
.
begin
();
it
!=
seq
.
end
();
++
it
)
emitter
<<
*
it
;
emitter
<<
EndSeq
;
return
emitter
;
}
template
<
typename
T
>
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
const
std
::
vector
<
T
>&
v
)
{
return
EmitSeq
(
emitter
,
v
);
}
template
<
typename
T
>
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
const
std
::
list
<
T
>&
v
)
{
return
EmitSeq
(
emitter
,
v
);
}
template
<
typename
T
>
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
const
std
::
set
<
T
>&
v
)
{
return
EmitSeq
(
emitter
,
v
);
}
template
<
typename
K
,
typename
V
>
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
const
std
::
map
<
K
,
V
>&
m
)
{
typedef
typename
std
::
map
<
K
,
V
>
map
;
emitter
<<
BeginMap
;
for
(
typename
map
::
const_iterator
it
=
m
.
begin
();
it
!=
m
.
end
();
++
it
)
emitter
<<
Key
<<
it
->
first
<<
Value
<<
it
->
second
;
emitter
<<
EndMap
;
return
emitter
;
}
namespace
YAML
{
template
<
typename
Seq
>
inline
Emitter
&
EmitSeq
(
Emitter
&
emitter
,
const
Seq
&
seq
)
{
emitter
<<
BeginSeq
;
for
(
typename
Seq
::
const_iterator
it
=
seq
.
begin
();
it
!=
seq
.
end
();
++
it
)
emitter
<<
*
it
;
emitter
<<
EndSeq
;
return
emitter
;
}
template
<
typename
T
>
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
const
std
::
vector
<
T
>&
v
)
{
return
EmitSeq
(
emitter
,
v
);
}
template
<
typename
T
>
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
const
std
::
list
<
T
>&
v
)
{
return
EmitSeq
(
emitter
,
v
);
}
template
<
typename
T
>
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
const
std
::
set
<
T
>&
v
)
{
return
EmitSeq
(
emitter
,
v
);
}
template
<
typename
K
,
typename
V
>
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
const
std
::
map
<
K
,
V
>&
m
)
{
typedef
typename
std
::
map
<
K
,
V
>
map
;
emitter
<<
BeginMap
;
for
(
typename
map
::
const_iterator
it
=
m
.
begin
();
it
!=
m
.
end
();
++
it
)
emitter
<<
Key
<<
it
->
first
<<
Value
<<
it
->
second
;
emitter
<<
EndMap
;
return
emitter
;
}
}
#endif // STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif
// STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/traits.h
View file @
3355bbb3
#ifndef TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define TRAITS_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
{
template
<
typename
>
struct
is_numeric
{
enum
{
value
=
false
};
};
namespace
YAML
{
template
<
typename
>
struct
is_numeric
{
enum
{
value
=
false
};
};
template
<
>
struct
is_numeric
<
char
>
{
enum
{
value
=
true
};
};
template
<
>
struct
is_numeric
<
unsigned
char
>
{
enum
{
value
=
true
};
};
template
<
>
struct
is_numeric
<
int
>
{
enum
{
value
=
true
};
};
template
<
>
struct
is_numeric
<
unsigned
int
>
{
enum
{
value
=
true
};
};
template
<
>
struct
is_numeric
<
long
int
>
{
enum
{
value
=
true
};
};
template
<
>
struct
is_numeric
<
unsigned
long
int
>
{
enum
{
value
=
true
};
};
template
<
>
struct
is_numeric
<
short
int
>
{
enum
{
value
=
true
};
};
template
<
>
struct
is_numeric
<
unsigned
short
int
>
{
enum
{
value
=
true
};
};
template
<
>
struct
is_numeric
<
char
>
{
enum
{
value
=
true
};
};
template
<
>
struct
is_numeric
<
unsigned
char
>
{
enum
{
value
=
true
};
};
template
<
>
struct
is_numeric
<
int
>
{
enum
{
value
=
true
};
};
template
<
>
struct
is_numeric
<
unsigned
int
>
{
enum
{
value
=
true
};
};
template
<
>
struct
is_numeric
<
long
int
>
{
enum
{
value
=
true
};
};
template
<
>
struct
is_numeric
<
unsigned
long
int
>
{
enum
{
value
=
true
};
};
template
<
>
struct
is_numeric
<
short
int
>
{
enum
{
value
=
true
};
};
template
<
>
struct
is_numeric
<
unsigned
short
int
>
{
enum
{
value
=
true
};
};
#if defined(_MSC_VER) && (_MSC_VER < 1310)
template
<
>
struct
is_numeric
<
__int64
>
{
enum
{
value
=
true
};
};
template
<
>
struct
is_numeric
<
unsigned
__int64
>
{
enum
{
value
=
true
};
};
template
<
>
struct
is_numeric
<
__int64
>
{
enum
{
value
=
true
};
};
template
<
>
struct
is_numeric
<
unsigned
__int64
>
{
enum
{
value
=
true
};
};
#else
template
<
>
struct
is_numeric
<
long
long
>
{
enum
{
value
=
true
};
};
template
<
>
struct
is_numeric
<
unsigned
long
long
>
{
enum
{
value
=
true
};
};
template
<
>
struct
is_numeric
<
long
long
>
{
enum
{
value
=
true
};
};
template
<
>
struct
is_numeric
<
unsigned
long
long
>
{
enum
{
value
=
true
};
};
#endif
template
<
>
struct
is_numeric
<
float
>
{
enum
{
value
=
true
};
};
template
<
>
struct
is_numeric
<
double
>
{
enum
{
value
=
true
};
};
template
<
>
struct
is_numeric
<
long
double
>
{
enum
{
value
=
true
};
};
template
<
>
struct
is_numeric
<
float
>
{
enum
{
value
=
true
};
};
template
<
>
struct
is_numeric
<
double
>
{
enum
{
value
=
true
};
};
template
<
>
struct
is_numeric
<
long
double
>
{
enum
{
value
=
true
};
};
template
<
bool
,
class
T
=
void
>
struct
enable_if_c
{
typedef
T
type
;
};
template
<
bool
,
class
T
=
void
>
struct
enable_if_c
{
typedef
T
type
;
};
template
<
class
T
>
struct
enable_if_c
<
false
,
T
>
{};
template
<
class
T
>
struct
enable_if_c
<
false
,
T
>
{};
template
<
class
Cond
,
class
T
=
void
>
struct
enable_if
:
public
enable_if_c
<
Cond
::
value
,
T
>
{};
template
<
class
Cond
,
class
T
=
void
>
struct
enable_if
:
public
enable_if_c
<
Cond
::
value
,
T
>
{};
template
<
bool
,
class
T
=
void
>
struct
disable_if_c
{
typedef
T
type
;
};
template
<
bool
,
class
T
=
void
>
struct
disable_if_c
{
typedef
T
type
;
};
template
<
class
T
>
struct
disable_if_c
<
true
,
T
>
{};
template
<
class
T
>
struct
disable_if_c
<
true
,
T
>
{};
template
<
class
Cond
,
class
T
=
void
>
struct
disable_if
:
public
disable_if_c
<
Cond
::
value
,
T
>
{};
template
<
class
Cond
,
class
T
=
void
>
struct
disable_if
:
public
disable_if_c
<
Cond
::
value
,
T
>
{};
}
#endif // TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif // TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
src/binary.cpp
View file @
3355bbb3
#include "yaml-cpp/binary.h"
namespace
YAML
{
static
const
char
encoding
[]
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
;
namespace
YAML
{
static
const
char
encoding
[]
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
;
std
::
string
EncodeBase64
(
const
unsigned
char
*
data
,
std
::
size_t
size
)
{
const
char
PAD
=
'='
;
std
::
string
ret
;
ret
.
resize
(
4
*
size
/
3
+
3
);
char
*
out
=
&
ret
[
0
];
std
::
size_t
chunks
=
size
/
3
;
std
::
size_t
remainder
=
size
%
3
;
for
(
std
::
size_t
i
=
0
;
i
<
chunks
;
i
++
,
data
+=
3
)
{
*
out
++
=
encoding
[
data
[
0
]
>>
2
];
*
out
++
=
encoding
[((
data
[
0
]
&
0x3
)
<<
4
)
|
(
data
[
1
]
>>
4
)];
*
out
++
=
encoding
[((
data
[
1
]
&
0xf
)
<<
2
)
|
(
data
[
2
]
>>
6
)];
*
out
++
=
encoding
[
data
[
2
]
&
0x3f
];
}
switch
(
remainder
)
{
case
0
:
break
;
case
1
:
*
out
++
=
encoding
[
data
[
0
]
>>
2
];
*
out
++
=
encoding
[((
data
[
0
]
&
0x3
)
<<
4
)];
*
out
++
=
PAD
;
*
out
++
=
PAD
;
break
;
case
2
:
*
out
++
=
encoding
[
data
[
0
]
>>
2
];
*
out
++
=
encoding
[((
data
[
0
]
&
0x3
)
<<
4
)
|
(
data
[
1
]
>>
4
)];
*
out
++
=
encoding
[((
data
[
1
]
&
0xf
)
<<
2
)];
*
out
++
=
PAD
;
break
;
}
ret
.
resize
(
out
-
&
ret
[
0
]);
return
ret
;
}
static
const
unsigned
char
decoding
[]
=
{
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
62
,
255
,
255
,
255
,
63
,
52
,
53
,
54
,
55
,
56
,
57
,
58
,
59
,
60
,
61
,
255
,
255
,
255
,
0
,
255
,
255
,
255
,
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
,
18
,
19
,
20
,
21
,
22
,
23
,
24
,
25
,
255
,
255
,
255
,
255
,
255
,
255
,
26
,
27
,
28
,
29
,
30
,
31
,
32
,
33
,
34
,
35
,
36
,
37
,
38
,
39
,
40
,
41
,
42
,
43
,
44
,
45
,
46
,
47
,
48
,
49
,
50
,
51
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
};
std
::
string
EncodeBase64
(
const
unsigned
char
*
data
,
std
::
size_t
size
)
{
const
char
PAD
=
'='
;
std
::
string
ret
;
ret
.
resize
(
4
*
size
/
3
+
3
);
char
*
out
=
&
ret
[
0
];
std
::
size_t
chunks
=
size
/
3
;
std
::
size_t
remainder
=
size
%
3
;
for
(
std
::
size_t
i
=
0
;
i
<
chunks
;
i
++
,
data
+=
3
)
{
*
out
++
=
encoding
[
data
[
0
]
>>
2
];
*
out
++
=
encoding
[((
data
[
0
]
&
0x3
)
<<
4
)
|
(
data
[
1
]
>>
4
)];
*
out
++
=
encoding
[((
data
[
1
]
&
0xf
)
<<
2
)
|
(
data
[
2
]
>>
6
)];
*
out
++
=
encoding
[
data
[
2
]
&
0x3f
];
}
switch
(
remainder
)
{
case
0
:
break
;
case
1
:
*
out
++
=
encoding
[
data
[
0
]
>>
2
];
*
out
++
=
encoding
[((
data
[
0
]
&
0x3
)
<<
4
)];
*
out
++
=
PAD
;
*
out
++
=
PAD
;
break
;
case
2
:
*
out
++
=
encoding
[
data
[
0
]
>>
2
];
*
out
++
=
encoding
[((
data
[
0
]
&
0x3
)
<<
4
)
|
(
data
[
1
]
>>
4
)];
*
out
++
=
encoding
[((
data
[
1
]
&
0xf
)
<<
2
)];
*
out
++
=
PAD
;
break
;
}
ret
.
resize
(
out
-
&
ret
[
0
]);
return
ret
;
}
static
const
unsigned
char
decoding
[]
=
{
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
62
,
255
,
255
,
255
,
63
,
52
,
53
,
54
,
55
,
56
,
57
,
58
,
59
,
60
,
61
,
255
,
255
,
255
,
0
,
255
,
255
,
255
,
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
,
18
,
19
,
20
,
21
,
22
,
23
,
24
,
25
,
255
,
255
,
255
,
255
,
255
,
255
,
26
,
27
,
28
,
29
,
30
,
31
,
32
,
33
,
34
,
35
,
36
,
37
,
38
,
39
,
40
,
41
,
42
,
43
,
44
,
45
,
46
,
47
,
48
,
49
,
50
,
51
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
};
std
::
vector
<
unsigned
char
>
DecodeBase64
(
const
std
::
string
&
input
)
{
typedef
std
::
vector
<
unsigned
char
>
ret_type
;
if
(
input
.
empty
())
return
ret_type
();
std
::
vector
<
unsigned
char
>
DecodeBase64
(
const
std
::
string
&
input
)
{
typedef
std
::
vector
<
unsigned
char
>
ret_type
;
if
(
input
.
empty
())
return
ret_type
();
ret_type
ret
(
3
*
input
.
size
()
/
4
+
1
);
unsigned
char
*
out
=
&
ret
[
0
];
unsigned
value
=
0
;
for
(
std
::
size_t
i
=
0
;
i
<
input
.
size
();
i
++
)
{
unsigned
char
d
=
decoding
[
static_cast
<
unsigned
>
(
input
[
i
])];
if
(
d
==
255
)
return
ret_type
();
ret_type
ret
(
3
*
input
.
size
()
/
4
+
1
);
unsigned
char
*
out
=
&
ret
[
0
];
value
=
(
value
<<
6
)
|
d
;
if
(
i
%
4
==
3
)
{
*
out
++
=
value
>>
16
;
if
(
i
>
0
&&
input
[
i
-
1
]
!=
'='
)
*
out
++
=
value
>>
8
;
if
(
input
[
i
]
!=
'='
)
*
out
++
=
value
;
}
}
ret
.
resize
(
out
-
&
ret
[
0
]);
return
ret
;
unsigned
value
=
0
;
for
(
std
::
size_t
i
=
0
;
i
<
input
.
size
();
i
++
)
{
unsigned
char
d
=
decoding
[
static_cast
<
unsigned
>
(
input
[
i
])];
if
(
d
==
255
)
return
ret_type
();
value
=
(
value
<<
6
)
|
d
;
if
(
i
%
4
==
3
)
{
*
out
++
=
value
>>
16
;
if
(
i
>
0
&&
input
[
i
-
1
]
!=
'='
)
*
out
++
=
value
>>
8
;
if
(
input
[
i
]
!=
'='
)
*
out
++
=
value
;
}
}
ret
.
resize
(
out
-
&
ret
[
0
]);
return
ret
;
}
}
src/collectionstack.h
View file @
3355bbb3
#ifndef COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define COLLECTIONSTACK_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 <stack>
#include <cassert>
namespace
YAML
{
struct
CollectionType
{
enum
value
{
None
,
BlockMap
,
BlockSeq
,
FlowMap
,
FlowSeq
,
CompactMap
};
};
namespace
YAML
{
struct
CollectionType
{
enum
value
{
None
,
BlockMap
,
BlockSeq
,
FlowMap
,
FlowSeq
,
CompactMap
};
};
class
CollectionStack
{
public:
CollectionType
::
value
GetCurCollectionType
()
const
{
if
(
collectionStack
.
empty
())
return
CollectionType
::
None
;
return
collectionStack
.
top
();
}
void
PushCollectionType
(
CollectionType
::
value
type
)
{
collectionStack
.
push
(
type
);
}
void
PopCollectionType
(
CollectionType
::
value
type
)
{
assert
(
type
==
GetCurCollectionType
());
collectionStack
.
pop
();
}
class
CollectionStack
{
public:
CollectionType
::
value
GetCurCollectionType
()
const
{
if
(
collectionStack
.
empty
())
return
CollectionType
::
None
;
return
collectionStack
.
top
();
}
void
PushCollectionType
(
CollectionType
::
value
type
)
{
collectionStack
.
push
(
type
);
}
void
PopCollectionType
(
CollectionType
::
value
type
)
{
assert
(
type
==
GetCurCollectionType
());
collectionStack
.
pop
();
}
private:
std
::
stack
<
CollectionType
::
value
>
collectionStack
;
};
private:
std
::
stack
<
CollectionType
::
value
>
collectionStack
;
};
}
#endif // COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif
// COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
src/contrib/graphbuilder.cpp
View file @
3355bbb3
...
...
@@ -2,15 +2,14 @@
#include "yaml-cpp/contrib/graphbuilder.h"
#include "graphbuilderadapter.h"
namespace
YAML
{
void
*
BuildGraphOfNextDocument
(
Parser
&
parser
,
GraphBuilderInterface
&
graphBuilder
)
{
GraphBuilderAdapter
eventHandler
(
graphBuilder
);
if
(
parser
.
HandleNextDocument
(
eventHandler
))
{
return
eventHandler
.
RootNode
();
}
else
{
return
NULL
;
}
namespace
YAML
{
void
*
BuildGraphOfNextDocument
(
Parser
&
parser
,
GraphBuilderInterface
&
graphBuilder
)
{
GraphBuilderAdapter
eventHandler
(
graphBuilder
);
if
(
parser
.
HandleNextDocument
(
eventHandler
))
{
return
eventHandler
.
RootNode
();
}
else
{
return
NULL
;
}
}
}
src/contrib/graphbuilderadapter.cpp
View file @
3355bbb3
#include "graphbuilderadapter.h"
namespace
YAML
{
int
GraphBuilderAdapter
::
ContainerFrame
::
sequenceMarker
;
void
GraphBuilderAdapter
::
OnNull
(
const
Mark
&
mark
,
anchor_t
anchor
)
{
void
*
pParent
=
GetCurrentParent
();
void
*
pNode
=
m_builder
.
NewNull
(
mark
,
pParent
);
RegisterAnchor
(
anchor
,
pNode
);
DispositionNode
(
pNode
);
}
void
GraphBuilderAdapter
::
OnAlias
(
const
Mark
&
mark
,
anchor_t
anchor
)
{
void
*
pReffedNode
=
m_anchors
.
Get
(
anchor
);
DispositionNode
(
m_builder
.
AnchorReference
(
mark
,
pReffedNode
));
}
void
GraphBuilderAdapter
::
OnScalar
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
anchor_t
anchor
,
const
std
::
string
&
value
)
{
void
*
pParent
=
GetCurrentParent
();
void
*
pNode
=
m_builder
.
NewScalar
(
mark
,
tag
,
pParent
,
value
);
RegisterAnchor
(
anchor
,
pNode
);
DispositionNode
(
pNode
);
}
void
GraphBuilderAdapter
::
OnSequenceStart
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
anchor_t
anchor
)
{
void
*
pNode
=
m_builder
.
NewSequence
(
mark
,
tag
,
GetCurrentParent
());
m_containers
.
push
(
ContainerFrame
(
pNode
));
RegisterAnchor
(
anchor
,
pNode
);
}
void
GraphBuilderAdapter
::
OnSequenceEnd
()
{
void
*
pSequence
=
m_containers
.
top
().
pContainer
;
m_containers
.
pop
();
DispositionNode
(
pSequence
);
}
void
GraphBuilderAdapter
::
OnMapStart
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
anchor_t
anchor
)
{
void
*
pNode
=
m_builder
.
NewMap
(
mark
,
tag
,
GetCurrentParent
());
m_containers
.
push
(
ContainerFrame
(
pNode
,
m_pKeyNode
));
m_pKeyNode
=
NULL
;
RegisterAnchor
(
anchor
,
pNode
);
}
void
GraphBuilderAdapter
::
OnMapEnd
()
{
void
*
pMap
=
m_containers
.
top
().
pContainer
;
m_pKeyNode
=
m_containers
.
top
().
pPrevKeyNode
;
m_containers
.
pop
();
DispositionNode
(
pMap
);
namespace
YAML
{
int
GraphBuilderAdapter
::
ContainerFrame
::
sequenceMarker
;
void
GraphBuilderAdapter
::
OnNull
(
const
Mark
&
mark
,
anchor_t
anchor
)
{
void
*
pParent
=
GetCurrentParent
();
void
*
pNode
=
m_builder
.
NewNull
(
mark
,
pParent
);
RegisterAnchor
(
anchor
,
pNode
);
DispositionNode
(
pNode
);
}
void
GraphBuilderAdapter
::
OnAlias
(
const
Mark
&
mark
,
anchor_t
anchor
)
{
void
*
pReffedNode
=
m_anchors
.
Get
(
anchor
);
DispositionNode
(
m_builder
.
AnchorReference
(
mark
,
pReffedNode
));
}
void
GraphBuilderAdapter
::
OnScalar
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
anchor_t
anchor
,
const
std
::
string
&
value
)
{
void
*
pParent
=
GetCurrentParent
();
void
*
pNode
=
m_builder
.
NewScalar
(
mark
,
tag
,
pParent
,
value
);
RegisterAnchor
(
anchor
,
pNode
);
DispositionNode
(
pNode
);
}
void
GraphBuilderAdapter
::
OnSequenceStart
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
anchor_t
anchor
)
{
void
*
pNode
=
m_builder
.
NewSequence
(
mark
,
tag
,
GetCurrentParent
());
m_containers
.
push
(
ContainerFrame
(
pNode
));
RegisterAnchor
(
anchor
,
pNode
);
}
void
GraphBuilderAdapter
::
OnSequenceEnd
()
{
void
*
pSequence
=
m_containers
.
top
().
pContainer
;
m_containers
.
pop
();
DispositionNode
(
pSequence
);
}
void
GraphBuilderAdapter
::
OnMapStart
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
anchor_t
anchor
)
{
void
*
pNode
=
m_builder
.
NewMap
(
mark
,
tag
,
GetCurrentParent
());
m_containers
.
push
(
ContainerFrame
(
pNode
,
m_pKeyNode
));
m_pKeyNode
=
NULL
;
RegisterAnchor
(
anchor
,
pNode
);
}
void
GraphBuilderAdapter
::
OnMapEnd
()
{
void
*
pMap
=
m_containers
.
top
().
pContainer
;
m_pKeyNode
=
m_containers
.
top
().
pPrevKeyNode
;
m_containers
.
pop
();
DispositionNode
(
pMap
);
}
void
*
GraphBuilderAdapter
::
GetCurrentParent
()
const
{
if
(
m_containers
.
empty
())
{
return
NULL
;
}
void
*
GraphBuilderAdapter
::
GetCurrentParent
()
const
{
if
(
m_containers
.
empty
())
{
return
NULL
;
}
return
m_containers
.
top
().
pContainer
;
return
m_containers
.
top
().
pContainer
;
}
void
GraphBuilderAdapter
::
RegisterAnchor
(
anchor_t
anchor
,
void
*
pNode
)
{
if
(
anchor
)
{
m_anchors
.
Register
(
anchor
,
pNode
);
}
void
GraphBuilderAdapter
::
RegisterAnchor
(
anchor_t
anchor
,
void
*
pNode
)
{
if
(
anchor
)
{
m_anchors
.
Register
(
anchor
,
pNode
)
;
}
}
void
GraphBuilderAdapter
::
DispositionNode
(
void
*
pNode
)
{
if
(
m_containers
.
empty
()
)
{
m_pRootNode
=
pNode
;
return
;
}
void
GraphBuilderAdapter
::
DispositionNode
(
void
*
pNode
)
{
if
(
m_containers
.
empty
())
{
m_pRootNode
=
pNode
;
return
;
}
void
*
pContainer
=
m_containers
.
top
().
pContainer
;
if
(
m_containers
.
top
().
isMap
())
{
if
(
m_pKeyNode
)
{
m_builder
.
AssignInMap
(
pContainer
,
m_pKeyNode
,
pNode
);
m_pKeyNode
=
NULL
;
}
else
{
m_pKeyNode
=
pNode
;
}
void
*
pContainer
=
m_containers
.
top
().
pContainer
;
if
(
m_containers
.
top
().
isMap
())
{
if
(
m_pKeyNode
)
{
m_builder
.
AssignInMap
(
pContainer
,
m_pKeyNode
,
pNode
);
m_pKeyNode
=
NULL
;
}
else
{
m_
builder
.
AppendToSequence
(
pContainer
,
pNode
)
;
m_
pKeyNode
=
pNode
;
}
}
else
{
m_builder
.
AppendToSequence
(
pContainer
,
pNode
);
}
}
}
Prev
1
2
3
4
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