Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
1d8ca1f
Avoid static reference to temporary
frankosterfeld Apr 11, 2024
b95aa14
fix: use C locale by default
SGSSGene Jul 17, 2024
9f7babc
Use c-strings to constant initialize token array
JosiahWI Aug 1, 2024
b11eaf1
Run format target from project root
JosiahWI Aug 1, 2024
1f5e971
Fix compile warning with -Wshadow
RonsonNamek Aug 5, 2024
04dddd6
Revert "Fix compile warning with -Wshadow"
jbeder Aug 5, 2024
06c3d1d
fix compile warning(Pull requests #1305)(Issues #1306)
RonsonNamek Aug 6, 2024
8fbf344
doc, fix: invalid liquid '{{...}}' tags
SGSSGene Jul 18, 2024
7b469b4
emitterutils: Explicitly include <cstdint>
csfore Aug 15, 2024
b38ac5b
Use FetchContent_MakeAvailable
LecrisUT Aug 21, 2024
ee9c4d1
fix: parse files with '\r' symbols as line ending correctly
SGSSGene Aug 22, 2024
84459a7
fix: missing token enum name
SGSSGene Aug 22, 2024
850ec4f
Fix reference types in iterators
orgads Nov 11, 2020
47cd272
Remove build debug messages
orgads Aug 27, 2024
1f2b841
fix(src,include,test): fixed multiple cases where a bad yaml was acce…
FedeDP Sep 12, 2024
da82fd9
chore(test/integration): refactor some test cases to their own test.
FedeDP Sep 13, 2024
bc67157
fix(src): avoid possible infinite loop in LoadAll().
FedeDP Sep 12, 2024
29c59c0
new(test): added a test to avoid future issues with LoadAll().
FedeDP Sep 13, 2024
c2bec4c
chore(test): moved infiniteloop test to load_node_test suite.
FedeDP Oct 14, 2024
3d2888c
missing keys should throw InvalidNode, not BadConversion
Nov 1, 2024
bd070a7
fix: prettier floating point numbers
SGSSGene Jul 6, 2024
d4e00bd
fix: rename fp_to_string to FpToString to match coding style
SGSSGene Jul 16, 2024
f4bca79
fix: fp_to_string uses now 2 spaces
SGSSGene Jul 16, 2024
72865f7
fix: remove trailing return types
SGSSGene Jul 16, 2024
28c0a1b
doc: add a little more information to dragonbox file
SGSSGene Jul 29, 2024
5d9e4b6
patch: split fp_to_string.h into fptostring.h and fptostring.cpp
SGSSGene Jul 29, 2024
d8de965
patch: move dragonbox.h from 'include' folder to 'src' folder
SGSSGene Jul 30, 2024
82f3c04
fix: add YAML_CPP_API for windows-shared library builds
SGSSGene Jul 30, 2024
0b94541
fix: add missing include
SGSSGene Jul 30, 2024
06ffaf3
remove reduntant license information
SGSSGene Oct 21, 2024
ebfbf27
patch: added more defensive programming techniques
SGSSGene Oct 22, 2024
9ce5a25
fix: spell fix
SGSSGene Oct 22, 2024
f878043
Don't install embedded copy of GTest
PhilMiller Feb 7, 2023
1da813f
ensuring local tags are retained after loading a node + test
IMaloney Oct 12, 2024
7def204
Fix bazel build, and commit module lock file.
jbeder Dec 17, 2024
61db897
Exclude ubuntu/C++ 11/googletest system from the test matrix since it…
jbeder Dec 17, 2024
d45c4fb
Update README.md
jbeder Dec 18, 2024
8a9a7b7
Update CONTRIBUTING.md
jbeder Dec 22, 2024
7470c2d
emitter: Support std::string_view
Oct 20, 2024
73ef006
Avoid including <iostream> in library code
jwnimmer-tri Dec 30, 2024
39f7374
Update README.md
diehlpk Jan 24, 2025
28f93bd
docs: Fix link in README
salim-b Mar 13, 2025
c9371de
[cmake] Require minimum CMake version 3.5
gruenich Mar 24, 2025
2f86d13
Update googletest to 1.13
gruenich Mar 24, 2025
aa8d4e4
up
Sep 4, 2025
4fe2fb8
Use std::locale::classic() instead of creating new C locales on demand.
mmueller2012 Sep 15, 2025
65c1c27
Fix warning -Wconstexpr-not-const
zhao-shihan Sep 27, 2025
a83cd31
Bump actions/checkout from 4 to 5 in the github-actions group
dependabot[bot] Oct 1, 2025
bbf8bdb
Bump actions/checkout from 5 to 6 in the github-actions group
dependabot[bot] Dec 1, 2025
a2826e8
fix: unittests sets locale before testing
SGSSGene Dec 10, 2025
c7aa78d
fix: overflow buffer with large precision values
SGSSGene Dec 10, 2025
5cf2553
build(deps): bump actions/checkout in the github-actions group
dependabot[bot] Jan 1, 2026
3738976
fix(bazel): add missing load statements
ahans Dec 26, 2025
89ff142
Add IWYU export pragmas.
hzeller Oct 24, 2025
f0329d0
build(deps): bump actions/checkout in the github-actions group
dependabot[bot] Feb 1, 2026
56e3bb5
Update project version to 0.9.0
jbeder Feb 4, 2026
2e6383d
Update README.md
KSkwarczynski Feb 8, 2026
80ea002
Fix DecodeBase64 to reject truncated input
jwnimmer-tri Feb 10, 2026
ebb85dd
fix: floating point conversion on x86 (32bit)
SGSSGene Feb 11, 2026
495cde6
Support newer CMake in test too
DarthGandalf Feb 11, 2026
f3f123c
test: add case demonstrating bug
SGSSGene Feb 17, 2026
f25f110
fix: change abort when no parsing progress is made
SGSSGene Feb 17, 2026
3e53605
test: fixes test for NBSP (non-break space)
SGSSGene Feb 17, 2026
44d5454
fix: handle escaped underscore `\_` correctly
SGSSGene Feb 17, 2026
97d150e
Feat/fix faulty string (#1406)
SGSSGene Feb 18, 2026
cd9cc51
Merge remote-tracking branch 'u/master' into ch-master
azat Feb 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .bazelignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
test/gtest-1.11.0
test/googletest-1.13.0
2 changes: 1 addition & 1 deletion .codedocs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ EXAMPLE_PATH =

# One or more directories and files to exclude from documentation generation.
# Use relative paths with respect to the repository root directory.
EXCLUDE = test/gtest-1.8.0/
EXCLUDE = test/googletest-1.13.0/

# One or more wildcard patterns to exclude files and directories from document
# generation.
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ jobs:
googletest: [build, system]
generator: ["Default Generator", "MinGW Makefiles"]
exclude:
- os: ubuntu-latest
cxx_standard: 11
googletest: system
- os: macos-latest
build: shared
- os: macos-latest
Expand Down Expand Up @@ -47,7 +50,7 @@ jobs:
packages: googletest libgmock-dev libgtest-dev
version: 1.0

- uses: actions/checkout@v4
- uses: actions/checkout@v6.0.2

- name: Configure
run: |
Expand Down Expand Up @@ -105,7 +108,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6.0.2

- name: Build
run: |
Expand All @@ -123,7 +126,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6.0.2

- name: Build
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bzlmod-archive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
permissions:
contents: write
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v4.1.1
- run: git archive $GITHUB_REF -o "yaml-cpp-${GITHUB_REF:10}.tar.gz"
- run: gh release upload ${GITHUB_REF:10} "yaml-cpp-${GITHUB_REF:10}.tar.gz"
env:
Expand Down
2 changes: 2 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

yaml_cpp_defines = select({
# On Windows, ensure static linking is used.
"@platforms//os:windows": ["YAML_CPP_STATIC_DEFINE", "YAML_CPP_NO_CONTRIB"],
Expand Down
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# 3.5 is actually available almost everywhere, but this a good minimum.
# 3.14 as the upper policy limit avoids CMake deprecation warnings.
cmake_minimum_required(VERSION 3.4...3.14)
# 3.5 is actually available almost everywhere.
# 3.30 as the upper policy limit avoids CMake deprecation warnings.
cmake_minimum_required(VERSION 3.5...3.30)

# enable MSVC_RUNTIME_LIBRARY target property
# see https://cmake.org/cmake/help/latest/policy/CMP0091.html
if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()

project(YAML_CPP VERSION 0.8.0 LANGUAGES CXX)
project(YAML_CPP VERSION 0.9.0 LANGUAGES CXX)

set(YAML_CPP_MAIN_PROJECT OFF)
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
Expand Down Expand Up @@ -197,6 +197,7 @@ if (YAML_CPP_FORMAT_SOURCE AND YAML_CPP_CLANG_FORMAT_EXE)
COMMAND clang-format --style=file -i $<TARGET_PROPERTY:yaml-cpp,SOURCES>
COMMAND_EXPAND_LISTS
COMMENT "Running clang-format"
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
VERBATIM)
endif()

Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Commit messages should be in the imperative mood, as described in the [Git contr

# Tests

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

If you are adding functionality, add tests accordingly.
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.

# Pull request process

Expand Down
6 changes: 3 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module(
version = "0.8.0",
)

bazel_dep(name = "platforms", version = "0.0.7")
bazel_dep(name = "rules_cc", version = "0.0.8")
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "rules_cc", version = "0.2.14")

bazel_dep(name = "googletest", version = "1.14.0", dev_dependency = True)
bazel_dep(name = "googletest", version = "1.17.0.bcr.2", dev_dependency = True)
282 changes: 282 additions & 0 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,18 @@ FetchContent_Declare(
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
GIT_TAG <tag_name> # Can be a tag (yaml-cpp-x.x.x), a commit hash, or a branch name (master)
)
FetchContent_GetProperties(yaml-cpp)

if(NOT yaml-cpp_POPULATED)
message(STATUS "Fetching yaml-cpp...")
FetchContent_Populate(yaml-cpp)
add_subdirectory(${yaml-cpp_SOURCE_DIR} ${yaml-cpp_BINARY_DIR})
endif()
FetchContent_MakeAvailable(yaml-cpp)

target_link_libraries(YOUR_LIBRARY PUBLIC yaml-cpp::yaml-cpp) # The library or executable that require yaml-cpp library
```

## Recent Releases

[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.
[yaml-cpp 0.9.0](https://github.com/jbeder/yaml-cpp/releases/tag/yaml-cpp-0.9.0) released!

[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.

**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.
**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.

# API Documentation

Expand Down
10 changes: 0 additions & 10 deletions WORKSPACE

This file was deleted.

2 changes: 2 additions & 0 deletions docs/How-To-Emit-YAML.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ produces
# STL Containers, and Other Overloads #
We overload `operator <<` for `std::vector`, `std::list`, and `std::map`, so you can write stuff like:

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

Expand All @@ -165,6 +166,7 @@ out << YAML::Flow << squares;
out << ages;
out << YAML::EndSeq;
```
{% endraw %}

produces

Expand Down
2 changes: 0 additions & 2 deletions include/yaml-cpp/dll.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
# ifndef YAML_CPP_API
# ifdef yaml_cpp_EXPORTS
/* We are building this library */
# pragma message( "Defining YAML_CPP_API for DLL export" )
# define YAML_CPP_API __declspec(dllexport)
# else
/* We are using this library */
# pragma message( "Defining YAML_CPP_API for DLL import" )
# define YAML_CPP_API __declspec(dllimport)
# endif
# endif
Expand Down
20 changes: 17 additions & 3 deletions include/yaml-cpp/emitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,24 @@

#include <cmath>
#include <cstddef>
#include <cstring>
#include <limits>
#include <memory>
#include <sstream>
#include <string>
#include <type_traits>

#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
#include <string_view>
#endif

#include "yaml-cpp/binary.h"
#include "yaml-cpp/dll.h"
#include "yaml-cpp/emitterdef.h"
#include "yaml-cpp/emittermanip.h"
#include "yaml-cpp/null.h"
#include "yaml-cpp/ostream_wrapper.h"
#include "yaml-cpp/fptostring.h"

namespace YAML {
class Binary;
Expand Down Expand Up @@ -67,6 +73,7 @@ class YAML_CPP_API Emitter {
Emitter& SetLocalPrecision(const _Precision& precision);

// overloads of write
Emitter& Write(const char* str, std::size_t size);
Emitter& Write(const std::string& str);
Emitter& Write(bool b);
Emitter& Write(char ch);
Expand Down Expand Up @@ -141,6 +148,7 @@ inline Emitter& Emitter::WriteIntegralType(T value) {
PrepareNode(EmitterNodeType::Scalar);

std::stringstream stream;
stream.imbue(std::locale::classic());
PrepareIntegralStream(stream);
stream << value;
m_stream << stream.str();
Expand All @@ -158,6 +166,7 @@ inline Emitter& Emitter::WriteStreamable(T value) {
PrepareNode(EmitterNodeType::Scalar);

std::stringstream stream;
stream.imbue(std::locale::classic());
SetStreamablePrecision<T>(stream);

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

if (!special) {
stream << value;
stream << FpToString(value, stream.precision());
}
m_stream << stream.str();

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

// overloads of insertion
#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
inline Emitter& operator<<(Emitter& emitter, const std::string_view& v) {
return emitter.Write(v.data(), v.size());
}
#endif
inline Emitter& operator<<(Emitter& emitter, const std::string& v) {
return emitter.Write(v);
return emitter.Write(v.data(), v.size());
}
inline Emitter& operator<<(Emitter& emitter, bool v) {
return emitter.Write(v);
Expand Down Expand Up @@ -230,7 +244,7 @@ inline Emitter& operator<<(Emitter& emitter, const Binary& b) {
}

inline Emitter& operator<<(Emitter& emitter, const char* v) {
return emitter.Write(std::string(v));
return emitter.Write(v, std::strlen(v));
}

inline Emitter& operator<<(Emitter& emitter, int v) {
Expand Down
7 changes: 4 additions & 3 deletions include/yaml-cpp/emitterstyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
#endif

namespace YAML {
struct EmitterStyle {
enum value { Default, Block, Flow };
};
namespace EmitterStyle {
enum value { Default, Block, Flow };
}

}

#endif // EMITTERSTYLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
3 changes: 3 additions & 0 deletions include/yaml-cpp/exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ const char* const UNKNOWN_TOKEN = "unknown token";
const char* const DOC_IN_SCALAR = "illegal document indicator in scalar";
const char* const EOF_IN_SCALAR = "illegal EOF in scalar";
const char* const CHAR_IN_SCALAR = "illegal character in scalar";
const char* const UNEXPECTED_SCALAR = "unexpected scalar";
const char* const UNEXPECTED_FLOW = "plain value cannot start with flow indicator character";
const char* const TAB_IN_INDENTATION =
"illegal tab when looking for indentation";
const char* const FLOW_END = "illegal flow end";
Expand Down Expand Up @@ -89,6 +91,7 @@ const char* const INVALID_TAG = "invalid tag";
const char* const BAD_FILE = "bad file";
const char* const MERGE_KEY_NEEDS_SINGLE_OR_SEQUENCE_OF_MAPS =
"merge key needs either single map or sequence of maps";
const char* const UNEXPECTED_TOKEN_AFTER_DOC = "unexpected token after end of document";

template <typename T>
inline const std::string KEY_NOT_FOUND_WITH_KEY(
Expand Down
15 changes: 15 additions & 0 deletions include/yaml-cpp/fptostring.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef YAML_H_FPTOSTRING
#define YAML_H_FPTOSTRING

#include "yaml-cpp/dll.h"

#include <string>

namespace YAML {
// "precision = 0" refers to shortest known unique representation of the value
YAML_CPP_API std::string FpToString(float v, size_t precision = 0);
YAML_CPP_API std::string FpToString(double v, size_t precision = 0);
YAML_CPP_API std::string FpToString(long double v, size_t precision = 0);
}

#endif
5 changes: 4 additions & 1 deletion include/yaml-cpp/node/convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "yaml-cpp/node/node.h"
#include "yaml-cpp/node/type.h"
#include "yaml-cpp/null.h"
#include "yaml-cpp/fptostring.h"


namespace YAML {
Expand Down Expand Up @@ -129,7 +130,7 @@ inner_encode(const T& rhs, std::stringstream& stream){
stream << ".inf";
}
} else {
stream << rhs;
stream << FpToString(rhs, stream.precision());
}
}

Expand Down Expand Up @@ -171,6 +172,7 @@ ConvertStreamTo(std::stringstream& stream, T& rhs) {
\
static Node encode(const type& rhs) { \
std::stringstream stream; \
stream.imbue(std::locale::classic()); \
stream.precision(std::numeric_limits<type>::max_digits10); \
conversion::inner_encode(rhs, stream); \
return Node(stream.str()); \
Expand All @@ -182,6 +184,7 @@ ConvertStreamTo(std::stringstream& stream, T& rhs) {
} \
const std::string& input = node.Scalar(); \
std::stringstream stream(input); \
stream.imbue(std::locale::classic()); \
stream.unsetf(std::ios::dec); \
if ((stream.peek() == '-') && std::is_unsigned<type>::value) { \
return false; \
Expand Down
2 changes: 1 addition & 1 deletion include/yaml-cpp/node/detail/iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class iterator_base {
using value_type = V;
using difference_type = std::ptrdiff_t;
using pointer = V*;
using reference = V;
using reference = V&;

public:
iterator_base() : m_iterator(), m_pMemory() {}
Expand Down
1 change: 1 addition & 0 deletions include/yaml-cpp/node/detail/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class YAML_CPP_API memory {
memory() : m_nodes{} {}
node& create_node();
void merge(const memory& rhs);
size_t size() const;

private:
using Nodes = std::set<shared_node>;
Expand Down
2 changes: 1 addition & 1 deletion include/yaml-cpp/node/detail/node_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class node_iterator_base {
using value_type = node_iterator_value<V>;
using difference_type = std::ptrdiff_t;
using pointer = node_iterator_value<V>*;
using reference = node_iterator_value<V>;
using reference = node_iterator_value<V>&;
using SeqIter = typename node_iterator_type<V>::seq;
using MapIter = typename node_iterator_type<V>::map;

Expand Down
6 changes: 4 additions & 2 deletions include/yaml-cpp/node/impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ struct as_if<T, void> {
const Node& node;

T operator()() const {
if (!node.m_pNode)
throw TypedBadConversion<T>(node.Mark());
if (!node.m_pNode) // no fallback
throw InvalidNode(node.m_invalidKey);

T t;
if (convert<T>::decode(node, t))
Expand All @@ -140,6 +140,8 @@ struct as_if<std::string, void> {
const Node& node;

std::string operator()() const {
if (node.Type() == NodeType::Undefined) // no fallback
throw InvalidNode(node.m_invalidKey);
if (node.Type() == NodeType::Null)
return "null";
if (node.Type() != NodeType::Scalar)
Expand Down
Loading
Loading