Commit Graph

276 Commits

Author SHA1 Message Date
Chen
98acc5a887
Emit the correct Alias on the key (#908) (#929) 2020-07-27 13:49:04 -05:00
Chen
1c9abc8fa4
fix issue743: handle the empty content of flow sep/map correctly during emitting. (#921)
* fix issue743: handle the empty content of flow sep/map correctly during emitting.

* handle the empty Tag/Anchor properly.

* delete comment
2020-07-24 07:28:40 -05:00
Chen
c2793a36d5
Fix runtime exceptions in Visual Studio environment. (#926) 2020-07-23 08:48:20 -05:00
Chen
c3df6d87d4
Properly allow a trailing tab character on a block scalar (#919)
Fixes #917
2020-07-16 10:08:09 -05:00
Chen
51ce663085
Handle a key with length over 1024 as a long key. (#916)
Fixes #501
2020-07-16 09:51:54 -05:00
Chen
33315286ab
Add the support to parsing a null value as std::string.
Fixes #590.
2020-07-16 09:15:39 -05:00
Oliver Hamlet
c82d3129dd
Add support for JSON-compatible string escapes (#485)
For completeness I've implemented escaping for characters outside the
basic multilingual plane, but it doesn't get used (as there's no
EscapeAsAsciiJson emitter option implemented).
2020-07-13 21:16:34 -05:00
Chen
6d5cfab5fd
fix bug from issue298:Emitter stylings settings overridden by node settings. (#915) 2020-07-06 08:16:38 -05:00
Chen
026a53fbe1
Parse colon in plain scalar correctly when in a flow collection
Fixes #740.
2020-07-02 14:08:14 -05:00
Raffaello Bertini
1c2e767347
Fix YAML::Newline in a sequence or map.
Inside of a sequence or map, `YAML::Newline` wouldn't reset the collection state, which would cause behavior like this:

```
nodeA:   
    k: [{i: 0},
 {i:1},
  ]NodeB:
    k: [{i: 0},
 {i:1},
  ]
```
2020-07-01 22:31:51 -05:00
Chen
08aa252611
Support kinds of emitter format-setting for YAML::Null. (#906)
* Support kinds of emitter format-setting for YAML::Null.

* update the code and test cases

* add the comment //fallthrough
2020-06-28 23:31:53 -05:00
Chen
5a9ab177ba
tag_null (#897) 2020-06-17 12:49:09 -05:00
Chen
72fe73a104
fix issue752: generate right long keys (#879)
* fix issue752: generate right long keys

* Improve the readability of test cases

* update to raw string literal
2020-06-17 00:57:28 -05:00
Rosen Penev
b2cd008717
partially fix clang compilation (#893)
* partially fix clang compilation

Missing header and mistaken algorithm usage.

Also removed it name from range loops. It's not correct.

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* run through clang's -Wrange-loop-analysis

Some range loops should not use references as they need to copy.

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* manual range loop conversions

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-06-15 16:59:27 -05:00
Chen
4dbfeb0bbc
Support as<uint8_t>/as<int8_t>.
Fix issue 844/848.
2020-06-15 10:31:59 -05:00
Chen
33316d531b
Add tests for some interfaces of emitter (#875) 2020-05-31 09:16:16 -05:00
Raúl Gutiérrez Segalés
f05b2577ad
Fix crash when parsing {x: (#865) 2020-05-23 12:17:20 -05:00
Chen
d9c35b6079
Throw an exception when trying to parse a negative number as an unsigned.
Fixing issue 859.
2020-05-19 11:48:22 -05:00
Chen
4b98aedc16
Supplement test cases for 2.19 ~ 2.22 schema tags. (#857)
Add test cases for the event handler for schema tags; does not include test cases for Node because specialized tag handling is not implemented yet.
2020-05-12 13:20:45 -05:00
Ian Taylor
9fb5153487
implement convert for standard library containers allowing for custom allocators (#855) 2020-04-29 18:29:33 -05:00
Alan Griffiths
4edff1fa5d
Fix stack overflow (#807)
Fix stack overflow in HandleNode by explicitly limiting the depth of recursion.
2020-04-09 13:02:10 -05:00
Ted Lyngmo
1d8542ad32
Add NodeTest EqualRepresentationAfterMoveAssignment (#816)
Add check that a move assigned Node gets the same representation as the
moved-from Node had before the move.
2020-04-07 20:08:56 -05:00
Romain Deterre
120863ba5a
Update Google Test to v1.10.0 (#840)
This commit updates the version of Google Test from 1.8 to 1.10.
2020-03-28 19:53:13 -05:00
Anton Onishchenko
de8253fcb0
Fix storing inf and NaN (#817) 2020-02-14 18:03:21 -06:00
JeffWegher
29dcf92f87
Fix Node::size() after removing node from sequence (#820) 2020-02-14 14:38:58 -06:00
Ted Lyngmo
ce056acab7
Add IsNull() check in test after reassignment (#814) 2020-02-07 10:52:43 -06:00
Jesse Beder
c9460110e0 Fix reading empty token stack with a node with properties but no scalar.
E.g. `!2`.
2020-01-20 18:16:08 -06:00
Igor [hyperxor]
5b3e30bfe9 Small readability improvements in Parser
Also add a test for a parser with no data
2019-11-23 13:17:02 -06:00
Igor [hyperxor]
72f699f5ce Remove redundant checks and add more unit tests (#783) 2019-11-04 10:19:02 -06:00
Fatih YAZICI
21d75fa4cd Fix CMake 3.10 and below compatibility (#763)
Add empty list of sources to add_library and add_executable.
2019-10-04 14:46:18 -05:00
Ezekiel Warren
62ff351432 Add bazel Support (#724)
Example of how someone might consume yaml-cpp with bazel:

cc_binary(
    name = "example",
    srcs = ["example.cc"],
    deps = ["@com_github_jbeder_yaml_cpp//:yaml-cpp"],
)
2019-09-27 10:11:38 -05:00
Isabella Muerte
5e9cb0128d Refactor CMake to use more modern paradigms (#741)
Remove 2.6-isms
Remove 2.8-isms
Bump CMake minimum version to 3.4

Disable some options when used as a subdirectory

Use `CONFIGURE_DEPENDS` with `file(GLOB)` when possible

Backport CMake 3.15's MSVC_RUNTIME_LIBRARY setting.
Set all compile options as generator expressions.
Set all find-package files to be installed to the correct file.

Remove `export(PACKAGE)`, as this has been deprecated.
Remove fat binary support
Remove manual setting of iPhone settings. These should be set by parent
projects.
Remove use of ExternalProject for a local use
Conditionally remove format target unless clang-format is found
2019-09-27 09:59:53 -05:00
Andy Maloney
d638508d33 Set C++ standard options in CMake per-target instead of globally (#735)
Setting CMAKE_CXX_STANDARD and CMAKE_CXX_STANDARD_REQUIRED directly is problematic when including yaml-cpp as a subproject.

The proper way is to set these per-target.
2019-09-10 07:51:13 -07:00
Jeppe Blicher Tarp
e0e01d53c2 Make sure output of NaN, Infinity and -Infinity is identical on all platforms (#717)
Specifically, printing `.nan`, `.inf`, and `-.inf`, respectively, as per the spec section 10.2.1.4.
2019-08-03 21:41:45 -04:00
bedapisl
0122697561 Improve error messages on operator[] or as<> (#656)
Invalid access via operator[] or as<> will now print the offending key, if possible.

For example:

a:
  x: 1
  y: 2

node["a"]["z"].as<int>()

will say that the key "z" was invalid.
2019-04-17 08:44:09 -05:00
Ted Lyngmo
0d5c57150c Apply formatting/style tweaks to comply with compile time diagnostics for g++ and clang++ (#686)
* Add compilation flags: -Wshadow -Weffc++ -pedantic -pedantic-errors
* Delete implicit copy & move constructors & assignment operators
  in classes with pointer data members.
* An exception to the above: Add default copy & move constructors &
  assignment operators for the Binary class.
* Convert boolean RegEx operators to binary operators.
* Initialize all members in all classes in ctors.
* Let default ctor delegate to the converting ctor in
  Binary and RegEx
* Don't change any tests except regex_test (as a result of the change
  to binary operators).

Note: https://bugzilla.redhat.com/show_bug.cgi?id=1544675 makes
-Weffc++ report a false positive in "include/yaml-cpp/node/impl.h".
2019-03-13 15:18:34 -07:00
caryoscelus
eca9cfd648 Add optional OnAnchor method to EventHandler (#530)
ref #110
2019-03-12 15:24:32 -07:00
Simon Gene Gottlieb
abf941b20d Fix float precision (#649)
The issue is that numbers like
2.01 or 3.01 can not be precisely represented with binary floating point
numbers.

This replaces all occurrences of 'std::numeric_limits<T>::digits10 + 1' with
'std::numeric_limits<T>::max_digits10'.

Background:
Using 'std::numeric_limits<T>::digits10 + 1' is not precise enough.
Converting a 'float' into a 'string' and back to a 'float' will not always
produce the original 'float' value. To guarantee that the 'string'
representation has sufficient precision the value
'std::numeric_limits<T>::max_digits10' has to be used.
2018-12-21 09:05:19 -05:00
Stefan Reinhold
45d9035a33 Skip newlines in binary decoding (Fix #387) (#616)
* Skip newlines in binary decoding
This fixes #387

* Skip all whitespace characters

This also removes spaces and tabs in addition to newlines.
2018-09-03 15:55:45 -05:00
Azamat H. Hackimov
5e79f5eed3 Improvements to CMake buildsystem
Roll-forward of c90c08ccc9 "Revert "Improvements to CMake buildsystem (#563)""

NEW:

* Replace CMAKE_SOURCE_DIR with CMAKE_CURRENT_SOURCE_DIR

Fixes #612 when yaml-cpp is used as a git submodule.

ORIGINAL:

* Move enable_testing() into proper place

* Added CMake's checks for C++11 standards

Raised minimal version of CMake to 3.1, since on old systems there no
decent compilers that supports c++11.

Closes #377.

* Externalize googletest project

Externalize gtest to avoid installation, fixes #539.

* Remove defined cmake_policies

CMP0012 - OLD marked as deprecated for >=cmake-3.1 and will be removed
CMP0015 - does not affect to build process
CMP0042 - already NEW for >=cmake-3.1

Fixes #505

* Fix compiling in Windows MSVC
2018-09-03 10:37:06 -05:00
Jesse Beder
c90c08ccc9 Revert "Improvements to CMake buildsystem (#563)"
This reverts commit 3e33bb3166.

The original commit broke the build (#612) when yaml-cpp is used as a git submodule.
2018-08-09 10:05:07 -05:00
Azamat H. Hackimov
3e33bb3166 Improvements to CMake buildsystem (#563)
* Move enable_testing() into proper place

* Added CMake's checks for C++11 standards

Raised minimal version of CMake to 3.1, since on old systems there no
decent compilers that supports c++11.

Closes #377.

* Externalize googletest project

Externalize gtest to avoid installation, fixes #539.

* Remove defined cmake_policies

CMP0012 - OLD marked as deprecated for >=cmake-3.1 and will be removed
CMP0015 - does not affect to build process
CMP0042 - already NEW for >=cmake-3.1

Fixes #505

* Fix compiling in Windows MSVC
2018-08-09 07:11:50 -05:00
Jiao
4fb1c4b92b Enable items to be removed from a sequence (#582) 2018-05-14 08:50:28 -05:00
Patrick Stotko
ab5f9259a4 Use target-based include_directories to enable modern CMake usage (#583) 2018-05-05 11:03:13 -05:00
Denis Gladkikh
cfb7606a84 Fix tag parsing with () (#532) 2018-01-28 10:18:55 -06:00
Ryan Schmidt
3f33f337a7 Only use -Wno-c99-extensions for clang 2017-11-14 07:07:37 -08:00
Roger Leigh
5e24f35816 test: Upgrade googlemock 1.7.0 to googletest 1.8.0
Note that with the release of 1.8.0, googlemock and
googletest are unified into a single release.
2017-08-24 22:49:17 -05:00
Peter-Levine
efbfa1c7c7 Fix segfault in gmock when running tests (#514)
Taken from https://github.com/google/googletest/issues/705#issuecomment-235067917
2017-07-24 09:14:23 -05:00
butataatawa
f82861001a Fix sequence sometimes not turning into a map (#450)
Previously, just referencing the next element in the sequence (and so constructing it, as an undefined element) would allow you to skip defining an element without turning the sequence into a map. E.g:

node[0] = "foo"; // sequence of size 1
node[1]; // sequence of size 1, with an undefined element at 1
node[2] = "bar"; // FIX: should be map of size 2 (since there's no element at index 1)
2017-01-02 15:44:22 -06:00
butataatawa
147d909fe6 Fix inconsistent Node::size when removing a key with unassigned node (#327) (#449) 2016-12-06 08:40:00 -06:00