Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,3 @@ SpaceAfterControlStatementKeyword: true
SpaceBeforeAssignmentOperators: true
ContinuationIndentWidth: 4
...

7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
1 change: 0 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ updates:
github-actions:
patterns:
- "*"

2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
${{format(matrix.generator != 'Default Generator' && '-G "{0}"' || '', matrix.generator)}}
CMAKE_INSTALL_PREFIX: "${{ github.workspace }}/install-prefix"
CMAKE_BUILD_TYPE: Debug
CMAKE_CXX_FLAGS_DEBUG: ${{ matrix.googletest == 'build' && '-g -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC' || '-g' }}
CMAKE_CXX_FLAGS_DEBUG: ${{ matrix.googletest == 'build' && '-g -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC' || '-g' }}
runs-on: ${{ matrix.os }}
steps:

Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/whitespace.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Whitespace

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:

permissions: read-all

jobs:
whitespace:
name: Whitespace
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

- name: Check whitespace
run: python3 util/check-whitespace.py
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ cmake_dependent_option(YAML_MSVC_SHARED_RT
"CMAKE_SYSTEM_NAME MATCHES Windows" OFF)
set(YAML_CPP_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/yaml-cpp"
CACHE STRING "Path to install the CMake package to")

if (YAML_CPP_FORMAT_SOURCE)
find_program(YAML_CPP_CLANG_FORMAT_EXE NAMES clang-format)
endif()
Expand Down
9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ Please verify the tests pass by configuring CMake with `-D YAML_CPP_BUILD_TESTS=

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.

# Whitespace

Maintained text files must not contain trailing spaces or tabs. Each line
must end with an LF character, and non-empty files must have exactly one final
LF. The vendored GoogleTest sources are excluded from this check.

You may run `python3 util/check-whitespace.py` to check whitespace before
submitting a pull request.

# Pull request process

Every pull request undergoes a code review. Unfortunately, github's code review process isn't great, but we'll manage. During the code review, if you make changes, add new commits to the pull request for each change. Once the code review is complete, rebase against the master branch and squash into a single commit.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ target_link_libraries(YOUR_LIBRARY PUBLIC yaml-cpp::yaml-cpp) # The library or e

**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
# API Documentation

The autogenerated API reference is hosted on [CodeDocs](https://codedocs.xyz/jbeder/yaml-cpp/index.html)

Expand Down
2 changes: 1 addition & 1 deletion docs/Breaking-Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ _none_

## 0.2.5 ##

This wiki was started with v0.2.5.
This wiki was started with v0.2.5.
2 changes: 1 addition & 1 deletion docs/How-To-Emit-YAML.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int main()
{
YAML::Emitter out;
out << "Hello, World!";

std::cout << "Here's the output YAML:\n" << out.c_str(); // prints "Hello, World!"
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion docs/How-To-Parse-A-Document-(Old-API).md
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,4 @@ This is intended behavior. If you want to copy a node, use the `Clone` function:
std::auto_ptr<YAML::Node> pCopy = myOtherNode.Clone();
```

The intent is that if you'd like to keep a `YAML::Node` around for longer than the document will stay in scope, you can clone it and store it as long as you like.
The intent is that if you'd like to keep a `YAML::Node` around for longer than the document will stay in scope, you can clone it and store it as long as you like.
2 changes: 1 addition & 1 deletion docs/Strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ For convenience, Richard Weeks has kindly provided a google gadget that converts

```
<wiki:gadget url="http://hosting.gmodules.com/ig/gadgets/file/111180078345548400783/c-style-utf8-encoder.xml"/>
```
```
6 changes: 3 additions & 3 deletions docs/Tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public:
node["a"] = a;
return node;
}

int a;
};

Expand Down Expand Up @@ -252,7 +252,7 @@ public:

// Implementation of convert::{encode,decode} for all classes derived from or being A
namespace YAML {
template<typename T>
template<typename T>
struct convert<T, typename std::enable_if<std::is_base_of<A, T>::value>::type> {
static Node encode(const T &rhs) {
Node node = rhs.emit();
Expand All @@ -274,4 +274,4 @@ B b = node.as<B>();
b.a = 12;
b.b = 42;
node = b;
```
```
2 changes: 1 addition & 1 deletion docs/_config.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
theme: jekyll-theme-slate
theme: jekyll-theme-slate
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 @@ -78,7 +78,7 @@ class iterator_base {
++(*this);
return iterator_pre;
}

iterator_base<V>& operator--() {
--m_iterator;
return *this;
Expand Down
6 changes: 3 additions & 3 deletions include/yaml-cpp/node/detail/reverse_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class reverse_iterator_base {

public:
using iterator_type = Iter;
using iterator_category = typename std::iterator_traits<Iter>::iterator_category;
using iterator_category = typename std::iterator_traits<Iter>::iterator_category;
using value_type = typename std::iterator_traits<Iter>::value_type;
using difference_type = typename std::iterator_traits<Iter>::difference_type;
using pointer = typename std::iterator_traits<Iter>::pointer;
Expand All @@ -53,7 +53,7 @@ class reverse_iterator_base {
typename std::enable_if<std::is_convertible<Iter2, Iter>::value,
enabler>::type = enabler())
: current(_other.current) {}

reverse_iterator_base<Iter>& operator++() {
--current;
return *this;
Expand All @@ -64,7 +64,7 @@ class reverse_iterator_base {
++(*this);
return iterator_pre;
}

reverse_iterator_base<Iter>& operator--() {
++current;
return *this;
Expand Down
64 changes: 32 additions & 32 deletions src/contrib/yaml-cpp.natvis
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- MSVC Debugger visualization hints for YAML::Node and YAML::detail::node -->
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="YAML::Node">
<DisplayString Condition="!m_isValid">{{invalid}}</DisplayString>
<DisplayString Condition="!m_pNode">{{pNode==nullptr}}</DisplayString>
<DisplayString>{{ {*m_pNode} }}</DisplayString>
<Expand>
<Item Condition="m_pNode->m_pRef._Ptr->m_pData._Ptr->m_type==YAML::NodeType::Scalar" Name="scalar">m_pNode->m_pRef._Ptr->m_pData._Ptr->m_scalar</Item>
<Item Condition="m_pNode->m_pRef._Ptr->m_pData._Ptr->m_type==YAML::NodeType::Sequence" Name="sequence">m_pNode->m_pRef._Ptr->m_pData._Ptr->m_sequence</Item>
<Item Condition="m_pNode->m_pRef._Ptr->m_pData._Ptr->m_type==YAML::NodeType::Map" Name="map">m_pNode->m_pRef._Ptr->m_pData._Ptr->m_map</Item>
<Item Name="[details]" >m_pNode->m_pRef._Ptr->m_pData._Ptr</Item>
</Expand>
</Type>
<Type Name="YAML::detail::node">
<DisplayString Condition="!m_pRef._Ptr">{{node:pRef==nullptr}}</DisplayString>
<DisplayString Condition="!m_pRef._Ptr->m_pData._Ptr">{{node:pRef->pData==nullptr}}</DisplayString>
<DisplayString Condition="!m_pRef._Ptr->m_pData._Ptr->m_isDefined">{{undefined}}</DisplayString>
<DisplayString Condition="m_pRef._Ptr->m_pData._Ptr->m_type==YAML::NodeType::Scalar">{{{m_pRef._Ptr->m_pData._Ptr->m_scalar}}}</DisplayString>
<DisplayString Condition="m_pRef._Ptr->m_pData._Ptr->m_type==YAML::NodeType::Map">{{ Map {m_pRef._Ptr->m_pData._Ptr->m_map}}}</DisplayString>
<DisplayString Condition="m_pRef._Ptr->m_pData._Ptr->m_type==YAML::NodeType::Sequence">{{ Seq {m_pRef._Ptr->m_pData._Ptr->m_sequence}}}</DisplayString>
<DisplayString>{{{m_pRef._Ptr->m_pData._Ptr->m_type}}}</DisplayString>
<Expand>
<Item Condition="m_pRef._Ptr->m_pData._Ptr->m_type==YAML::NodeType::Scalar" Name="scalar">m_pRef._Ptr->m_pData._Ptr->m_scalar</Item>
<Item Condition="m_pRef._Ptr->m_pData._Ptr->m_type==YAML::NodeType::Sequence" Name="sequence">m_pRef._Ptr->m_pData._Ptr->m_sequence</Item>
<Item Condition="m_pRef._Ptr->m_pData._Ptr->m_type==YAML::NodeType::Map" Name="map">m_pRef._Ptr->m_pData._Ptr->m_map</Item>
<Item Name="[details]" >m_pRef._Ptr->m_pData._Ptr</Item>
</Expand>
</Type>
</AutoVisualizer>
<?xml version="1.0" encoding="utf-8"?>
<!-- MSVC Debugger visualization hints for YAML::Node and YAML::detail::node -->
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="YAML::Node">
<DisplayString Condition="!m_isValid">{{invalid}}</DisplayString>
<DisplayString Condition="!m_pNode">{{pNode==nullptr}}</DisplayString>
<DisplayString>{{ {*m_pNode} }}</DisplayString>
<Expand>
<Item Condition="m_pNode->m_pRef._Ptr->m_pData._Ptr->m_type==YAML::NodeType::Scalar" Name="scalar">m_pNode->m_pRef._Ptr->m_pData._Ptr->m_scalar</Item>
<Item Condition="m_pNode->m_pRef._Ptr->m_pData._Ptr->m_type==YAML::NodeType::Sequence" Name="sequence">m_pNode->m_pRef._Ptr->m_pData._Ptr->m_sequence</Item>
<Item Condition="m_pNode->m_pRef._Ptr->m_pData._Ptr->m_type==YAML::NodeType::Map" Name="map">m_pNode->m_pRef._Ptr->m_pData._Ptr->m_map</Item>
<Item Name="[details]" >m_pNode->m_pRef._Ptr->m_pData._Ptr</Item>
</Expand>
</Type>

<Type Name="YAML::detail::node">
<DisplayString Condition="!m_pRef._Ptr">{{node:pRef==nullptr}}</DisplayString>
<DisplayString Condition="!m_pRef._Ptr->m_pData._Ptr">{{node:pRef->pData==nullptr}}</DisplayString>
<DisplayString Condition="!m_pRef._Ptr->m_pData._Ptr->m_isDefined">{{undefined}}</DisplayString>
<DisplayString Condition="m_pRef._Ptr->m_pData._Ptr->m_type==YAML::NodeType::Scalar">{{{m_pRef._Ptr->m_pData._Ptr->m_scalar}}}</DisplayString>
<DisplayString Condition="m_pRef._Ptr->m_pData._Ptr->m_type==YAML::NodeType::Map">{{ Map {m_pRef._Ptr->m_pData._Ptr->m_map}}}</DisplayString>
<DisplayString Condition="m_pRef._Ptr->m_pData._Ptr->m_type==YAML::NodeType::Sequence">{{ Seq {m_pRef._Ptr->m_pData._Ptr->m_sequence}}}</DisplayString>
<DisplayString>{{{m_pRef._Ptr->m_pData._Ptr->m_type}}}</DisplayString>
<Expand>
<Item Condition="m_pRef._Ptr->m_pData._Ptr->m_type==YAML::NodeType::Scalar" Name="scalar">m_pRef._Ptr->m_pData._Ptr->m_scalar</Item>
<Item Condition="m_pRef._Ptr->m_pData._Ptr->m_type==YAML::NodeType::Sequence" Name="sequence">m_pRef._Ptr->m_pData._Ptr->m_sequence</Item>
<Item Condition="m_pRef._Ptr->m_pData._Ptr->m_type==YAML::NodeType::Map" Name="map">m_pRef._Ptr->m_pData._Ptr->m_map</Item>
<Item Name="[details]" >m_pRef._Ptr->m_pData._Ptr</Item>
</Expand>
</Type>

</AutoVisualizer>
17 changes: 8 additions & 9 deletions src/contrib/yaml-cpp.natvis.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# MSVC debugger visualizer for YAML::Node

## How to use
Add yaml-cpp.natvis to your Visual C++ project like any other source file. It will be included in the debug information, and improve debugger display on YAML::Node and contained types.

## Compatibility and Troubleshooting

This has been tested for MSVC 2017. It is expected to be compatible with VS 2015 and VS 2019. If you have any problems, you can open an issue here: https://github.com/peterchen-cp/yaml-cpp-natvis

# MSVC debugger visualizer for YAML::Node

## How to use
Add yaml-cpp.natvis to your Visual C++ project like any other source file. It will be included in the debug information, and improve debugger display on YAML::Node and contained types.

## Compatibility and Troubleshooting

This has been tested for MSVC 2017. It is expected to be compatible with VS 2015 and VS 2019. If you have any problems, you can open an issue here: https://github.com/peterchen-cp/yaml-cpp-natvis
10 changes: 5 additions & 5 deletions src/emitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -983,13 +983,13 @@ Emitter& Emitter::Write(const Binary& binary) {
if (!good())
return *this;

const StringFormat::value strFormat =
const StringFormat::value strFormat =
Utils::ComputeBinaryFormat(binary, m_pState->GetStringFormat(),
m_pState->CurGroupFlowType());

if (strFormat == StringFormat::Literal)
if (strFormat == StringFormat::Literal)
m_pState->SetMapKeyFormat(YAML::LongKey, FmtScope::Local);

PrepareNode(EmitterNodeType::Scalar);

switch (strFormat) {
Expand All @@ -1004,8 +1004,8 @@ Emitter& Emitter::Write(const Binary& binary) {
Utils::WriteBinary(m_stream, binary);
break;
case StringFormat::Literal:
Utils::WriteLiteralBinary(m_stream, binary,
m_pState->CurIndent() + m_pState->GetIndent(),
Utils::WriteLiteralBinary(m_stream, binary,
m_pState->CurIndent() + m_pState->GetIndent(),
m_pState->GetWrap());
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/emitterutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ StringFormat::value ComputeBinaryFormat(const Binary &bin,
switch (strFormat) {
case Auto:
if (bin.size() > 0u) {
return StringFormat::Plain;
return StringFormat::Plain;
}
return StringFormat::DoubleQuoted;
case SingleQuoted:
Expand Down
2 changes: 1 addition & 1 deletion src/scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void Scanner::ScanNextToken() {
// special scalars
if (InBlockContext() && (INPUT.peek() == Keys::LiteralScalar ||
INPUT.peek() == Keys::FoldedScalar)) {
// if we begin parsing a literal scalar with an unverified potential
// if we begin parsing a literal scalar with an unverified potential
// simple key pushed, that may be a tag to the literal scalar, and
// should be removed to avoid wrong indentation limit
// eg:
Expand Down
8 changes: 4 additions & 4 deletions test/create-emitter-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def expand(template):
for car in expand(template[:1]):
for cdr in expand(template[1:]):
yield car + cdr


def gen_events():
for template in gen_templates():
Expand All @@ -153,7 +153,7 @@ class Writer(object):
def __init__(self, out):
self.out = out
self.indent = 0

def writeln(self, s):
self.out.write('%s%s\n' % (' ' * self.indent, s))

Expand All @@ -166,14 +166,14 @@ def __init__(self, writer, name, indent):
def __enter__(self):
self.writer.writeln('%s {' % self.name)
self.writer.indent += self.indent

def __exit__(self, type, value, traceback):
self.writer.indent -= self.indent
self.writer.writeln('}')

def create_emitter_tests(out):
out = Writer(out)

includes = [
'handler_test.h',
'yaml-cpp/yaml.h',
Expand Down
6 changes: 3 additions & 3 deletions test/integration/emitter_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ TEST_F(EmitterTest, Unicode) {

TEST_F(EmitterTest, DoubleQuotedUnicode) {
out << DoubleQuoted << "\x24 \xC2\xA2 \xE2\x82\xAC \xF0\xA4\xAD\xA2";
ExpectEmit("\"\x24 \xC2\xA2 \xE2\x82\xAC \xF0\xA4\xAD\xA2\"");
ExpectEmit("\"\x24 \xC2\xA2 \xE2\x82\xAC \xF0\xA4\xAD\xA2\"");
}

TEST_F(EmitterTest, EscapedJsonString) {
Expand All @@ -1029,7 +1029,7 @@ TEST_F(EmitterTest, EscapedJsonString) {
}

TEST_F(EmitterTest, EscapedCharacters) {
out << BeginSeq
out << BeginSeq
<< '\x00'
<< '\x0C'
<< '\x0D'
Expand Down Expand Up @@ -1606,7 +1606,7 @@ TEST_F(EmitterTest, NaN) {
"bar: .nan");
}

TEST_F(EmitterTest, ComplexFlowSeqEmbeddingAMapWithNewLine) {
TEST_F(EmitterTest, ComplexFlowSeqEmbeddingAMapWithNewLine) {
out << YAML::BeginMap;

out << YAML::Key << "NodeA" << YAML::Value << YAML::BeginMap;
Expand Down
8 changes: 4 additions & 4 deletions test/integration/error_messages_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ TEST(ErrorMessageTest, BadSubscriptErrorMessage) {
// Test that printable key is part of error message
EXPECT_THROW_EXCEPTION(YAML::BadSubscript, doc["first"]["second"]["fourth"],
"operator[] call on a scalar (key: \"fourth\")");

EXPECT_THROW_EXCEPTION(YAML::BadSubscript, doc["first"]["second"][37],
"operator[] call on a scalar (key: \"37\")");

Expand All @@ -47,15 +47,15 @@ TEST(ErrorMessageTest, Ex9_1_InvalidNodeErrorMessage) {
// Test that printable key is part of error message
EXPECT_THROW_EXCEPTION(YAML::InvalidNode, doc["first"]["fourth"].as<int>(),
"invalid node; first invalid key: \"fourth\"");

EXPECT_THROW_EXCEPTION(YAML::InvalidNode, doc["first"][37].as<int>(),
"invalid node; first invalid key: \"37\"");

// Non-printable key is not included in error message
EXPECT_THROW_EXCEPTION(YAML::InvalidNode,
doc["first"][std::vector<int>()].as<int>(),
"invalid node; this may result from using a map "
"iterator as a sequence iterator, or vice-versa");
}
}
}
}
Loading
Loading