mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 20:51:16 +00:00
Compare commits
149 Commits
release-0.
...
release-0.
Author | SHA1 | Date | |
---|---|---|---|
![]() |
572e940c83 | ||
![]() |
01eb370300 | ||
![]() |
d760d037ca | ||
![]() |
6105d4cfeb | ||
![]() |
e145488547 | ||
![]() |
b688c93050 | ||
![]() |
1723523c43 | ||
![]() |
d772361f15 | ||
![]() |
a441e1a14c | ||
![]() |
fb0802097c | ||
![]() |
643ea61a98 | ||
![]() |
d1e4c2640c | ||
![]() |
ddc578dbd7 | ||
![]() |
8906ae9a0d | ||
![]() |
4e350e5808 | ||
![]() |
7ace0e93d2 | ||
![]() |
0e61ddb6d9 | ||
![]() |
97fa02a484 | ||
![]() |
5024caa69c | ||
![]() |
21ed2b5817 | ||
![]() |
92a35581d7 | ||
![]() |
5b32d89222 | ||
![]() |
812a2dc684 | ||
![]() |
add460947b | ||
![]() |
3099d51ba4 | ||
![]() |
6f4608ce05 | ||
![]() |
5abfbf5aac | ||
![]() |
d78d16532a | ||
![]() |
62634f53ec | ||
![]() |
860365b263 | ||
![]() |
e8e5d4bc40 | ||
![]() |
b077e8390e | ||
![]() |
c953ce0b07 | ||
![]() |
f87dced5c9 | ||
![]() |
62361e6f27 | ||
![]() |
70e1eb3f9c | ||
![]() |
77cc54585f | ||
![]() |
e69f51ee16 | ||
![]() |
ee795d7e3e | ||
![]() |
f6d6c90aa9 | ||
![]() |
d9c7bcf32f | ||
![]() |
f3b230693a | ||
![]() |
f64f619c29 | ||
![]() |
8e5fc0e304 | ||
![]() |
976e8b184c | ||
![]() |
e5d0366797 | ||
![]() |
c3798d9bd4 | ||
![]() |
40c47f6312 | ||
![]() |
e3d5ec189d | ||
![]() |
5be19ccbfd | ||
![]() |
98830a4a15 | ||
![]() |
3a88c4b4a1 | ||
![]() |
69af9b420a | ||
![]() |
0987b234c3 | ||
![]() |
2dfccbb945 | ||
![]() |
a9be4849d8 | ||
![]() |
b1100d7c54 | ||
![]() |
64e381f2c1 | ||
![]() |
f6b728d56c | ||
![]() |
edd6650536 | ||
![]() |
a04dfdeb07 | ||
![]() |
1721750d9e | ||
![]() |
a8f82af604 | ||
![]() |
0c321a6dc6 | ||
![]() |
08b3ddfd3e | ||
![]() |
fddc991b60 | ||
![]() |
3337df7ca2 | ||
![]() |
41533a8c49 | ||
![]() |
a6e1d4cf74 | ||
![]() |
5397a93702 | ||
![]() |
b9583dde76 | ||
![]() |
f22f38f7f2 | ||
![]() |
9e62bf8349 | ||
![]() |
f9d826c22a | ||
![]() |
4770ec798c | ||
![]() |
4568dd0b19 | ||
![]() |
a308b73e8a | ||
![]() |
c2a8a2c1f7 | ||
![]() |
a03af5dd73 | ||
![]() |
b50264e74d | ||
![]() |
ecdd9cc66d | ||
![]() |
3a90454d50 | ||
![]() |
2d81e46655 | ||
![]() |
b4963ab0fa | ||
![]() |
432268917b | ||
![]() |
2d06df474b | ||
![]() |
03fc837236 | ||
![]() |
80cf3c98db | ||
![]() |
f7b2247217 | ||
![]() |
36c63980b9 | ||
![]() |
0d1b5224c8 | ||
![]() |
ac81d7c883 | ||
![]() |
78b7a1b8a9 | ||
![]() |
12364895cb | ||
![]() |
5012063143 | ||
![]() |
c3b0ba9d61 | ||
![]() |
4fdbb748ec | ||
![]() |
b1730ea3da | ||
![]() |
3865d37bc7 | ||
![]() |
f5a9d4c8e3 | ||
![]() |
09beb5c47a | ||
![]() |
6e03bebeb0 | ||
![]() |
a7bdf08c7e | ||
![]() |
cf198080d0 | ||
![]() |
190a556756 | ||
![]() |
9aa3eb56f2 | ||
![]() |
ff1a8fc59a | ||
![]() |
7bbf712c36 | ||
![]() |
9b985c5ce2 | ||
![]() |
d3bbd08273 | ||
![]() |
4f8680b540 | ||
![]() |
ec95e61c04 | ||
![]() |
6ffc9ac788 | ||
![]() |
0e197b8723 | ||
![]() |
3d84f57008 | ||
![]() |
a7ebb3615a | ||
![]() |
a95baeafd6 | ||
![]() |
1ab16bac62 | ||
![]() |
4aa61944fe | ||
![]() |
e225509210 | ||
![]() |
d1eca90216 | ||
![]() |
020cd97915 | ||
![]() |
f0174ca08b | ||
![]() |
fed95c5da4 | ||
![]() |
a530630f1c | ||
![]() |
00e4a56d15 | ||
![]() |
1e6877043e | ||
![]() |
248b18a2d0 | ||
![]() |
7e79edc058 | ||
![]() |
8b97dfe77e | ||
![]() |
3eeb270ef5 | ||
![]() |
c1d75dd4f7 | ||
![]() |
dd1eb715c4 | ||
![]() |
fadca5a89d | ||
![]() |
7e129c9b64 | ||
![]() |
3e94c0a037 | ||
![]() |
d7feb2e9b9 | ||
![]() |
8ba5e3fbf6 | ||
![]() |
857c7d93a0 | ||
![]() |
b690648308 | ||
![]() |
d904b600a9 | ||
![]() |
bacb74e8ec | ||
![]() |
b1ac3289b8 | ||
![]() |
835b86d9f7 | ||
![]() |
94dc63af04 | ||
![]() |
50474b6b9f | ||
![]() |
4c3926a5c7 | ||
![]() |
9fbcfe9ec5 | ||
![]() |
d98687afc3 |
4
.hgeol
Normal file
4
.hgeol
Normal file
@@ -0,0 +1,4 @@
|
||||
**.h = native
|
||||
**.c = native
|
||||
**.cpp = native
|
||||
**.txt = native
|
@@ -22,8 +22,8 @@ include(CheckCXXCompilerFlag)
|
||||
project(YAML_CPP)
|
||||
|
||||
set(YAML_CPP_VERSION_MAJOR "0")
|
||||
set(YAML_CPP_VERSION_MINOR "2")
|
||||
set(YAML_CPP_VERSION_PATCH "5")
|
||||
set(YAML_CPP_VERSION_MINOR "3")
|
||||
set(YAML_CPP_VERSION_PATCH "0")
|
||||
set(YAML_CPP_VERSION "${YAML_CPP_VERSION_MAJOR}.${YAML_CPP_VERSION_MINOR}.${YAML_CPP_VERSION_PATCH}")
|
||||
|
||||
enable_testing()
|
||||
@@ -51,14 +51,15 @@ option(APPLE_UNIVERSAL_BIN "Apple: Build universal binary" OFF)
|
||||
option(MSVC_SHARED_RT "MSVC: Build with shared runtime libs (/MD)" ON)
|
||||
option(MSVC_STHREADED_RT "MSVC: Build with single-threaded static runtime libs (/ML until VS .NET 2003)" OFF)
|
||||
|
||||
|
||||
###
|
||||
### Sources, headers, directories and libs
|
||||
###
|
||||
set(header_directory "include/yaml-cpp/")
|
||||
|
||||
file(GLOB sources "src/[a-zA-Z]*.cpp")
|
||||
file(GLOB public_headers "include/yaml-cpp/[a-zA-Z]*.h")
|
||||
file(GLOB private_headers "src/[a-zA-Z]*.h")
|
||||
|
||||
|
||||
if(YAML_CPP_BUILD_CONTRIB)
|
||||
file(GLOB contrib_sources "src/contrib/[a-zA-Z]*.cpp")
|
||||
file(GLOB contrib_public_headers "include/yaml-cpp/contrib/[a-zA-Z]*.h")
|
||||
@@ -77,6 +78,7 @@ if(VERBOSE)
|
||||
endif()
|
||||
|
||||
include_directories(${YAML_CPP_SOURCE_DIR}/include)
|
||||
include_directories(${YAML_CPP_SOURCE_DIR}/src)
|
||||
|
||||
|
||||
###
|
||||
@@ -209,7 +211,9 @@ else()
|
||||
set(_library_dir lib)
|
||||
endif()
|
||||
|
||||
set(INCLUDE_INSTALL_DIR include/yaml-cpp)
|
||||
set(INCLUDE_INSTALL_ROOT_DIR include)
|
||||
|
||||
set(INCLUDE_INSTALL_DIR ${INCLUDE_INSTALL_ROOT_DIR}/yaml-cpp)
|
||||
set(LIB_INSTALL_DIR "${_library_dir}${LIB_SUFFIX}")
|
||||
|
||||
set(_INSTALL_DESTINATIONS
|
||||
@@ -257,10 +261,9 @@ endif()
|
||||
|
||||
install(TARGETS yaml-cpp ${_INSTALL_DESTINATIONS})
|
||||
install(
|
||||
FILES
|
||||
${public_headers}
|
||||
${contrib_public_headers}
|
||||
DIRECTORY ${header_directory}
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}
|
||||
FILES_MATCHING PATTERN "*.h"
|
||||
)
|
||||
|
||||
if(UNIX)
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef ALIASMANAGER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define ALIASMANAGER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
66
include/yaml-cpp/binary.h
Normal file
66
include/yaml-cpp/binary.h
Normal file
@@ -0,0 +1,66 @@
|
||||
#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
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
class Node;
|
||||
|
||||
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_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 false;
|
||||
}
|
||||
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;
|
||||
};
|
||||
|
||||
void operator >> (const Node& node, Binary& binary);
|
||||
}
|
||||
|
||||
#endif // BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
@@ -1,7 +1,7 @@
|
||||
#ifndef ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,18 +1,30 @@
|
||||
#ifndef CONVERSION_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define CONVERSION_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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/null.h"
|
||||
#include "yaml-cpp/traits.h"
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
// traits for conversion
|
||||
|
||||
template<typename T>
|
||||
struct is_scalar_convertible { enum { value = is_numeric<T>::value }; };
|
||||
|
||||
template<> struct is_scalar_convertible<std::string> { enum { value = true }; };
|
||||
template<> struct is_scalar_convertible<bool> { enum { value = true }; };
|
||||
template<> struct is_scalar_convertible<_Null> { enum { value = true }; };
|
||||
|
||||
// actual conversion
|
||||
|
||||
inline bool Convert(const std::string& input, std::string& output) {
|
||||
output = input;
|
||||
return true;
|
||||
@@ -21,12 +33,42 @@ namespace YAML
|
||||
YAML_CPP_API bool Convert(const std::string& input, bool& output);
|
||||
YAML_CPP_API bool Convert(const std::string& input, _Null& output);
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline bool Convert(const std::string& input, T& output, typename enable_if<is_numeric<T> >::type * = 0) {
|
||||
std::stringstream stream(input);
|
||||
stream.unsetf(std::ios::dec);
|
||||
stream >> output;
|
||||
return !!stream;
|
||||
if((stream >> output) && (stream >> std::ws).eof())
|
||||
return true;
|
||||
|
||||
if(std::numeric_limits<T>::has_infinity) {
|
||||
if(IsInfinity(input)) {
|
||||
output = std::numeric_limits<T>::infinity();
|
||||
return true;
|
||||
} else if(IsNegativeInfinity(input)) {
|
||||
output = -std::numeric_limits<T>::infinity();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(std::numeric_limits<T>::has_quiet_NaN && IsNaN(input)) {
|
||||
output = std::numeric_limits<T>::quiet_NaN();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,12 +1,13 @@
|
||||
#ifndef EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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/emittermanip.h"
|
||||
#include "yaml-cpp/ostream.h"
|
||||
#include "yaml-cpp/noncopyable.h"
|
||||
@@ -43,20 +44,24 @@ namespace YAML
|
||||
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& null);
|
||||
Emitter& Write(const _Binary& binary);
|
||||
Emitter& Write(const Binary& binary);
|
||||
|
||||
template <typename T>
|
||||
Emitter& WriteIntegralType(T value);
|
||||
@@ -69,10 +74,12 @@ namespace YAML
|
||||
void PreWriteStreamable(std::stringstream& str);
|
||||
void PostWriteIntegralType(const std::stringstream& str);
|
||||
void PostWriteStreamable(const std::stringstream& str);
|
||||
|
||||
template<typename T> void SetStreamablePrecision(std::stringstream&) {}
|
||||
unsigned GetFloatPrecision() const;
|
||||
unsigned GetDoublePrecision() const;
|
||||
|
||||
private:
|
||||
enum ATOMIC_TYPE { AT_SCALAR, AT_SEQ, AT_BLOCK_SEQ, AT_FLOW_SEQ, AT_MAP, AT_BLOCK_MAP, AT_FLOW_MAP };
|
||||
|
||||
void PreAtomicWrite();
|
||||
bool GotoNextPreAtomicState();
|
||||
void PostAtomicWrite();
|
||||
@@ -119,20 +126,35 @@ namespace YAML
|
||||
|
||||
std::stringstream str;
|
||||
PreWriteStreamable(str);
|
||||
SetStreamablePrecision<T>(str);
|
||||
str << value;
|
||||
PostWriteStreamable(str);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void Emitter::SetStreamablePrecision<float>(std::stringstream& str)
|
||||
{
|
||||
str.precision(GetFloatPrecision());
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void Emitter::SetStreamablePrecision<double>(std::stringstream& str)
|
||||
{
|
||||
str.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 Binary& b) { return emitter.Write(b); }
|
||||
|
||||
inline Emitter& operator << (Emitter& emitter, const char *v) { return emitter.Write(std::string(v)); }
|
||||
|
||||
@@ -155,6 +177,10 @@ namespace YAML
|
||||
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
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
@@ -125,16 +125,25 @@ namespace YAML
|
||||
inline _Comment Comment(const std::string content) {
|
||||
return _Comment(content);
|
||||
}
|
||||
|
||||
struct _Binary {
|
||||
_Binary(const char *data_, std::size_t size_): data(data_), size(size_) {}
|
||||
const char *data;
|
||||
std::size_t size;
|
||||
};
|
||||
|
||||
inline _Binary Binary(const char *data, std::size_t size) {
|
||||
return _Binary(data, size);
|
||||
}
|
||||
|
||||
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
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef LTNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define LTNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,18 +1,18 @@
|
||||
#ifndef NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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/conversion.h"
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include "yaml-cpp/exceptions.h"
|
||||
#include "yaml-cpp/iterator.h"
|
||||
#include "yaml-cpp/ltnode.h"
|
||||
#include "yaml-cpp/mark.h"
|
||||
#include "yaml-cpp/noncopyable.h"
|
||||
#include "yaml-cpp/conversion.h"
|
||||
#include "yaml-cpp/iterator.h"
|
||||
#include "yaml-cpp/ltnode.h"
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
@@ -66,7 +66,7 @@ namespace YAML
|
||||
const T to() const;
|
||||
|
||||
template <typename T>
|
||||
friend YAML_CPP_API void operator >> (const Node& node, T& value);
|
||||
friend YAML_CPP_API typename enable_if<is_scalar_convertible<T> >::type operator >> (const Node& node, T& value);
|
||||
|
||||
// retrieval for maps and sequences
|
||||
template <typename T>
|
||||
@@ -77,7 +77,9 @@ namespace YAML
|
||||
|
||||
// specific to maps
|
||||
const Node *FindValue(const char *key) const;
|
||||
const Node *FindValue(char *key) const;
|
||||
const Node& operator [] (const char *key) const;
|
||||
const Node& operator [] (char *key) const;
|
||||
|
||||
// for tags
|
||||
const std::string& Tag() const { return m_tag; }
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef NODEIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NODEIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace YAML
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void operator >> (const Node& node, T& value) {
|
||||
inline typename enable_if<is_scalar_convertible<T> >::type operator >> (const Node& node, T& value) {
|
||||
if(!ConvertScalar(node, value))
|
||||
throw InvalidScalar(node.m_mark);
|
||||
}
|
||||
@@ -68,10 +68,18 @@ namespace YAML
|
||||
inline const Node *Node::FindValue(const char *key) const {
|
||||
return FindValue(std::string(key));
|
||||
}
|
||||
|
||||
inline const Node *Node::FindValue(char *key) const {
|
||||
return FindValue(std::string(key));
|
||||
}
|
||||
|
||||
inline const Node& Node::operator [] (const char *key) const {
|
||||
return GetValue(std::string(key));
|
||||
}
|
||||
|
||||
inline const Node& Node::operator [] (char *key) const {
|
||||
return GetValue(std::string(key));
|
||||
}
|
||||
}
|
||||
|
||||
#endif // NODEIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef NODEREADIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NODEREADIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef NODEUTIL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NODEUTIL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace YAML
|
||||
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);
|
||||
YAML_CPP_API bool IsNull(const Node& node); // old API only
|
||||
|
||||
extern YAML_CPP_API _Null Null;
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef OSTREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define OSTREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
@@ -32,7 +32,8 @@ namespace YAML
|
||||
void Load(std::istream& in);
|
||||
bool HandleNextDocument(EventHandler& eventHandler);
|
||||
|
||||
bool GetNextDocument(Node& document);
|
||||
bool GetNextDocument(Node& document); // old API only
|
||||
|
||||
void PrintTokens(std::ostream& out);
|
||||
|
||||
private:
|
||||
|
@@ -1,39 +1,44 @@
|
||||
#ifndef STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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 T>
|
||||
inline Emitter& operator << (Emitter& emitter, const std::vector <T>& v) {
|
||||
typedef typename std::vector <T> vec;
|
||||
template<typename Seq>
|
||||
inline Emitter& EmitSeq(Emitter& emitter, const Seq& seq) {
|
||||
emitter << BeginSeq;
|
||||
for(typename vec::const_iterator it=v.begin();it!=v.end();++it)
|
||||
emitter << *it;
|
||||
emitter << EndSeq;
|
||||
return emitter;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline Emitter& operator << (Emitter& emitter, const std::list <T>& v) {
|
||||
typedef typename std::list <T> list;
|
||||
emitter << BeginSeq;
|
||||
for(typename list::const_iterator it=v.begin();it!=v.end();++it)
|
||||
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) {
|
||||
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)
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef STLNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define STLNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,17 +1,17 @@
|
||||
#ifndef YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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/parser.h"
|
||||
#include "yaml-cpp/node.h"
|
||||
#include "yaml-cpp/stlnode.h"
|
||||
#include "yaml-cpp/iterator.h"
|
||||
#include "yaml-cpp/emitter.h"
|
||||
#include "yaml-cpp/stlemitter.h"
|
||||
#include "yaml-cpp/exceptions.h"
|
||||
|
||||
#include "yaml-cpp/node.h"
|
||||
#include "yaml-cpp/stlnode.h"
|
||||
#include "yaml-cpp/iterator.h"
|
||||
|
||||
#endif // YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
102
src/binary.cpp
Normal file
102
src/binary.cpp
Normal file
@@ -0,0 +1,102 @@
|
||||
#include "yaml-cpp/binary.h"
|
||||
#include "yaml-cpp/node.h"
|
||||
|
||||
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::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();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void operator >> (const Node& node, Binary& binary)
|
||||
{
|
||||
std::string scalar;
|
||||
node.GetScalar(scalar);
|
||||
std::vector<unsigned char> data = DecodeBase64(scalar);
|
||||
binary.swap(data);
|
||||
}
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
#ifndef COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,10 +1,11 @@
|
||||
#ifndef GRAPHBUILDERADAPTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define GRAPHBUILDERADAPTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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 <cstdlib>
|
||||
#include <map>
|
||||
#include <stack>
|
||||
#include "yaml-cpp/eventhandler.h"
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef DIRECTIVES_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define DIRECTIVES_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -93,6 +93,16 @@ namespace YAML
|
||||
{
|
||||
return m_pState->SetPostCommentIndent(n, GLOBAL);
|
||||
}
|
||||
|
||||
bool Emitter::SetFloatPrecision(unsigned n)
|
||||
{
|
||||
return m_pState->SetFloatPrecision(n, GLOBAL);
|
||||
}
|
||||
|
||||
bool Emitter::SetDoublePrecision(unsigned n)
|
||||
{
|
||||
return m_pState->SetDoublePrecision(n, GLOBAL);
|
||||
}
|
||||
|
||||
// SetLocalValue
|
||||
// . Either start/end a group, or set a modifier locally
|
||||
@@ -145,6 +155,15 @@ namespace YAML
|
||||
return *this;
|
||||
}
|
||||
|
||||
Emitter& Emitter::SetLocalPrecision(const _Precision& precision)
|
||||
{
|
||||
if(precision.floatPrecision >= 0)
|
||||
m_pState->SetFloatPrecision(precision.floatPrecision, LOCAL);
|
||||
if(precision.doublePrecision >= 0)
|
||||
m_pState->SetDoublePrecision(precision.doublePrecision, LOCAL);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// GotoNextPreAtomicState
|
||||
// . Runs the state machine, emitting if necessary, and returns 'true' if done (i.e., ready to emit an atom)
|
||||
bool Emitter::GotoNextPreAtomicState()
|
||||
@@ -186,6 +205,7 @@ namespace YAML
|
||||
case ES_WRITING_FLOW_SEQ_ENTRY:
|
||||
return true;
|
||||
case ES_DONE_WITH_FLOW_SEQ_ENTRY:
|
||||
EmitSeparationIfNecessary();
|
||||
m_stream << ',';
|
||||
m_pState->RequireSoftSeparation();
|
||||
m_pState->SwitchState(ES_WAITING_FOR_FLOW_SEQ_ENTRY);
|
||||
@@ -221,9 +241,9 @@ namespace YAML
|
||||
m_pState->SetError(ErrorMsg::EXPECTED_KEY_TOKEN);
|
||||
return true;
|
||||
case ES_WAITING_FOR_FLOW_MAP_KEY:
|
||||
EmitSeparationIfNecessary();
|
||||
m_pState->SwitchState(ES_WRITING_FLOW_MAP_KEY);
|
||||
if(m_pState->CurrentlyInLongKey()) {
|
||||
EmitSeparationIfNecessary();
|
||||
m_stream << '?';
|
||||
m_pState->RequireSoftSeparation();
|
||||
}
|
||||
@@ -234,6 +254,7 @@ namespace YAML
|
||||
m_pState->SetError(ErrorMsg::EXPECTED_VALUE_TOKEN);
|
||||
return true;
|
||||
case ES_WAITING_FOR_FLOW_MAP_VALUE:
|
||||
EmitSeparationIfNecessary();
|
||||
m_stream << ':';
|
||||
m_pState->RequireSoftSeparation();
|
||||
m_pState->SwitchState(ES_WRITING_FLOW_MAP_VALUE);
|
||||
@@ -496,6 +517,7 @@ namespace YAML
|
||||
} else if(flowType == FT_FLOW) {
|
||||
// Note: flow maps are allowed to be empty
|
||||
assert(curState == ES_DONE_WITH_FLOW_MAP_VALUE || curState == ES_WAITING_FOR_FLOW_MAP_ENTRY);
|
||||
EmitSeparationIfNecessary();
|
||||
m_stream << "}";
|
||||
} else
|
||||
assert(false);
|
||||
@@ -526,6 +548,7 @@ namespace YAML
|
||||
m_pState->UnsetSeparation();
|
||||
m_pState->SwitchState(ES_WAITING_FOR_BLOCK_MAP_KEY);
|
||||
} else if(flowType == FT_FLOW) {
|
||||
EmitSeparationIfNecessary();
|
||||
if(curState == ES_DONE_WITH_FLOW_MAP_VALUE) {
|
||||
m_stream << ',';
|
||||
m_pState->RequireSoftSeparation();
|
||||
@@ -647,9 +670,11 @@ namespace YAML
|
||||
str << std::dec;
|
||||
break;
|
||||
case Hex:
|
||||
str << "0x";
|
||||
str << std::hex;
|
||||
break;
|
||||
case Oct:
|
||||
case Oct:
|
||||
str << "0";
|
||||
str << std::oct;
|
||||
break;
|
||||
default:
|
||||
@@ -657,13 +682,22 @@ namespace YAML
|
||||
}
|
||||
}
|
||||
|
||||
void Emitter::PreWriteStreamable(std::stringstream& str)
|
||||
void Emitter::PreWriteStreamable(std::stringstream&)
|
||||
{
|
||||
PreAtomicWrite();
|
||||
EmitSeparationIfNecessary();
|
||||
str.precision(15);
|
||||
}
|
||||
|
||||
unsigned Emitter::GetFloatPrecision() const
|
||||
{
|
||||
return m_pState->GetFloatPrecision();
|
||||
}
|
||||
|
||||
unsigned Emitter::GetDoublePrecision() const
|
||||
{
|
||||
return m_pState->GetDoublePrecision();
|
||||
}
|
||||
|
||||
void Emitter::PostWriteIntegralType(const std::stringstream& str)
|
||||
{
|
||||
m_stream << str.str();
|
||||
@@ -729,6 +763,20 @@ namespace YAML
|
||||
return *this;
|
||||
}
|
||||
|
||||
Emitter& Emitter::Write(char ch)
|
||||
{
|
||||
if(!good())
|
||||
return *this;
|
||||
|
||||
PreAtomicWrite();
|
||||
EmitSeparationIfNecessary();
|
||||
|
||||
Utils::WriteChar(m_stream, ch);
|
||||
|
||||
PostAtomicWrite();
|
||||
return *this;
|
||||
}
|
||||
|
||||
Emitter& Emitter::Write(const _Alias& alias)
|
||||
{
|
||||
if(!good())
|
||||
@@ -796,8 +844,12 @@ namespace YAML
|
||||
if(!good())
|
||||
return *this;
|
||||
|
||||
m_stream << Indentation(m_pState->GetPreCommentIndent());
|
||||
if(m_stream.col() > 0)
|
||||
m_stream << Indentation(m_pState->GetPreCommentIndent());
|
||||
Utils::WriteComment(m_stream, comment.content, m_pState->GetPostCommentIndent());
|
||||
m_pState->RequireHardSeparation();
|
||||
m_pState->ForceHardSeparation();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -813,7 +865,7 @@ namespace YAML
|
||||
return *this;
|
||||
}
|
||||
|
||||
Emitter& Emitter::Write(const _Binary& binary)
|
||||
Emitter& Emitter::Write(const Binary& binary)
|
||||
{
|
||||
Write(SecondaryTag("binary"));
|
||||
|
||||
@@ -822,7 +874,7 @@ namespace YAML
|
||||
|
||||
PreAtomicWrite();
|
||||
EmitSeparationIfNecessary();
|
||||
Utils::WriteBinary(m_stream, binary.data, binary.size);
|
||||
Utils::WriteBinary(m_stream, binary);
|
||||
PostAtomicWrite();
|
||||
return *this;
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
#include "emitterstate.h"
|
||||
#include "yaml-cpp/exceptions.h"
|
||||
#include <limits>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
@@ -21,6 +22,8 @@ namespace YAML
|
||||
m_seqFmt.set(Block);
|
||||
m_mapFmt.set(Block);
|
||||
m_mapKeyFmt.set(Auto);
|
||||
m_floatPrecision.set(6);
|
||||
m_doublePrecision.set(15);
|
||||
}
|
||||
|
||||
EmitterState::~EmitterState()
|
||||
@@ -261,5 +264,21 @@ namespace YAML
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool EmitterState::SetFloatPrecision(int value, FMT_SCOPE scope)
|
||||
{
|
||||
if(value < 0 || value > std::numeric_limits<float>::digits10)
|
||||
return false;
|
||||
_Set(m_floatPrecision, value, scope);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EmitterState::SetDoublePrecision(int value, FMT_SCOPE scope)
|
||||
{
|
||||
if(value < 0 || value > std::numeric_limits<double>::digits10)
|
||||
return false;
|
||||
_Set(m_doublePrecision, value, scope);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef EMITTERSTATE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define EMITTERSTATE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
@@ -145,6 +145,11 @@ namespace YAML
|
||||
|
||||
bool SetMapKeyFormat(EMITTER_MANIP value, FMT_SCOPE scope);
|
||||
EMITTER_MANIP GetMapKeyFormat() const { return m_mapKeyFmt.get(); }
|
||||
|
||||
bool SetFloatPrecision(int value, FMT_SCOPE scope);
|
||||
unsigned GetFloatPrecision() const { return m_floatPrecision.get(); }
|
||||
bool SetDoublePrecision(int value, FMT_SCOPE scope);
|
||||
unsigned GetDoublePrecision() const { return m_doublePrecision.get(); }
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
@@ -169,6 +174,8 @@ namespace YAML
|
||||
Setting<EMITTER_MANIP> m_seqFmt;
|
||||
Setting<EMITTER_MANIP> m_mapFmt;
|
||||
Setting<EMITTER_MANIP> m_mapKeyFmt;
|
||||
Setting<int> m_floatPrecision;
|
||||
Setting<int> m_doublePrecision;
|
||||
|
||||
SettingChanges m_modifiedSettings;
|
||||
SettingChanges m_globalModifiedSettings;
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#include "emitterutils.h"
|
||||
#include "exp.h"
|
||||
#include "indentation.h"
|
||||
#include "yaml-cpp/binary.h"
|
||||
#include "yaml-cpp/exceptions.h"
|
||||
#include "stringsource.h"
|
||||
#include <sstream>
|
||||
@@ -128,6 +129,9 @@ namespace YAML
|
||||
}
|
||||
|
||||
bool IsValidPlainScalar(const std::string& str, bool inFlow, bool allowOnlyAscii) {
|
||||
if(str.empty())
|
||||
return false;
|
||||
|
||||
// first check the start
|
||||
const RegEx& start = (inFlow ? Exp::PlainScalarInFlow() : Exp::PlainScalar());
|
||||
if(!start.Matches(str))
|
||||
@@ -265,9 +269,29 @@ namespace YAML
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WriteChar(ostream& out, char ch)
|
||||
{
|
||||
if(('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z'))
|
||||
out << ch;
|
||||
else if((0x20 <= ch && ch <= 0x7e) || ch == ' ')
|
||||
out << "\"" << ch << "\"";
|
||||
else if(ch == '\t')
|
||||
out << "\"\\t\"";
|
||||
else if(ch == '\n')
|
||||
out << "\"\\n\"";
|
||||
else if(ch == '\b')
|
||||
out << "\"\\b\"";
|
||||
else {
|
||||
out << "\"";
|
||||
WriteDoubleQuoteEscapeSequence(out, ch);
|
||||
out << "\"";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WriteComment(ostream& out, const std::string& str, int postCommentIndent)
|
||||
{
|
||||
unsigned curIndent = out.col();
|
||||
const unsigned curIndent = out.col();
|
||||
out << "#" << Indentation(postCommentIndent);
|
||||
int codePoint;
|
||||
for(std::string::const_iterator i = str.begin();
|
||||
@@ -344,41 +368,10 @@ namespace YAML
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WriteBinary(ostream& out, const char *data, std::size_t size)
|
||||
bool WriteBinary(ostream& out, const Binary& binary)
|
||||
{
|
||||
static const char encoding[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
const char PAD = '=';
|
||||
|
||||
out << "\"";
|
||||
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;
|
||||
}
|
||||
|
||||
out << "\"";
|
||||
return true;
|
||||
WriteDoubleQuotedString(out, EncodeBase64(binary.data(), binary.size()), false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef EMITTERUTILS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define EMITTERUTILS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
@@ -11,18 +11,21 @@
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
class Binary;
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
bool WriteString(ostream& out, const std::string& str, bool inFlow, bool escapeNonAscii);
|
||||
bool WriteSingleQuotedString(ostream& out, const std::string& str);
|
||||
bool WriteDoubleQuotedString(ostream& out, const std::string& str, bool escapeNonAscii);
|
||||
bool WriteLiteralString(ostream& out, const std::string& str, int indent);
|
||||
bool WriteChar(ostream& out, char ch);
|
||||
bool WriteComment(ostream& out, const std::string& str, int postCommentIndent);
|
||||
bool WriteAlias(ostream& out, const std::string& str);
|
||||
bool WriteAnchor(ostream& out, const std::string& str);
|
||||
bool WriteTag(ostream& out, const std::string& str, bool verbatim);
|
||||
bool WriteTagWithPrefix(ostream& out, const std::string& prefix, const std::string& tag);
|
||||
bool WriteBinary(ostream& out, const char *data, std::size_t size);
|
||||
bool WriteBinary(ostream& out, const Binary& binary);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef EXP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define EXP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace YAML
|
||||
// . In the block context - ? : must be not be followed with a space.
|
||||
// . In the flow context ? is illegal and : and - must not be followed with a space.
|
||||
inline const RegEx& PlainScalar() {
|
||||
static const RegEx e = !(BlankOrBreak() || RegEx(",[]{}#&*!|>\'\"%@`", REGEX_OR) || (RegEx("-?:", REGEX_OR) + Blank()));
|
||||
static const RegEx e = !(BlankOrBreak() || RegEx(",[]{}#&*!|>\'\"%@`", REGEX_OR) || (RegEx("-?:", REGEX_OR) + (BlankOrBreak() || RegEx())));
|
||||
return e;
|
||||
}
|
||||
inline const RegEx& PlainScalarInFlow() {
|
||||
@@ -149,7 +149,7 @@ namespace YAML
|
||||
return e;
|
||||
}
|
||||
inline const RegEx& EndScalarInFlow() {
|
||||
static const RegEx e = (RegEx(':') + (BlankOrBreak() || RegEx(",]}", REGEX_OR))) || RegEx(",?[]{}", REGEX_OR);
|
||||
static const RegEx e = (RegEx(':') + (BlankOrBreak() || RegEx() || RegEx(",]}", REGEX_OR))) || RegEx(",?[]{}", REGEX_OR);
|
||||
return e;
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef INDENTATION_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define INDENTATION_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef ITERPRIV_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define ITERPRIV_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,14 +1,14 @@
|
||||
#include "yaml-cpp/node.h"
|
||||
#include "yaml-cpp/aliasmanager.h"
|
||||
#include "yaml-cpp/emitfromevents.h"
|
||||
#include "yaml-cpp/emitter.h"
|
||||
#include "yaml-cpp/eventhandler.h"
|
||||
#include "iterpriv.h"
|
||||
#include "nodebuilder.h"
|
||||
#include "nodeownership.h"
|
||||
#include "scanner.h"
|
||||
#include "tag.h"
|
||||
#include "token.h"
|
||||
#include "yaml-cpp/aliasmanager.h"
|
||||
#include "yaml-cpp/emitfromevents.h"
|
||||
#include "yaml-cpp/emitter.h"
|
||||
#include "yaml-cpp/eventhandler.h"
|
||||
#include <cassert>
|
||||
#include <stdexcept>
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef NODE_OWNERSHIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NODE_OWNERSHIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#include "yaml-cpp/parser.h"
|
||||
#include "directives.h"
|
||||
#include "yaml-cpp/eventhandler.h"
|
||||
#include "yaml-cpp/exceptions.h"
|
||||
#include "yaml-cpp/node.h"
|
||||
#include "directives.h"
|
||||
#include "nodebuilder.h"
|
||||
#include "scanner.h"
|
||||
#include "singledocparser.h"
|
||||
|
@@ -1,11 +1,13 @@
|
||||
#ifndef PTR_STACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define PTR_STACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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/noncopyable.h"
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
|
@@ -1,11 +1,13 @@
|
||||
#ifndef PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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/noncopyable.h"
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef REGEX_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define REGEX_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef REGEXIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define REGEXIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef SCANNER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define SCANNER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -23,6 +23,7 @@ namespace YAML
|
||||
bool emptyLine = false, moreIndented = false;
|
||||
int foldedNewlineCount = 0;
|
||||
bool foldedNewlineStartedMoreIndented = false;
|
||||
std::size_t lastEscapedChar = std::string::npos;
|
||||
std::string scalar;
|
||||
params.leadingSpaces = false;
|
||||
|
||||
@@ -52,6 +53,7 @@ namespace YAML
|
||||
// eat escape character and get out (but preserve trailing whitespace!)
|
||||
INPUT.get();
|
||||
lastNonWhitespaceChar = scalar.size();
|
||||
lastEscapedChar = scalar.size();
|
||||
escapedNewline = true;
|
||||
break;
|
||||
}
|
||||
@@ -60,6 +62,7 @@ namespace YAML
|
||||
if(INPUT.peek() == params.escape) {
|
||||
scalar += Exp::Escape(INPUT);
|
||||
lastNonWhitespaceChar = scalar.size();
|
||||
lastEscapedChar = scalar.size();
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -171,20 +174,32 @@ namespace YAML
|
||||
// post-processing
|
||||
if(params.trimTrailingSpaces) {
|
||||
std::size_t pos = scalar.find_last_not_of(' ');
|
||||
if(lastEscapedChar != std::string::npos) {
|
||||
if(pos < lastEscapedChar || pos == std::string::npos)
|
||||
pos = lastEscapedChar;
|
||||
}
|
||||
if(pos < scalar.size())
|
||||
scalar.erase(pos + 1);
|
||||
}
|
||||
|
||||
switch(params.chomp) {
|
||||
case CLIP: {
|
||||
const std::size_t pos = scalar.find_last_not_of('\n');
|
||||
std::size_t pos = scalar.find_last_not_of('\n');
|
||||
if(lastEscapedChar != std::string::npos) {
|
||||
if(pos < lastEscapedChar || pos == std::string::npos)
|
||||
pos = lastEscapedChar;
|
||||
}
|
||||
if(pos == std::string::npos)
|
||||
scalar.erase();
|
||||
else if(pos + 1 < scalar.size())
|
||||
scalar.erase(pos + 2);
|
||||
} break;
|
||||
case STRIP: {
|
||||
const std::size_t pos = scalar.find_last_not_of('\n');
|
||||
std::size_t pos = scalar.find_last_not_of('\n');
|
||||
if(lastEscapedChar != std::string::npos) {
|
||||
if(pos < lastEscapedChar || pos == std::string::npos)
|
||||
pos = lastEscapedChar;
|
||||
}
|
||||
if(pos == std::string::npos)
|
||||
scalar.erase();
|
||||
else if(pos < scalar.size())
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef SCANSCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define SCANSCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef SCANTAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define SCANTAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef SETTING_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define SETTING_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef SINGLEDOCPARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define SINGLEDOCPARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -178,7 +178,7 @@ namespace YAML
|
||||
}
|
||||
|
||||
Stream::Stream(std::istream& input)
|
||||
: m_input(input), m_nPushedBack(0),
|
||||
: m_input(input),
|
||||
m_pPrefetched(new unsigned char[YAML_PREFETCH_SIZE]),
|
||||
m_nPrefetchedAvailable(0), m_nPrefetchedUsed(0)
|
||||
{
|
||||
@@ -192,18 +192,17 @@ namespace YAML
|
||||
char_traits::int_type intro[4];
|
||||
int nIntroUsed = 0;
|
||||
UtfIntroState state = uis_start;
|
||||
for (; !s_introFinalState[state]; ) {
|
||||
for(; !s_introFinalState[state]; ) {
|
||||
std::istream::int_type ch = input.get();
|
||||
intro[nIntroUsed++] = ch;
|
||||
UtfIntroCharType charType = IntroCharTypeOf(ch);
|
||||
UtfIntroState newState = s_introTransitions[state][charType];
|
||||
int nUngets = s_introUngetCount[state][charType];
|
||||
if (nUngets > 0) {
|
||||
for (; nUngets > 0; --nUngets) {
|
||||
if (char_traits::eof() != intro[--nIntroUsed]) {
|
||||
m_bufPushback[m_nPushedBack++] =
|
||||
char_traits::to_char_type(intro[nIntroUsed]);
|
||||
}
|
||||
if(nUngets > 0) {
|
||||
input.clear();
|
||||
for(; nUngets > 0; --nUngets) {
|
||||
if(char_traits::eof() != intro[--nIntroUsed])
|
||||
input.putback(char_traits::to_char_type(intro[nIntroUsed]));
|
||||
}
|
||||
}
|
||||
state = newState;
|
||||
@@ -398,11 +397,6 @@ namespace YAML
|
||||
|
||||
unsigned char Stream::GetNextByte() const
|
||||
{
|
||||
if (m_nPushedBack)
|
||||
{
|
||||
return m_bufPushback[--m_nPushedBack];
|
||||
}
|
||||
|
||||
if (m_nPrefetchedUsed >= m_nPrefetchedAvailable)
|
||||
{
|
||||
std::streambuf *pBuf = m_input.rdbuf();
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
static const size_t MAX_PARSER_PUSHBACK = 8;
|
||||
|
||||
class Stream: private noncopyable
|
||||
{
|
||||
public:
|
||||
@@ -50,8 +48,6 @@ namespace YAML
|
||||
Mark m_mark;
|
||||
|
||||
CharacterSet m_charSet;
|
||||
unsigned char m_bufPushback[MAX_PARSER_PUSHBACK];
|
||||
mutable size_t m_nPushedBack;
|
||||
mutable std::deque<char> m_readahead;
|
||||
unsigned char* const m_pPrefetched;
|
||||
mutable size_t m_nPrefetchedAvailable;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef STREAMCHARSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define STREAMCHARSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef STRINGSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define STRINGSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef TAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define TAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
@@ -1,5 +1,10 @@
|
||||
file(GLOB test_headers [a-z]*.h)
|
||||
file(GLOB test_sources [a-z]*.cpp)
|
||||
file(GLOB test_old_api_sources old-api/[a-z]*.cpp)
|
||||
|
||||
list(APPEND test_sources ${test_old_api_sources})
|
||||
|
||||
include_directories(${YAML_CPP_SOURCE_DIR}/test)
|
||||
|
||||
add_executable(run-tests
|
||||
${test_sources}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
#include "tests.h"
|
||||
#include "yaml-cpp/yaml.h"
|
||||
#include <iostream>
|
||||
|
||||
namespace Test
|
||||
{
|
||||
@@ -282,6 +283,20 @@ namespace Test
|
||||
desiredOutput = "- &fred ~\n- *fred";
|
||||
}
|
||||
|
||||
void AliasAndAnchorInFlow(YAML::Emitter& out, std::string& desiredOutput)
|
||||
{
|
||||
out << YAML::Flow << YAML::BeginSeq;
|
||||
out << YAML::Anchor("fred");
|
||||
out << YAML::BeginMap;
|
||||
out << YAML::Key << "name" << YAML::Value << "Fred";
|
||||
out << YAML::Key << "age" << YAML::Value << 42;
|
||||
out << YAML::EndMap;
|
||||
out << YAML::Alias("fred");
|
||||
out << YAML::EndSeq;
|
||||
|
||||
desiredOutput = "[&fred {name: Fred, age: 42}, *fred]";
|
||||
}
|
||||
|
||||
void SimpleVerbatimTag(YAML::Emitter& out, std::string& desiredOutput)
|
||||
{
|
||||
out << YAML::VerbatimTag("!foo") << "bar";
|
||||
@@ -503,6 +518,40 @@ namespace Test
|
||||
|
||||
desiredOutput = "? long key # long key\n: value";
|
||||
}
|
||||
|
||||
void InitialComment(YAML::Emitter& out, std::string& desiredOutput)
|
||||
{
|
||||
out << YAML::Comment("A comment describing the purpose of the file.");
|
||||
out << YAML::BeginMap << YAML::Key << "key" << YAML::Value << "value" << YAML::EndMap;
|
||||
|
||||
desiredOutput = "# A comment describing the purpose of the file.\nkey: value";
|
||||
}
|
||||
|
||||
void InitialCommentWithDocIndicator(YAML::Emitter& out, std::string& desiredOutput)
|
||||
{
|
||||
out << YAML::BeginDoc << YAML::Comment("A comment describing the purpose of the file.");
|
||||
out << YAML::BeginMap << YAML::Key << "key" << YAML::Value << "value" << YAML::EndMap;
|
||||
|
||||
desiredOutput = "---\n# A comment describing the purpose of the file.\nkey: value";
|
||||
}
|
||||
|
||||
void CommentInFlowSeq(YAML::Emitter& out, std::string& desiredOutput)
|
||||
{
|
||||
out << YAML::Flow << YAML::BeginSeq << "foo" << YAML::Comment("foo!") << "bar" << YAML::EndSeq;
|
||||
|
||||
desiredOutput = "[foo # foo!\n, bar]";
|
||||
}
|
||||
|
||||
void CommentInFlowMap(YAML::Emitter& out, std::string& desiredOutput)
|
||||
{
|
||||
out << YAML::Flow << YAML::BeginMap;
|
||||
out << YAML::Key << "foo" << YAML::Value << "foo value";
|
||||
out << YAML::Key << "bar" << YAML::Value << "bar value" << YAML::Comment("bar!");
|
||||
out << YAML::Key << "baz" << YAML::Value << "baz value" << YAML::Comment("baz!");
|
||||
out << YAML::EndMap;
|
||||
|
||||
desiredOutput = "{foo: foo value, bar: bar value # bar!\n, baz: baz value # baz!\n}";
|
||||
}
|
||||
|
||||
void Indentation(YAML::Emitter& out, std::string& desiredOutput)
|
||||
{
|
||||
@@ -688,9 +737,9 @@ namespace Test
|
||||
{
|
||||
out << YAML::Flow << YAML::BeginMap;
|
||||
out << YAML::Key << "a" << YAML::Value << "foo" << YAML::Newline;
|
||||
out << YAML::Key << "b" << YAML::Newline << YAML::Value << "bar";
|
||||
out << YAML::Key << "b" << YAML::Value << "bar";
|
||||
out << YAML::EndMap;
|
||||
desiredOutput = "{a: foo\n, b\n: bar}";
|
||||
desiredOutput = "{a: foo\n, b: bar}";
|
||||
}
|
||||
|
||||
void LotsOfNewlines(YAML::Emitter& out, std::string& desiredOutput)
|
||||
@@ -711,19 +760,19 @@ namespace Test
|
||||
|
||||
void Binary(YAML::Emitter& out, std::string& desiredOutput)
|
||||
{
|
||||
out << YAML::Binary("Hello, World!", 13);
|
||||
out << YAML::Binary(reinterpret_cast<const unsigned char*>("Hello, World!"), 13);
|
||||
desiredOutput = "!!binary \"SGVsbG8sIFdvcmxkIQ==\"";
|
||||
}
|
||||
|
||||
void LongBinary(YAML::Emitter& out, std::string& desiredOutput)
|
||||
{
|
||||
out << YAML::Binary("Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.\n", 270);
|
||||
out << YAML::Binary(reinterpret_cast<const unsigned char*>("Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.\n"), 270);
|
||||
desiredOutput = "!!binary \"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4K\"";
|
||||
}
|
||||
|
||||
void EmptyBinary(YAML::Emitter& out, std::string& desiredOutput)
|
||||
{
|
||||
out << YAML::Binary("", 0);
|
||||
out << YAML::Binary(reinterpret_cast<const unsigned char *>(""), 0);
|
||||
desiredOutput = "!!binary \"\"";
|
||||
}
|
||||
|
||||
@@ -742,6 +791,12 @@ namespace Test
|
||||
desiredOutput = "apple: \":\"\nbanana: \":\"";
|
||||
}
|
||||
|
||||
void ColonAtEndOfScalarInFlow(YAML::Emitter& out, std::string& desiredOutput)
|
||||
{
|
||||
out << YAML::Flow << YAML::BeginMap << YAML::Key << "C:" << YAML::Value << "C:" << YAML::EndMap;
|
||||
desiredOutput = "{\"C:\": \"C:\"}";
|
||||
}
|
||||
|
||||
void BoolFormatting(YAML::Emitter& out, std::string& desiredOutput)
|
||||
{
|
||||
out << YAML::BeginSeq;
|
||||
@@ -798,8 +853,65 @@ namespace Test
|
||||
out << "Oops";
|
||||
desiredOutput = "Hi\n---\nBye\n---\nOops";
|
||||
}
|
||||
|
||||
void EmptyString(YAML::Emitter& out, std::string& desiredOutput)
|
||||
{
|
||||
out << YAML::BeginMap;
|
||||
out << YAML::Key << "key" << YAML::Value << "";
|
||||
out << YAML::EndMap;
|
||||
desiredOutput = "key: \"\"";
|
||||
}
|
||||
|
||||
void SingleChar(YAML::Emitter& out, std::string& desiredOutput)
|
||||
{
|
||||
out << YAML::BeginSeq;
|
||||
out << 'a';
|
||||
out << ':';
|
||||
out << (char)0x10;
|
||||
out << '\n';
|
||||
out << ' ';
|
||||
out << '\t';
|
||||
out << YAML::EndSeq;
|
||||
desiredOutput = "- a\n- \":\"\n- \"\\x10\"\n- \"\\n\"\n- \" \"\n- \"\\t\"";
|
||||
}
|
||||
|
||||
void DefaultPrecision(YAML::Emitter& out, std::string& desiredOutput)
|
||||
{
|
||||
out << YAML::BeginSeq;
|
||||
out << 1.234f;
|
||||
out << 3.14159265358979;
|
||||
out << YAML::EndSeq;
|
||||
desiredOutput = "- 1.234\n- 3.14159265358979";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void SetPrecision(YAML::Emitter& out, std::string& desiredOutput)
|
||||
{
|
||||
out << YAML::BeginSeq;
|
||||
out << YAML::FloatPrecision(3) << 1.234f;
|
||||
out << YAML::DoublePrecision(6) << 3.14159265358979;
|
||||
out << YAML::EndSeq;
|
||||
desiredOutput = "- 1.23\n- 3.14159";
|
||||
}
|
||||
|
||||
void DashInBlockContext(YAML::Emitter& out, std::string& desiredOutput)
|
||||
{
|
||||
out << YAML::BeginMap;
|
||||
out << YAML::Key << "key" << YAML::Value << "-";
|
||||
out << YAML::EndMap;
|
||||
desiredOutput = "key: \"-\"";
|
||||
}
|
||||
|
||||
void HexAndOct(YAML::Emitter& out, std::string& desiredOutput)
|
||||
{
|
||||
out << YAML::Flow << YAML::BeginSeq;
|
||||
out << 31;
|
||||
out << YAML::Hex << 31;
|
||||
out << YAML::Oct << 31;
|
||||
out << YAML::EndSeq;
|
||||
desiredOutput = "[31, 0x1f, 037]";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// incorrect emitting
|
||||
|
||||
void ExtraEndSeq(YAML::Emitter& out, std::string& desiredError)
|
||||
@@ -963,6 +1075,7 @@ namespace Test
|
||||
RunEmitterTest(&Emitter::BlockMapAsKey, "block map as key", passed, total);
|
||||
RunEmitterTest(&Emitter::AliasAndAnchor, "alias and anchor", passed, total);
|
||||
RunEmitterTest(&Emitter::AliasAndAnchorWithNull, "alias and anchor with null", passed, total);
|
||||
RunEmitterTest(&Emitter::AliasAndAnchorInFlow, "alias and anchor in flow", passed, total);
|
||||
RunEmitterTest(&Emitter::SimpleVerbatimTag, "simple verbatim tag", passed, total);
|
||||
RunEmitterTest(&Emitter::VerbatimTagInBlockSeq, "verbatim tag in block seq", passed, total);
|
||||
RunEmitterTest(&Emitter::VerbatimTagInFlowSeq, "verbatim tag in flow seq", passed, total);
|
||||
@@ -980,6 +1093,10 @@ namespace Test
|
||||
RunEmitterTest(&Emitter::SimpleComment, "simple comment", passed, total);
|
||||
RunEmitterTest(&Emitter::MultiLineComment, "multi-line comment", passed, total);
|
||||
RunEmitterTest(&Emitter::ComplexComments, "complex comments", passed, total);
|
||||
RunEmitterTest(&Emitter::InitialComment, "initial comment", passed, total);
|
||||
RunEmitterTest(&Emitter::InitialCommentWithDocIndicator, "initial comment with doc indicator", passed, total);
|
||||
RunEmitterTest(&Emitter::CommentInFlowSeq, "comment in flow seq", passed, total);
|
||||
RunEmitterTest(&Emitter::CommentInFlowMap, "comment in flow map", passed, total);
|
||||
RunEmitterTest(&Emitter::Indentation, "indentation", passed, total);
|
||||
RunEmitterTest(&Emitter::SimpleGlobalSettings, "simple global settings", passed, total);
|
||||
RunEmitterTest(&Emitter::ComplexGlobalSettings, "complex global settings", passed, total);
|
||||
@@ -1002,9 +1119,16 @@ namespace Test
|
||||
RunEmitterTest(&Emitter::EmptyBinary, "empty binary", passed, total);
|
||||
RunEmitterTest(&Emitter::ColonAtEndOfScalar, "colon at end of scalar", passed, total);
|
||||
RunEmitterTest(&Emitter::ColonAsScalar, "colon as scalar", passed, total);
|
||||
RunEmitterTest(&Emitter::ColonAtEndOfScalarInFlow, "colon at end of scalar in flow", passed, total);
|
||||
RunEmitterTest(&Emitter::BoolFormatting, "bool formatting", passed, total);
|
||||
RunEmitterTest(&Emitter::DocStartAndEnd, "doc start and end", passed, total);
|
||||
RunEmitterTest(&Emitter::ImplicitDocStart, "implicit doc start", passed, total);
|
||||
RunEmitterTest(&Emitter::EmptyString, "empty string", passed, total);
|
||||
RunEmitterTest(&Emitter::SingleChar, "single char", passed, total);
|
||||
RunEmitterTest(&Emitter::DefaultPrecision, "default precision", passed, total);
|
||||
RunEmitterTest(&Emitter::SetPrecision, "set precision", passed, total);
|
||||
RunEmitterTest(&Emitter::DashInBlockContext, "dash in block context", passed, total);
|
||||
RunEmitterTest(&Emitter::HexAndOct, "hex and oct", passed, total);
|
||||
|
||||
RunEmitterErrorTest(&Emitter::ExtraEndSeq, "extra EndSeq", passed, total);
|
||||
RunEmitterErrorTest(&Emitter::ExtraEndMap, "extra EndMap", passed, total);
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef EMITTERTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define EMITTERTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
13
test/nodetests.h
Normal file
13
test/nodetests.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef NODETESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NODETESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
namespace Test {
|
||||
bool RunNodeTests();
|
||||
}
|
||||
|
||||
#endif // NODETESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A6666
|
||||
|
@@ -2,6 +2,7 @@
|
||||
#include "yaml-cpp/yaml.h"
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
namespace Test
|
||||
{
|
||||
@@ -803,7 +804,138 @@ namespace Test
|
||||
|
||||
return ExpectedTagValue(node, "!");
|
||||
}
|
||||
}
|
||||
|
||||
bool Infinity()
|
||||
{
|
||||
std::string input =
|
||||
"- .inf\n"
|
||||
"- .Inf\n"
|
||||
"- .INF\n"
|
||||
"- +.inf\n"
|
||||
"- +.Inf\n"
|
||||
"- +.INF\n"
|
||||
"- -.inf\n"
|
||||
"- -.Inf\n"
|
||||
"- -.INF\n";
|
||||
std::stringstream stream(input);
|
||||
YAML::Parser parser(stream);
|
||||
YAML::Node doc;
|
||||
parser.GetNextDocument(doc);
|
||||
|
||||
for(unsigned i=0;i<doc.size();i++)
|
||||
if(doc[i].to<double>() != (i < 6 ? +1 : -1) * std::numeric_limits<double>::infinity())
|
||||
return false;
|
||||
for(unsigned i=0;i<doc.size();i++)
|
||||
if(doc[i].to<long double>() != (i < 6 ? +1 : -1) * std::numeric_limits<long double>::infinity())
|
||||
return false;
|
||||
for(unsigned i=0;i<doc.size();i++)
|
||||
if(doc[i].to<float>() != (i < 6 ? +1 : -1) * std::numeric_limits<float>::infinity())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NaN()
|
||||
{
|
||||
std::string input =
|
||||
"- .nan\n"
|
||||
"- .NaN\n"
|
||||
"- .NAN\n";
|
||||
std::stringstream stream(input);
|
||||
YAML::Parser parser(stream);
|
||||
YAML::Node doc;
|
||||
parser.GetNextDocument(doc);
|
||||
|
||||
for(unsigned i=0;i<doc.size();i++) {
|
||||
double d;
|
||||
doc[i] >> d;
|
||||
if(d == d)
|
||||
return false;
|
||||
}
|
||||
for(unsigned i=0;i<doc.size();i++) {
|
||||
long double d;
|
||||
doc[i] >> d;
|
||||
if(d == d)
|
||||
return false;
|
||||
}
|
||||
for(unsigned i=0;i<doc.size();i++) {
|
||||
float d;
|
||||
doc[i] >> d;
|
||||
if(d == d)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NonConstKey()
|
||||
{
|
||||
std::string input = "{a: 1}";
|
||||
std::stringstream stream(input);
|
||||
YAML::Parser parser(stream);
|
||||
YAML::Node doc;
|
||||
parser.GetNextDocument(doc);
|
||||
|
||||
std::vector<char> key(2);
|
||||
key[0] = 'a';
|
||||
key[1] = '\0';
|
||||
if(doc[&key[0]].to<int>() != 1)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SingleChar()
|
||||
{
|
||||
std::string input = "5";
|
||||
std::stringstream stream(input);
|
||||
YAML::Parser parser(stream);
|
||||
YAML::Node doc;
|
||||
parser.GetNextDocument(doc);
|
||||
|
||||
return doc.to<int>() == 5;
|
||||
}
|
||||
|
||||
bool QuotedNewline()
|
||||
{
|
||||
std::string input = "foo: \"\\n\"";
|
||||
std::stringstream stream(input);
|
||||
YAML::Parser parser(stream);
|
||||
YAML::Node doc;
|
||||
parser.GetNextDocument(doc);
|
||||
|
||||
return doc["foo"].to<std::string>() == "\n";
|
||||
}
|
||||
|
||||
bool DoubleAsInt()
|
||||
{
|
||||
std::string input = "1.5";
|
||||
std::stringstream stream(input);
|
||||
YAML::Parser parser(stream);
|
||||
YAML::Node doc;
|
||||
parser.GetNextDocument(doc);
|
||||
|
||||
try {
|
||||
doc.to<int>();
|
||||
} catch(const YAML::InvalidScalar& e) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Binary()
|
||||
{
|
||||
std::string input = "[!!binary \"SGVsbG8sIFdvcmxkIQ==\", !!binary \"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4K\"]";
|
||||
std::stringstream stream(input);
|
||||
YAML::Parser parser(stream);
|
||||
YAML::Node doc;
|
||||
parser.GetNextDocument(doc);
|
||||
|
||||
if(doc[0].to<YAML::Binary>() != YAML::Binary(reinterpret_cast<const unsigned char*>("Hello, World!"), 13))
|
||||
return false;
|
||||
if(doc[1].to<YAML::Binary>() != YAML::Binary(reinterpret_cast<const unsigned char*>("Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.\n"), 270))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
void RunScalarParserTest(void (*test)(std::string&, std::string&), const std::string& name, int& passed, int& total) {
|
||||
@@ -853,7 +985,7 @@ namespace Test
|
||||
} else {
|
||||
std::cout << "Parser test failed: " << name << "\n";
|
||||
if(error != "")
|
||||
std::cout << "Caught exception: " << error << "\n";
|
||||
std::cout << " Caught exception: " << error << "\n";
|
||||
}
|
||||
total++;
|
||||
}
|
||||
@@ -1021,7 +1153,7 @@ namespace Test
|
||||
} else {
|
||||
std::cout << "Parser test failed: " << name << "\n";
|
||||
if(error != "")
|
||||
std::cout << "Caught exception: " << error << "\n";
|
||||
std::cout << " Caught exception: " << error << "\n";
|
||||
}
|
||||
total++;
|
||||
}
|
||||
@@ -1079,6 +1211,13 @@ namespace Test
|
||||
RunParserTest(&Parser::DefaultPlainScalarTag, "default plain scalar tag", passed, total);
|
||||
RunParserTest(&Parser::DefaultSequenceTag, "default sequence tag", passed, total);
|
||||
RunParserTest(&Parser::ExplicitNonSpecificSequenceTag, "explicit, non-specific sequence tag", passed, total);
|
||||
RunParserTest(&Parser::Infinity, "infinity", passed, total);
|
||||
RunParserTest(&Parser::NaN, "NaN", passed, total);
|
||||
RunParserTest(&Parser::NonConstKey, "non const key", passed, total);
|
||||
RunParserTest(&Parser::SingleChar, "single char", passed, total);
|
||||
RunParserTest(&Parser::QuotedNewline, "quoted newline", passed, total);
|
||||
RunParserTest(&Parser::DoubleAsInt, "double as int", passed, total);
|
||||
RunParserTest(&Parser::Binary, "binary", passed, total);
|
||||
|
||||
RunEncodingTest(&EncodeToUtf8, false, "UTF-8, no BOM", passed, total);
|
||||
RunEncodingTest(&EncodeToUtf8, true, "UTF-8 with BOM", passed, total);
|
1456
test/old-api/spectests.cpp
Normal file
1456
test/old-api/spectests.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
#ifndef PARSERTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define PARSERTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
850
test/specexamples.h
Normal file
850
test/specexamples.h
Normal file
@@ -0,0 +1,850 @@
|
||||
namespace Test {
|
||||
namespace Spec {
|
||||
const char *ex2_1 =
|
||||
"- Mark McGwire\n"
|
||||
"- Sammy Sosa\n"
|
||||
"- Ken Griffey";
|
||||
|
||||
const char *ex2_2 =
|
||||
"hr: 65 # Home runs\n"
|
||||
"avg: 0.278 # Batting average\n"
|
||||
"rbi: 147 # Runs Batted In";
|
||||
|
||||
const char *ex2_3 =
|
||||
"american:\n"
|
||||
"- Boston Red Sox\n"
|
||||
"- Detroit Tigers\n"
|
||||
"- New York Yankees\n"
|
||||
"national:\n"
|
||||
"- New York Mets\n"
|
||||
"- Chicago Cubs\n"
|
||||
"- Atlanta Braves";
|
||||
|
||||
const char *ex2_4 =
|
||||
"-\n"
|
||||
" name: Mark McGwire\n"
|
||||
" hr: 65\n"
|
||||
" avg: 0.278\n"
|
||||
"-\n"
|
||||
" name: Sammy Sosa\n"
|
||||
" hr: 63\n"
|
||||
" avg: 0.288";
|
||||
|
||||
const char *ex2_5 =
|
||||
"- [name , hr, avg ]\n"
|
||||
"- [Mark McGwire, 65, 0.278]\n"
|
||||
"- [Sammy Sosa , 63, 0.288]";
|
||||
|
||||
const char *ex2_6 =
|
||||
"Mark McGwire: {hr: 65, avg: 0.278}\n"
|
||||
"Sammy Sosa: {\n"
|
||||
" hr: 63,\n"
|
||||
" avg: 0.288\n"
|
||||
" }";
|
||||
|
||||
const char *ex2_7 =
|
||||
"# Ranking of 1998 home runs\n"
|
||||
"---\n"
|
||||
"- Mark McGwire\n"
|
||||
"- Sammy Sosa\n"
|
||||
"- Ken Griffey\n"
|
||||
"\n"
|
||||
"# Team ranking\n"
|
||||
"---\n"
|
||||
"- Chicago Cubs\n"
|
||||
"- St Louis Cardinals";
|
||||
|
||||
const char *ex2_8 =
|
||||
"---\n"
|
||||
"time: 20:03:20\n"
|
||||
"player: Sammy Sosa\n"
|
||||
"action: strike (miss)\n"
|
||||
"...\n"
|
||||
"---\n"
|
||||
"time: 20:03:47\n"
|
||||
"player: Sammy Sosa\n"
|
||||
"action: grand slam\n"
|
||||
"...";
|
||||
|
||||
const char *ex2_9 =
|
||||
"---\n"
|
||||
"hr: # 1998 hr ranking\n"
|
||||
" - Mark McGwire\n"
|
||||
" - Sammy Sosa\n"
|
||||
"rbi:\n"
|
||||
" # 1998 rbi ranking\n"
|
||||
" - Sammy Sosa\n"
|
||||
" - Ken Griffey";
|
||||
|
||||
const char *ex2_10 =
|
||||
"---\n"
|
||||
"hr:\n"
|
||||
" - Mark McGwire\n"
|
||||
" # Following node labeled SS\n"
|
||||
" - &SS Sammy Sosa\n"
|
||||
"rbi:\n"
|
||||
" - *SS # Subsequent occurrence\n"
|
||||
" - Ken Griffey";
|
||||
|
||||
const char *ex2_11 =
|
||||
"? - Detroit Tigers\n"
|
||||
" - Chicago cubs\n"
|
||||
":\n"
|
||||
" - 2001-07-23\n"
|
||||
"\n"
|
||||
"? [ New York Yankees,\n"
|
||||
" Atlanta Braves ]\n"
|
||||
": [ 2001-07-02, 2001-08-12,\n"
|
||||
" 2001-08-14 ]";
|
||||
|
||||
const char *ex2_12 =
|
||||
"---\n"
|
||||
"# Products purchased\n"
|
||||
"- item : Super Hoop\n"
|
||||
" quantity: 1\n"
|
||||
"- item : Basketball\n"
|
||||
" quantity: 4\n"
|
||||
"- item : Big Shoes\n"
|
||||
" quantity: 1";
|
||||
|
||||
const char *ex2_13 =
|
||||
"# ASCII Art\n"
|
||||
"--- |\n"
|
||||
" \\//||\\/||\n"
|
||||
" // || ||__";
|
||||
|
||||
const char *ex2_14 =
|
||||
"--- >\n"
|
||||
" Mark McGwire's\n"
|
||||
" year was crippled\n"
|
||||
" by a knee injury.";
|
||||
|
||||
const char *ex2_15 =
|
||||
">\n"
|
||||
" Sammy Sosa completed another\n"
|
||||
" fine season with great stats.\n"
|
||||
" \n"
|
||||
" 63 Home Runs\n"
|
||||
" 0.288 Batting Average\n"
|
||||
" \n"
|
||||
" What a year!";
|
||||
|
||||
const char *ex2_16 =
|
||||
"name: Mark McGwire\n"
|
||||
"accomplishment: >\n"
|
||||
" Mark set a major league\n"
|
||||
" home run record in 1998.\n"
|
||||
"stats: |\n"
|
||||
" 65 Home Runs\n"
|
||||
" 0.278 Batting Average\n";
|
||||
|
||||
const char *ex2_17 =
|
||||
"unicode: \"Sosa did fine.\\u263A\"\n"
|
||||
"control: \"\\b1998\\t1999\\t2000\\n\"\n"
|
||||
"hex esc: \"\\x0d\\x0a is \\r\\n\"\n"
|
||||
"\n"
|
||||
"single: '\"Howdy!\" he cried.'\n"
|
||||
"quoted: ' # Not a ''comment''.'\n"
|
||||
"tie-fighter: '|\\-*-/|'";
|
||||
|
||||
const char *ex2_18 =
|
||||
"plain:\n"
|
||||
" This unquoted scalar\n"
|
||||
" spans many lines.\n"
|
||||
"\n"
|
||||
"quoted: \"So does this\n"
|
||||
" quoted scalar.\\n\"";
|
||||
|
||||
// TODO: 2.19 - 2.22 schema tags
|
||||
|
||||
const char *ex2_23 =
|
||||
"---\n"
|
||||
"not-date: !!str 2002-04-28\n"
|
||||
"\n"
|
||||
"picture: !!binary |\n"
|
||||
" R0lGODlhDAAMAIQAAP//9/X\n"
|
||||
" 17unp5WZmZgAAAOfn515eXv\n"
|
||||
" Pz7Y6OjuDg4J+fn5OTk6enp\n"
|
||||
" 56enmleECcgggoBADs=\n"
|
||||
"\n"
|
||||
"application specific tag: !something |\n"
|
||||
" The semantics of the tag\n"
|
||||
" above may be different for\n"
|
||||
" different documents.";
|
||||
|
||||
const char *ex2_24 =
|
||||
"%TAG ! tag:clarkevans.com,2002:\n"
|
||||
"--- !shape\n"
|
||||
" # Use the ! handle for presenting\n"
|
||||
" # tag:clarkevans.com,2002:circle\n"
|
||||
"- !circle\n"
|
||||
" center: &ORIGIN {x: 73, y: 129}\n"
|
||||
" radius: 7\n"
|
||||
"- !line\n"
|
||||
" start: *ORIGIN\n"
|
||||
" finish: { x: 89, y: 102 }\n"
|
||||
"- !label\n"
|
||||
" start: *ORIGIN\n"
|
||||
" color: 0xFFEEBB\n"
|
||||
" text: Pretty vector drawing.";
|
||||
|
||||
const char *ex2_25 =
|
||||
"# Sets are represented as a\n"
|
||||
"# Mapping where each key is\n"
|
||||
"# associated with a null value\n"
|
||||
"--- !!set\n"
|
||||
"? Mark McGwire\n"
|
||||
"? Sammy Sosa\n"
|
||||
"? Ken Griffey";
|
||||
|
||||
const char *ex2_26 =
|
||||
"# Ordered maps are represented as\n"
|
||||
"# A sequence of mappings, with\n"
|
||||
"# each mapping having one key\n"
|
||||
"--- !!omap\n"
|
||||
"- Mark McGwire: 65\n"
|
||||
"- Sammy Sosa: 63\n"
|
||||
"- Ken Griffey: 58";
|
||||
|
||||
const char *ex2_27 =
|
||||
"--- !<tag:clarkevans.com,2002:invoice>\n"
|
||||
"invoice: 34843\n"
|
||||
"date : 2001-01-23\n"
|
||||
"bill-to: &id001\n"
|
||||
" given : Chris\n"
|
||||
" family : Dumars\n"
|
||||
" address:\n"
|
||||
" lines: |\n"
|
||||
" 458 Walkman Dr.\n"
|
||||
" Suite #292\n"
|
||||
" city : Royal Oak\n"
|
||||
" state : MI\n"
|
||||
" postal : 48046\n"
|
||||
"ship-to: *id001\n"
|
||||
"product:\n"
|
||||
" - sku : BL394D\n"
|
||||
" quantity : 4\n"
|
||||
" description : Basketball\n"
|
||||
" price : 450.00\n"
|
||||
" - sku : BL4438H\n"
|
||||
" quantity : 1\n"
|
||||
" description : Super Hoop\n"
|
||||
" price : 2392.00\n"
|
||||
"tax : 251.42\n"
|
||||
"total: 4443.52\n"
|
||||
"comments:\n"
|
||||
" Late afternoon is best.\n"
|
||||
" Backup contact is Nancy\n"
|
||||
" Billsmer @ 338-4338.";
|
||||
|
||||
const char *ex2_28 =
|
||||
"---\n"
|
||||
"Time: 2001-11-23 15:01:42 -5\n"
|
||||
"User: ed\n"
|
||||
"Warning:\n"
|
||||
" This is an error message\n"
|
||||
" for the log file\n"
|
||||
"---\n"
|
||||
"Time: 2001-11-23 15:02:31 -5\n"
|
||||
"User: ed\n"
|
||||
"Warning:\n"
|
||||
" A slightly different error\n"
|
||||
" message.\n"
|
||||
"---\n"
|
||||
"Date: 2001-11-23 15:03:17 -5\n"
|
||||
"User: ed\n"
|
||||
"Fatal:\n"
|
||||
" Unknown variable \"bar\"\n"
|
||||
"Stack:\n"
|
||||
" - file: TopClass.py\n"
|
||||
" line: 23\n"
|
||||
" code: |\n"
|
||||
" x = MoreObject(\"345\\n\")\n"
|
||||
" - file: MoreClass.py\n"
|
||||
" line: 58\n"
|
||||
" code: |-\n"
|
||||
" foo = bar";
|
||||
|
||||
// TODO: 5.1 - 5.2 BOM
|
||||
|
||||
const char *ex5_3 =
|
||||
"sequence:\n"
|
||||
"- one\n"
|
||||
"- two\n"
|
||||
"mapping:\n"
|
||||
" ? sky\n"
|
||||
" : blue\n"
|
||||
" sea : green";
|
||||
|
||||
const char *ex5_4 =
|
||||
"sequence: [ one, two, ]\n"
|
||||
"mapping: { sky: blue, sea: green }";
|
||||
|
||||
const char *ex5_5 =
|
||||
"# Comment only.";
|
||||
|
||||
const char *ex5_6 =
|
||||
"anchored: !local &anchor value\n"
|
||||
"alias: *anchor";
|
||||
|
||||
const char *ex5_7 =
|
||||
"literal: |\n"
|
||||
" some\n"
|
||||
" text\n"
|
||||
"folded: >\n"
|
||||
" some\n"
|
||||
" text\n";
|
||||
|
||||
const char *ex5_8 =
|
||||
"single: 'text'\n"
|
||||
"double: \"text\"";
|
||||
|
||||
// TODO: 5.9 directive
|
||||
// TODO: 5.10 reserved indicator
|
||||
|
||||
const char *ex5_11 =
|
||||
"|\n"
|
||||
" Line break (no glyph)\n"
|
||||
" Line break (glyphed)\n";
|
||||
|
||||
const char *ex5_12 =
|
||||
"# Tabs and spaces\n"
|
||||
"quoted: \"Quoted\t\"\n"
|
||||
"block: |\n"
|
||||
" void main() {\n"
|
||||
" \tprintf(\"Hello, world!\\n\");\n"
|
||||
" }";
|
||||
|
||||
const char *ex5_13 =
|
||||
"\"Fun with \\\\\n"
|
||||
"\\\" \\a \\b \\e \\f \\\n"
|
||||
"\\n \\r \\t \\v \\0 \\\n"
|
||||
"\\ \\_ \\N \\L \\P \\\n"
|
||||
"\\x41 \\u0041 \\U00000041\"";
|
||||
|
||||
const char *ex5_14 =
|
||||
"Bad escapes:\n"
|
||||
" \"\\c\n"
|
||||
" \\xq-\"";
|
||||
|
||||
const char *ex6_1 =
|
||||
" # Leading comment line spaces are\n"
|
||||
" # neither content nor indentation.\n"
|
||||
" \n"
|
||||
"Not indented:\n"
|
||||
" By one space: |\n"
|
||||
" By four\n"
|
||||
" spaces\n"
|
||||
" Flow style: [ # Leading spaces\n"
|
||||
" By two, # in flow style\n"
|
||||
" Also by two, # are neither\n"
|
||||
" \tStill by two # content nor\n"
|
||||
" ] # indentation.";
|
||||
|
||||
const char *ex6_2 =
|
||||
"? a\n"
|
||||
": -\tb\n"
|
||||
" - -\tc\n"
|
||||
" - d";
|
||||
|
||||
const char *ex6_3 =
|
||||
"- foo:\t bar\n"
|
||||
"- - baz\n"
|
||||
" -\tbaz";
|
||||
|
||||
const char *ex6_4 =
|
||||
"plain: text\n"
|
||||
" lines\n"
|
||||
"quoted: \"text\n"
|
||||
" \tlines\"\n"
|
||||
"block: |\n"
|
||||
" text\n"
|
||||
" \tlines\n";
|
||||
|
||||
const char *ex6_5 =
|
||||
"Folding:\n"
|
||||
" \"Empty line\n"
|
||||
" \t\n"
|
||||
" as a line feed\"\n"
|
||||
"Chomping: |\n"
|
||||
" Clipped empty lines\n"
|
||||
" ";
|
||||
|
||||
const char *ex6_6 =
|
||||
">-\n"
|
||||
" trimmed\n"
|
||||
" \n"
|
||||
" \n"
|
||||
"\n"
|
||||
" as\n"
|
||||
" space";
|
||||
|
||||
const char *ex6_7 =
|
||||
">\n"
|
||||
" foo \n"
|
||||
" \n"
|
||||
" \t bar\n"
|
||||
"\n"
|
||||
" baz\n";
|
||||
|
||||
const char *ex6_8 =
|
||||
"\"\n"
|
||||
" foo \n"
|
||||
" \n"
|
||||
" \t bar\n"
|
||||
"\n"
|
||||
" baz\n"
|
||||
"\"";
|
||||
|
||||
const char *ex6_9 =
|
||||
"key: # Comment\n"
|
||||
" value";
|
||||
|
||||
const char *ex6_10 =
|
||||
" # Comment\n"
|
||||
" \n"
|
||||
"\n";
|
||||
|
||||
const char *ex6_11 =
|
||||
"key: # Comment\n"
|
||||
" # lines\n"
|
||||
" value\n"
|
||||
"\n";
|
||||
|
||||
const char *ex6_12 =
|
||||
"{ first: Sammy, last: Sosa }:\n"
|
||||
"# Statistics:\n"
|
||||
" hr: # Home runs\n"
|
||||
" 65\n"
|
||||
" avg: # Average\n"
|
||||
" 0.278";
|
||||
|
||||
const char *ex6_13 =
|
||||
"%FOO bar baz # Should be ignored\n"
|
||||
" # with a warning.\n"
|
||||
"--- \"foo\"";
|
||||
|
||||
const char *ex6_14 =
|
||||
"%YAML 1.3 # Attempt parsing\n"
|
||||
" # with a warning\n"
|
||||
"---\n"
|
||||
"\"foo\"";
|
||||
|
||||
const char *ex6_15 =
|
||||
"%YAML 1.2\n"
|
||||
"%YAML 1.1\n"
|
||||
"foo";
|
||||
|
||||
const char *ex6_16 =
|
||||
"%TAG !yaml! tag:yaml.org,2002:\n"
|
||||
"---\n"
|
||||
"!yaml!str \"foo\"";
|
||||
|
||||
const char *ex6_17 =
|
||||
"%TAG ! !foo\n"
|
||||
"%TAG ! !foo\n"
|
||||
"bar";
|
||||
|
||||
const char *ex6_18 =
|
||||
"# Private\n"
|
||||
"!foo \"bar\"\n"
|
||||
"...\n"
|
||||
"# Global\n"
|
||||
"%TAG ! tag:example.com,2000:app/\n"
|
||||
"---\n"
|
||||
"!foo \"bar\"";
|
||||
|
||||
const char *ex6_19 =
|
||||
"%TAG !! tag:example.com,2000:app/\n"
|
||||
"---\n"
|
||||
"!!int 1 - 3 # Interval, not integer";
|
||||
|
||||
const char *ex6_20 =
|
||||
"%TAG !e! tag:example.com,2000:app/\n"
|
||||
"---\n"
|
||||
"!e!foo \"bar\"";
|
||||
|
||||
const char *ex6_21 =
|
||||
"%TAG !m! !my-\n"
|
||||
"--- # Bulb here\n"
|
||||
"!m!light fluorescent\n"
|
||||
"...\n"
|
||||
"%TAG !m! !my-\n"
|
||||
"--- # Color here\n"
|
||||
"!m!light green";
|
||||
|
||||
const char *ex6_22 =
|
||||
"%TAG !e! tag:example.com,2000:app/\n"
|
||||
"---\n"
|
||||
"- !e!foo \"bar\"";
|
||||
|
||||
const char *ex6_23 =
|
||||
"!!str &a1 \"foo\":\n"
|
||||
" !!str bar\n"
|
||||
"&a2 baz : *a1";
|
||||
|
||||
const char *ex6_24 =
|
||||
"!<tag:yaml.org,2002:str> foo :\n"
|
||||
" !<!bar> baz";
|
||||
|
||||
const char *ex6_25 =
|
||||
"- !<!> foo\n"
|
||||
"- !<$:?> bar\n";
|
||||
|
||||
const char *ex6_26 =
|
||||
"%TAG !e! tag:example.com,2000:app/\n"
|
||||
"---\n"
|
||||
"- !local foo\n"
|
||||
"- !!str bar\n"
|
||||
"- !e!tag%21 baz\n";
|
||||
|
||||
const char *ex6_27a =
|
||||
"%TAG !e! tag:example,2000:app/\n"
|
||||
"---\n"
|
||||
"- !e! foo";
|
||||
|
||||
const char *ex6_27b =
|
||||
"%TAG !e! tag:example,2000:app/\n"
|
||||
"---\n"
|
||||
"- !h!bar baz";
|
||||
|
||||
const char *ex6_28 =
|
||||
"# Assuming conventional resolution:\n"
|
||||
"- \"12\"\n"
|
||||
"- 12\n"
|
||||
"- ! 12";
|
||||
|
||||
const char *ex6_29 =
|
||||
"First occurrence: &anchor Value\n"
|
||||
"Second occurrence: *anchor";
|
||||
|
||||
const char *ex7_1 =
|
||||
"First occurrence: &anchor Foo\n"
|
||||
"Second occurrence: *anchor\n"
|
||||
"Override anchor: &anchor Bar\n"
|
||||
"Reuse anchor: *anchor";
|
||||
|
||||
const char *ex7_2 =
|
||||
"{\n"
|
||||
" foo : !!str,\n"
|
||||
" !!str : bar,\n"
|
||||
"}";
|
||||
|
||||
const char *ex7_3 =
|
||||
"{\n"
|
||||
" ? foo :,\n"
|
||||
" : bar,\n"
|
||||
"}\n";
|
||||
|
||||
const char *ex7_4 =
|
||||
"\"implicit block key\" : [\n"
|
||||
" \"implicit flow key\" : value,\n"
|
||||
" ]";
|
||||
|
||||
const char *ex7_5 =
|
||||
"\"folded \n"
|
||||
"to a space,\t\n"
|
||||
" \n"
|
||||
"to a line feed, or \t\\\n"
|
||||
" \\ \tnon-content\"";
|
||||
|
||||
const char *ex7_6 =
|
||||
"\" 1st non-empty\n"
|
||||
"\n"
|
||||
" 2nd non-empty \n"
|
||||
"\t3rd non-empty \"";
|
||||
|
||||
const char *ex7_7 =
|
||||
" 'here''s to \"quotes\"'";
|
||||
|
||||
const char *ex7_8 =
|
||||
"'implicit block key' : [\n"
|
||||
" 'implicit flow key' : value,\n"
|
||||
" ]";
|
||||
|
||||
const char *ex7_9 =
|
||||
"' 1st non-empty\n"
|
||||
"\n"
|
||||
" 2nd non-empty \n"
|
||||
"\t3rd non-empty '";
|
||||
|
||||
const char *ex7_10 =
|
||||
"# Outside flow collection:\n"
|
||||
"- ::vector\n"
|
||||
"- \": - ()\"\n"
|
||||
"- Up, up, and away!\n"
|
||||
"- -123\n"
|
||||
"- http://example.com/foo#bar\n"
|
||||
"# Inside flow collection:\n"
|
||||
"- [ ::vector,\n"
|
||||
" \": - ()\",\n"
|
||||
" \"Up, up, and away!\",\n"
|
||||
" -123,\n"
|
||||
" http://example.com/foo#bar ]";
|
||||
|
||||
const char *ex7_11 =
|
||||
"implicit block key : [\n"
|
||||
" implicit flow key : value,\n"
|
||||
" ]";
|
||||
|
||||
const char *ex7_12 =
|
||||
"1st non-empty\n"
|
||||
"\n"
|
||||
" 2nd non-empty \n"
|
||||
"\t3rd non-empty";
|
||||
|
||||
const char *ex7_13 =
|
||||
"- [ one, two, ]\n"
|
||||
"- [three ,four]";
|
||||
|
||||
const char *ex7_14 =
|
||||
"[\n"
|
||||
"\"double\n"
|
||||
" quoted\", 'single\n"
|
||||
" quoted',\n"
|
||||
"plain\n"
|
||||
" text, [ nested ],\n"
|
||||
"single: pair,\n"
|
||||
"]";
|
||||
|
||||
const char *ex7_15 =
|
||||
"- { one : two , three: four , }\n"
|
||||
"- {five: six,seven : eight}";
|
||||
|
||||
const char *ex7_16 =
|
||||
"{\n"
|
||||
"? explicit: entry,\n"
|
||||
"implicit: entry,\n"
|
||||
"?\n"
|
||||
"}";
|
||||
|
||||
const char *ex7_17 =
|
||||
"{\n"
|
||||
"unquoted : \"separate\",\n"
|
||||
"http://foo.com,\n"
|
||||
"omitted value:,\n"
|
||||
": omitted key,\n"
|
||||
"}";
|
||||
|
||||
const char *ex7_18 =
|
||||
"{\n"
|
||||
"\"adjacent\":value,\n"
|
||||
"\"readable\":value,\n"
|
||||
"\"empty\":\n"
|
||||
"}";
|
||||
|
||||
const char *ex7_19 =
|
||||
"[\n"
|
||||
"foo: bar\n"
|
||||
"]";
|
||||
|
||||
const char *ex7_20 =
|
||||
"[\n"
|
||||
"? foo\n"
|
||||
" bar : baz\n"
|
||||
"]";
|
||||
|
||||
const char *ex7_21 =
|
||||
"- [ YAML : separate ]\n"
|
||||
"- [ : empty key entry ]\n"
|
||||
"- [ {JSON: like}:adjacent ]";
|
||||
|
||||
const char *ex7_22 =
|
||||
"[ foo\n"
|
||||
" bar: invalid,"; // Note: we don't check (on purpose) the >1K chars for an implicit key
|
||||
|
||||
const char *ex7_23 =
|
||||
"- [ a, b ]\n"
|
||||
"- { a: b }\n"
|
||||
"- \"a\"\n"
|
||||
"- 'b'\n"
|
||||
"- c";
|
||||
|
||||
const char *ex7_24 =
|
||||
"- !!str \"a\"\n"
|
||||
"- 'b'\n"
|
||||
"- &anchor \"c\"\n"
|
||||
"- *anchor\n"
|
||||
"- !!str";
|
||||
|
||||
const char *ex8_1 =
|
||||
"- | # Empty header\n"
|
||||
" literal\n"
|
||||
"- >1 # Indentation indicator\n"
|
||||
" folded\n"
|
||||
"- |+ # Chomping indicator\n"
|
||||
" keep\n"
|
||||
"\n"
|
||||
"- >1- # Both indicators\n"
|
||||
" strip\n";
|
||||
|
||||
const char *ex8_2 =
|
||||
"- |\n"
|
||||
" detected\n"
|
||||
"- >\n"
|
||||
" \n"
|
||||
" \n"
|
||||
" # detected\n"
|
||||
"- |1\n"
|
||||
" explicit\n"
|
||||
"- >\n"
|
||||
" \t\n"
|
||||
" detected\n";
|
||||
|
||||
const char *ex8_3a =
|
||||
"- |\n"
|
||||
" \n"
|
||||
" text";
|
||||
|
||||
const char *ex8_3b =
|
||||
"- >\n"
|
||||
" text\n"
|
||||
" text";
|
||||
|
||||
const char *ex8_3c =
|
||||
"- |2\n"
|
||||
" text";
|
||||
|
||||
const char *ex8_4 =
|
||||
"strip: |-\n"
|
||||
" text\n"
|
||||
"clip: |\n"
|
||||
" text\n"
|
||||
"keep: |+\n"
|
||||
" text\n";
|
||||
|
||||
const char *ex8_5 =
|
||||
" # Strip\n"
|
||||
" # Comments:\n"
|
||||
"strip: |-\n"
|
||||
" # text\n"
|
||||
" \n"
|
||||
" # Clip\n"
|
||||
" # comments:\n"
|
||||
"\n"
|
||||
"clip: |\n"
|
||||
" # text\n"
|
||||
" \n"
|
||||
" # Keep\n"
|
||||
" # comments:\n"
|
||||
"\n"
|
||||
"keep: |+\n"
|
||||
" # text\n"
|
||||
"\n"
|
||||
" # Trail\n"
|
||||
" # Comments\n";
|
||||
|
||||
const char *ex8_6 =
|
||||
"strip: >-\n"
|
||||
"\n"
|
||||
"clip: >\n"
|
||||
"\n"
|
||||
"keep: |+\n"
|
||||
"\n";
|
||||
|
||||
const char *ex8_7 =
|
||||
"|\n"
|
||||
" literal\n"
|
||||
" \ttext\n"
|
||||
"\n";
|
||||
|
||||
const char *ex8_8 =
|
||||
"|\n"
|
||||
" \n"
|
||||
" \n"
|
||||
" literal\n"
|
||||
" \n"
|
||||
" \n"
|
||||
" text\n"
|
||||
"\n"
|
||||
" # Comment\n";
|
||||
|
||||
const char *ex8_9 =
|
||||
">\n"
|
||||
" folded\n"
|
||||
" text\n"
|
||||
"\n";
|
||||
|
||||
const char *ex8_10 =
|
||||
">\n"
|
||||
"\n"
|
||||
" folded\n"
|
||||
" line\n"
|
||||
"\n"
|
||||
" next\n"
|
||||
" line\n"
|
||||
" * bullet\n"
|
||||
"\n"
|
||||
" * list\n"
|
||||
" * lines\n"
|
||||
"\n"
|
||||
" last\n"
|
||||
" line\n"
|
||||
"\n"
|
||||
"# Comment\n";
|
||||
|
||||
const char *ex8_11 = ex8_10;
|
||||
const char *ex8_12 = ex8_10;
|
||||
const char *ex8_13 = ex8_10;
|
||||
|
||||
const char *ex8_14 =
|
||||
"block sequence:\n"
|
||||
" - one\n"
|
||||
" - two : three\n";
|
||||
|
||||
const char *ex8_15 =
|
||||
"- # Empty\n"
|
||||
"- |\n"
|
||||
" block node\n"
|
||||
"- - one # Compact\n"
|
||||
" - two # sequence\n"
|
||||
"- one: two # Compact mapping\n";
|
||||
|
||||
const char *ex8_16 =
|
||||
"block mapping:\n"
|
||||
" key: value\n";
|
||||
|
||||
const char *ex8_17 =
|
||||
"? explicit key # Empty value\n"
|
||||
"? |\n"
|
||||
" block key\n"
|
||||
": - one # Explicit compact\n"
|
||||
" - two # block value\n";
|
||||
|
||||
const char *ex8_18 =
|
||||
"plain key: in-line value\n"
|
||||
": # Both empty\n"
|
||||
"\"quoted key\":\n"
|
||||
"- entry\n";
|
||||
|
||||
const char *ex8_19 =
|
||||
"- sun: yellow\n"
|
||||
"- ? earth: blue\n"
|
||||
" : moon: white\n";
|
||||
|
||||
const char *ex8_20 =
|
||||
"-\n"
|
||||
" \"flow in block\"\n"
|
||||
"- >\n"
|
||||
" Block scalar\n"
|
||||
"- !!map # Block collection\n"
|
||||
" foo : bar\n";
|
||||
|
||||
const char *ex8_21 =
|
||||
"literal: |2\n"
|
||||
" value\n"
|
||||
"folded:\n"
|
||||
" !foo\n"
|
||||
" >1\n"
|
||||
" value\n";
|
||||
|
||||
const char *ex8_22 =
|
||||
"sequence: !!seq\n"
|
||||
"- entry\n"
|
||||
"- !!seq\n"
|
||||
" - nested\n"
|
||||
"mapping: !!map\n"
|
||||
" foo: bar\n";
|
||||
}
|
||||
}
|
||||
|
2302
test/spectests.cpp
2302
test/spectests.cpp
File diff suppressed because it is too large
Load Diff
349
test/spectests.h
349
test/spectests.h
@@ -1,11 +1,358 @@
|
||||
#ifndef SPECTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define SPECTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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 Test {
|
||||
struct TEST {
|
||||
TEST(): ok(false) {}
|
||||
TEST(bool ok_): ok(ok_) {}
|
||||
TEST(const char *error_): ok(false), error(error_) {}
|
||||
|
||||
bool ok;
|
||||
std::string error;
|
||||
};
|
||||
|
||||
namespace Spec {
|
||||
// 2.1
|
||||
TEST SeqScalars();
|
||||
|
||||
// 2.2
|
||||
TEST MappingScalarsToScalars();
|
||||
|
||||
// 2.3
|
||||
TEST MappingScalarsToSequences();
|
||||
|
||||
// 2.4
|
||||
TEST SequenceOfMappings();
|
||||
|
||||
// 2.5
|
||||
TEST SequenceOfSequences();
|
||||
|
||||
// 2.6
|
||||
TEST MappingOfMappings();
|
||||
|
||||
// 2.7
|
||||
TEST TwoDocumentsInAStream();
|
||||
|
||||
// 2.8
|
||||
TEST PlayByPlayFeed();
|
||||
|
||||
// 2.9
|
||||
TEST SingleDocumentWithTwoComments();
|
||||
|
||||
// 2.10
|
||||
TEST SimpleAnchor();
|
||||
|
||||
// 2.11
|
||||
TEST MappingBetweenSequences();
|
||||
|
||||
// 2.12
|
||||
TEST CompactNestedMapping();
|
||||
|
||||
// 2.13
|
||||
TEST InLiteralsNewlinesArePreserved();
|
||||
|
||||
// 2.14
|
||||
TEST InFoldedScalarsNewlinesBecomeSpaces();
|
||||
|
||||
// 2.15
|
||||
TEST FoldedNewlinesArePreservedForMoreIndentedAndBlankLines();
|
||||
|
||||
// 2.16
|
||||
TEST IndentationDeterminesScope();
|
||||
|
||||
// 2.17
|
||||
TEST QuotedScalars();
|
||||
|
||||
// 2.18
|
||||
TEST MultiLineFlowScalars();
|
||||
|
||||
// TODO: 2.19 - 2.22 schema tags
|
||||
|
||||
// 2.23
|
||||
TEST VariousExplicitTags();
|
||||
|
||||
// 2.24
|
||||
TEST GlobalTags();
|
||||
|
||||
// 2.25
|
||||
TEST UnorderedSets();
|
||||
|
||||
// 2.26
|
||||
TEST OrderedMappings();
|
||||
|
||||
// 2.27
|
||||
TEST Invoice();
|
||||
|
||||
// 2.28
|
||||
TEST LogFile();
|
||||
|
||||
// TODO: 5.1 - 5.2 BOM
|
||||
|
||||
// 5.3
|
||||
TEST BlockStructureIndicators();
|
||||
|
||||
// 5.4
|
||||
TEST FlowStructureIndicators();
|
||||
|
||||
// 5.5
|
||||
TEST CommentIndicator();
|
||||
|
||||
// 5.6
|
||||
TEST NodePropertyIndicators();
|
||||
|
||||
// 5.7
|
||||
TEST BlockScalarIndicators();
|
||||
|
||||
// 5.8
|
||||
TEST QuotedScalarIndicators();
|
||||
|
||||
// TODO: 5.9 directive
|
||||
// TODO: 5.10 reserved indicator
|
||||
|
||||
// 5.11
|
||||
TEST LineBreakCharacters();
|
||||
|
||||
// 5.12
|
||||
TEST TabsAndSpaces();
|
||||
|
||||
// 5.13
|
||||
TEST EscapedCharacters();
|
||||
|
||||
// 5.14
|
||||
TEST InvalidEscapedCharacters();
|
||||
|
||||
// 6.1
|
||||
TEST IndentationSpaces();
|
||||
|
||||
// 6.2
|
||||
TEST IndentationIndicators();
|
||||
|
||||
// 6.3
|
||||
TEST SeparationSpaces();
|
||||
|
||||
// 6.4
|
||||
TEST LinePrefixes();
|
||||
|
||||
// 6.5
|
||||
TEST EmptyLines();
|
||||
|
||||
// 6.6
|
||||
TEST LineFolding();
|
||||
|
||||
// 6.7
|
||||
TEST BlockFolding();
|
||||
|
||||
// 6.8
|
||||
TEST FlowFolding();
|
||||
|
||||
// 6.9
|
||||
TEST SeparatedComment();
|
||||
|
||||
// 6.10
|
||||
TEST CommentLines();
|
||||
|
||||
// 6.11
|
||||
TEST MultiLineComments();
|
||||
|
||||
// 6.12
|
||||
TEST SeparationSpacesII();
|
||||
|
||||
// 6.13
|
||||
TEST ReservedDirectives();
|
||||
|
||||
// 6.14
|
||||
TEST YAMLDirective();
|
||||
|
||||
// 6.15
|
||||
TEST InvalidRepeatedYAMLDirective();
|
||||
|
||||
// 6.16
|
||||
TEST TagDirective();
|
||||
|
||||
// 6.17
|
||||
TEST InvalidRepeatedTagDirective();
|
||||
|
||||
// 6.18
|
||||
TEST PrimaryTagHandle();
|
||||
|
||||
// 6.19
|
||||
TEST SecondaryTagHandle();
|
||||
|
||||
// 6.20
|
||||
TEST TagHandles();
|
||||
|
||||
// 6.21
|
||||
TEST LocalTagPrefix();
|
||||
|
||||
// 6.22
|
||||
TEST GlobalTagPrefix();
|
||||
|
||||
// 6.23
|
||||
TEST NodeProperties();
|
||||
|
||||
// 6.24
|
||||
TEST VerbatimTags();
|
||||
|
||||
// 6.25
|
||||
TEST InvalidVerbatimTags();
|
||||
|
||||
// 6.26
|
||||
TEST TagShorthands();
|
||||
|
||||
// 6.27
|
||||
TEST InvalidTagShorthands();
|
||||
|
||||
// 6.28
|
||||
TEST NonSpecificTags();
|
||||
|
||||
// 6.29
|
||||
TEST NodeAnchors();
|
||||
|
||||
// 7.1
|
||||
TEST AliasNodes();
|
||||
|
||||
// 7.2
|
||||
TEST EmptyNodes();
|
||||
|
||||
// 7.3
|
||||
TEST CompletelyEmptyNodes();
|
||||
|
||||
// 7.4
|
||||
TEST DoubleQuotedImplicitKeys();
|
||||
|
||||
// 7.5
|
||||
TEST DoubleQuotedLineBreaks();
|
||||
|
||||
// 7.6
|
||||
TEST DoubleQuotedLines();
|
||||
|
||||
// 7.7
|
||||
TEST SingleQuotedCharacters();
|
||||
|
||||
// 7.8
|
||||
TEST SingleQuotedImplicitKeys();
|
||||
|
||||
// 7.9
|
||||
TEST SingleQuotedLines();
|
||||
|
||||
// 7.10
|
||||
TEST PlainCharacters();
|
||||
|
||||
// 7.11
|
||||
TEST PlainImplicitKeys();
|
||||
|
||||
// 7.12
|
||||
TEST PlainLines();
|
||||
|
||||
// 7.13
|
||||
TEST FlowSequence();
|
||||
|
||||
// 7.14
|
||||
TEST FlowSequenceEntries();
|
||||
|
||||
// 7.15
|
||||
TEST FlowMappings();
|
||||
|
||||
// 7.16
|
||||
TEST FlowMappingEntries();
|
||||
|
||||
// 7.17
|
||||
TEST FlowMappingSeparateValues();
|
||||
|
||||
// 7.18
|
||||
TEST FlowMappingAdjacentValues();
|
||||
|
||||
// 7.19
|
||||
TEST SinglePairFlowMappings();
|
||||
|
||||
// 7.20
|
||||
TEST SinglePairExplicitEntry();
|
||||
|
||||
// 7.21
|
||||
TEST SinglePairImplicitEntries();
|
||||
|
||||
// 7.22
|
||||
TEST InvalidImplicitKeys();
|
||||
|
||||
// 7.23
|
||||
TEST FlowContent();
|
||||
|
||||
// 7.24
|
||||
TEST FlowNodes();
|
||||
|
||||
// 8.1
|
||||
TEST BlockScalarHeader();
|
||||
|
||||
// 8.2
|
||||
TEST BlockIndentationHeader();
|
||||
|
||||
// 8.3
|
||||
TEST InvalidBlockScalarIndentationIndicators();
|
||||
|
||||
// 8.4
|
||||
TEST ChompingFinalLineBreak();
|
||||
|
||||
// 8.5
|
||||
TEST ChompingTrailingLines();
|
||||
|
||||
// 8.6
|
||||
TEST EmptyScalarChomping();
|
||||
|
||||
// 8.7
|
||||
TEST LiteralScalar();
|
||||
|
||||
// 8.8
|
||||
TEST LiteralContent();
|
||||
|
||||
// 8.9
|
||||
TEST FoldedScalar();
|
||||
|
||||
// 8.10
|
||||
TEST FoldedLines();
|
||||
|
||||
// 8.11
|
||||
TEST MoreIndentedLines();
|
||||
|
||||
// 8.12
|
||||
TEST EmptySeparationLines();
|
||||
|
||||
// 8.13
|
||||
TEST FinalEmptyLines();
|
||||
|
||||
// 8.14
|
||||
TEST BlockSequence();
|
||||
|
||||
// 8.15
|
||||
TEST BlockSequenceEntryTypes();
|
||||
|
||||
// 8.16
|
||||
TEST BlockMappings();
|
||||
|
||||
// 8.17
|
||||
TEST ExplicitBlockMappingEntries();
|
||||
|
||||
// 8.18
|
||||
TEST ImplicitBlockMappingEntries();
|
||||
|
||||
// 8.19
|
||||
TEST CompactBlockMappings();
|
||||
|
||||
// 8.20
|
||||
TEST BlockNodeTypes();
|
||||
|
||||
// 8.21
|
||||
TEST BlockScalarNodes();
|
||||
|
||||
// 8.22
|
||||
TEST BlockCollectionNodes();
|
||||
}
|
||||
|
||||
bool RunSpecTests();
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
#include "tests.h"
|
||||
#include "emittertests.h"
|
||||
#include "nodetests.h"
|
||||
#include "parsertests.h"
|
||||
#include "spectests.h"
|
||||
#include "yaml-cpp/yaml.h"
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef TESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define TESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !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
|
||||
|
||||
|
129
util/api.cpp
Normal file
129
util/api.cpp
Normal file
@@ -0,0 +1,129 @@
|
||||
// a sketch of what the new API might look like
|
||||
|
||||
#include "yaml-cpp/yaml.h"
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
// test.yaml
|
||||
// - foo
|
||||
// - primes: [2, 3, 5, 7, 11]
|
||||
// odds: [1, 3, 5, 7, 9, 11]
|
||||
// - [x, y]
|
||||
|
||||
// move-like semantics
|
||||
YAML::Value root = YAML::Parse("test.yaml");
|
||||
|
||||
std::cout << root[0].as<std::string>(); // "foo"
|
||||
std::cout << str(root[0]); // "foo", shorthand?
|
||||
std::cout << root[1]["primes"][3].as<int>(); // "7"
|
||||
std::cout << root[1]["odds"][6].as<int>(); // throws?
|
||||
|
||||
root[2].push_back(5);
|
||||
root[3] = "Hello, World";
|
||||
root[0].reset();
|
||||
root[0]["key"] = "value";
|
||||
|
||||
std::cout << root;
|
||||
// # not sure about formatting
|
||||
// - {key: value}
|
||||
// - primes: [2, 3, 5, 7, 11]
|
||||
// odds: [1, 3, 5, 7, 9, 11]
|
||||
// - [x, y, 5]
|
||||
// - Hello, World
|
||||
}
|
||||
|
||||
{
|
||||
// for all copy-like commands, think of python's "name/value" semantics
|
||||
YAML::Value root = "Hello"; // Hello
|
||||
root = YAML::Sequence(); // []
|
||||
root[0] = 0; // [0]
|
||||
root[2] = "two"; // [0, ~, two] # forces root[1] to be initialized to null
|
||||
|
||||
YAML::Value other = root; // both point to the same thing
|
||||
other[0] = 5; // now root[0] is 0 also
|
||||
other.push_back(root); // &1 [5, ~, two, *1]
|
||||
other[3][0] = 0; // &1 [0, ~, two, *1] # since it's a true alias
|
||||
other.push_back(Copy(root)); // &1 [0, ~, two, *1, &2 [0, ~, two, *2]]
|
||||
other[4][0] = 5; // &1 [0, ~, two, *1, &2 [5, ~, two, *2]] # they're really different
|
||||
}
|
||||
|
||||
{
|
||||
YAML::Value node; // ~
|
||||
node[0] = 1; // [1] # auto-construct a sequence
|
||||
node["key"] = 5; // {0: 1, key: 5} # auto-turn it into a map
|
||||
node.push_back(10); // error, can't turn a map into a sequence
|
||||
node.erase("key"); // {0: 1} # still a map, even if we remove the key that caused the problem
|
||||
node = "Hello"; // Hello # assignment overwrites everything, so it's now just a plain scalar
|
||||
}
|
||||
|
||||
{
|
||||
YAML::Value map; // ~
|
||||
map[3] = 1; // {3: 1} # auto-constructs a map, *not* a sequence
|
||||
|
||||
YAML::Value seq; // ~
|
||||
seq = YAML::Sequence(); // []
|
||||
seq[3] = 1; // [~, ~, ~, 1]
|
||||
}
|
||||
|
||||
{
|
||||
YAML::Value node; // ~
|
||||
node[0] = node; // &1 [*1] # fun stuff
|
||||
}
|
||||
|
||||
{
|
||||
YAML::Value node;
|
||||
YAML::Value subnode = node["key"]; // 'subnode' is not instantiated ('node' is still null)
|
||||
subnode = "value"; // {key: value} # now it is
|
||||
YAML::Value subnode2 = node["key2"];
|
||||
node["key3"] = subnode2; // subnode2 is still not instantiated, but node["key3"] is "pseudo" aliased to it
|
||||
subnode2 = "monkey"; // {key: value, key2: &1 monkey, key3: *1} # bam! it instantiates both
|
||||
}
|
||||
|
||||
{
|
||||
YAML::Value seq = YAML::Sequence();
|
||||
seq[0] = "zero"; // [zero]
|
||||
seq[1] = seq[0]; // [&1 zero, *1]
|
||||
seq[0] = seq[1]; // [&1 zero, *1] # no-op (they both alias the same thing, so setting them equal is nothing)
|
||||
Is(seq[0], seq[1]); // true
|
||||
seq[1] = "one"; // [&1 one, *1]
|
||||
UnAlias(seq[1]); // [one, one]
|
||||
Is(seq[0], seq[1]); // false
|
||||
}
|
||||
|
||||
{
|
||||
YAML::Value root;
|
||||
root.push_back("zero");
|
||||
root.push_back("one");
|
||||
root.push_back("two");
|
||||
YAML::Value two = root[2];
|
||||
root = "scalar"; // 'two' is still "two", even though 'root' is "scalar" (the sequence effectively no longer exists)
|
||||
|
||||
// Note: in all likelihood, the memory for nodes "zero" and "one" is still allocated. How can it go away? Weak pointers?
|
||||
}
|
||||
|
||||
{
|
||||
YAML::Value root; // ~
|
||||
root[0] = root; // &1 [*1]
|
||||
root[0] = 5; // [5]
|
||||
}
|
||||
|
||||
{
|
||||
YAML::Value root;
|
||||
YAML::Value key;
|
||||
key["key"] = "value";
|
||||
root[key] = key; // &1 {key: value}: *1
|
||||
}
|
||||
|
||||
{
|
||||
YAML::Value root;
|
||||
root[0] = "hi";
|
||||
root[1][0] = "bye";
|
||||
root[1][1] = root; // &1 [hi, [bye, *1]] # root
|
||||
YAML::Value sub = root[1]; // &1 [bye, [hi, *1]] # sub
|
||||
root = "gone"; // [bye, gone] # sub
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@@ -39,7 +39,6 @@ void parse(std::istream& input)
|
||||
try {
|
||||
YAML::Parser parser(input);
|
||||
YAML::Node doc;
|
||||
NullEventHandler handler;
|
||||
while(parser.GetNextDocument(doc)) {
|
||||
YAML::Emitter emitter;
|
||||
emitter << doc;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
exec_prefix=@CMAKE_INSTALL_PREFIX@
|
||||
libdir=${prefix}/@LIB_INSTALL_DIR@
|
||||
includedir=${prefix}/@INCLUDE_INSTALL_DIR@
|
||||
includedir=${prefix}/@INCLUDE_INSTALL_ROOT_DIR@
|
||||
|
||||
Name: Yaml-cpp
|
||||
Description: A YAML parser and emitter for C++
|
||||
|
Reference in New Issue
Block a user