Skip to content
This repository was archived by the owner on Jun 12, 2025. It is now read-only.

Commit 9f3b224

Browse files
committed
Merge branch 'master' into merge-key-support
2 parents f198d02 + 28f93bd commit 9f3b224

47 files changed

Lines changed: 5180 additions & 114 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ jobs:
2020
googletest: [build, system]
2121
generator: ["Default Generator", "MinGW Makefiles"]
2222
exclude:
23+
- os: ubuntu-latest
24+
cxx_standard: 11
25+
googletest: system
2326
- os: macos-latest
2427
build: shared
2528
- os: macos-latest

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ if (YAML_CPP_FORMAT_SOURCE AND YAML_CPP_CLANG_FORMAT_EXE)
199199
COMMAND clang-format --style=file -i $<TARGET_PROPERTY:yaml-cpp,SOURCES>
200200
COMMAND_EXPAND_LISTS
201201
COMMENT "Running clang-format"
202+
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
202203
VERBATIM)
203204
endif()
204205

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ Commit messages should be in the imperative mood, as described in the [Git contr
1717

1818
# Tests
1919

20-
Please verify the tests pass by running the target `test/yaml-cpp-tests`.
20+
Please verify the tests pass by configuring CMake with `-D YAML_CPP_BUILD_TESTS=ON` and running the target `test/yaml-cpp-tests`.
2121

22-
If you are adding functionality, add tests accordingly.
22+
If you are adding functionality, add tests accordingly. Note that the "spec tests" are reserved for examples directly from the YAML spec, so if you have new examples, put them in other test files.
2323

2424
# Pull request process
2525

MODULE.bazel.lock

Lines changed: 114 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,18 @@ FetchContent_Declare(
6161
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
6262
GIT_TAG <tag_name> # Can be a tag (yaml-cpp-x.x.x), a commit hash, or a branch name (master)
6363
)
64-
FetchContent_GetProperties(yaml-cpp)
65-
66-
if(NOT yaml-cpp_POPULATED)
67-
message(STATUS "Fetching yaml-cpp...")
68-
FetchContent_Populate(yaml-cpp)
69-
add_subdirectory(${yaml-cpp_SOURCE_DIR} ${yaml-cpp_BINARY_DIR})
70-
endif()
64+
FetchContent_MakeAvailable(yaml-cpp)
7165
7266
target_link_libraries(YOUR_LIBRARY PUBLIC yaml-cpp::yaml-cpp) # The library or executable that require yaml-cpp library
7367
```
7468

7569
## Recent Releases
7670

77-
[yaml-cpp 0.6.0](https://github.com/jbeder/yaml-cpp/releases/tag/yaml-cpp-0.6.0) released! This release requires C++11, and no longer depends on Boost.
71+
[yaml-cpp 0.8.0](https://github.com/jbeder/yaml-cpp/releases/tag/0.8.0) released!
7872

7973
[yaml-cpp 0.3.0](https://github.com/jbeder/yaml-cpp/releases/tag/release-0.3.0) is still available if you want the old API.
8074

81-
**The old API will continue to be supported, and will still receive bugfixes!** The 0.3.x and 0.4.x versions will be old API releases, and 0.5.x and above will all be new API releases.
75+
**The old API will stop receiving bugfixes in 2026.** The 0.3.x versions provide the old API, and 0.5.x and above all provide the new API.
8276

8377
# API Documentation
8478

WORKSPACE

Lines changed: 0 additions & 10 deletions
This file was deleted.

docs/How-To-Emit-YAML.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ produces
154154
# STL Containers, and Other Overloads #
155155
We overload `operator <<` for `std::vector`, `std::list`, and `std::map`, so you can write stuff like:
156156

157+
{% raw %}
157158
```cpp
158159
std::vector <int> squares = {1, 4, 9, 16};
159160

@@ -165,6 +166,7 @@ out << YAML::Flow << squares;
165166
out << ages;
166167
out << YAML::EndSeq;
167168
```
169+
{% endraw %}
168170
169171
produces
170172

include/yaml-cpp/dll.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@
1515
# ifndef YAML_CPP_API
1616
# ifdef yaml_cpp_EXPORTS
1717
/* We are building this library */
18-
# pragma message( "Defining YAML_CPP_API for DLL export" )
1918
# define YAML_CPP_API __declspec(dllexport)
2019
# else
2120
/* We are using this library */
22-
# pragma message( "Defining YAML_CPP_API for DLL import" )
2321
# define YAML_CPP_API __declspec(dllimport)
2422
# endif
2523
# endif

include/yaml-cpp/emitter.h

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,24 @@
99

1010
#include <cmath>
1111
#include <cstddef>
12+
#include <cstring>
1213
#include <limits>
1314
#include <memory>
1415
#include <sstream>
1516
#include <string>
1617
#include <type_traits>
1718

19+
#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
20+
#include <string_view>
21+
#endif
22+
1823
#include "yaml-cpp/binary.h"
1924
#include "yaml-cpp/dll.h"
2025
#include "yaml-cpp/emitterdef.h"
2126
#include "yaml-cpp/emittermanip.h"
2227
#include "yaml-cpp/null.h"
2328
#include "yaml-cpp/ostream_wrapper.h"
29+
#include "yaml-cpp/fptostring.h"
2430

2531
namespace YAML {
2632
class Binary;
@@ -67,6 +73,7 @@ class YAML_CPP_API Emitter {
6773
Emitter& SetLocalPrecision(const _Precision& precision);
6874

6975
// overloads of write
76+
Emitter& Write(const char* str, std::size_t size);
7077
Emitter& Write(const std::string& str);
7178
Emitter& Write(bool b);
7279
Emitter& Write(char ch);
@@ -141,6 +148,7 @@ inline Emitter& Emitter::WriteIntegralType(T value) {
141148
PrepareNode(EmitterNodeType::Scalar);
142149

143150
std::stringstream stream;
151+
stream.imbue(std::locale("C"));
144152
PrepareIntegralStream(stream);
145153
stream << value;
146154
m_stream << stream.str();
@@ -158,6 +166,7 @@ inline Emitter& Emitter::WriteStreamable(T value) {
158166
PrepareNode(EmitterNodeType::Scalar);
159167

160168
std::stringstream stream;
169+
stream.imbue(std::locale("C"));
161170
SetStreamablePrecision<T>(stream);
162171

163172
bool special = false;
@@ -178,7 +187,7 @@ inline Emitter& Emitter::WriteStreamable(T value) {
178187
}
179188

180189
if (!special) {
181-
stream << value;
190+
stream << FpToString(value, stream.precision());
182191
}
183192
m_stream << stream.str();
184193

@@ -198,8 +207,13 @@ inline void Emitter::SetStreamablePrecision<double>(std::stringstream& stream) {
198207
}
199208

200209
// overloads of insertion
210+
#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
211+
inline Emitter& operator<<(Emitter& emitter, const std::string_view& v) {
212+
return emitter.Write(v.data(), v.size());
213+
}
214+
#endif
201215
inline Emitter& operator<<(Emitter& emitter, const std::string& v) {
202-
return emitter.Write(v);
216+
return emitter.Write(v.data(), v.size());
203217
}
204218
inline Emitter& operator<<(Emitter& emitter, bool v) {
205219
return emitter.Write(v);
@@ -230,7 +244,7 @@ inline Emitter& operator<<(Emitter& emitter, const Binary& b) {
230244
}
231245

232246
inline Emitter& operator<<(Emitter& emitter, const char* v) {
233-
return emitter.Write(std::string(v));
247+
return emitter.Write(v, std::strlen(v));
234248
}
235249

236250
inline Emitter& operator<<(Emitter& emitter, int v) {

include/yaml-cpp/emitterstyle.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
#endif
99

1010
namespace YAML {
11-
struct EmitterStyle {
12-
enum value { Default, Block, Flow };
13-
};
11+
namespace EmitterStyle {
12+
enum value { Default, Block, Flow };
13+
}
14+
1415
}
1516

1617
#endif // EMITTERSTYLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66

0 commit comments

Comments
 (0)