Compare commits

..

15 Commits

Author SHA1 Message Date
Jesse Beder
e1e6344a21 Add back missing YAML_CPP_API. 2021-11-19 10:55:17 -06:00
Jesse Beder
317d6d3ce4 Revert "Revert "Revert "Hide most of non-public symbols by default (#984)" (#1038)" (#1045)"
This reverts commit 0733aeb451.
2021-11-19 10:47:42 -06:00
Ryan Burns
328d2d85e8 Fix .pc paths for absolute GNUInstallDirs (#1058)
GNUInstallDirs provided may be absolute paths, in which case appending
to the install prefix is not correct. We can instead use the provided
CMAKE_INSTALL_FULL_* variables, which are precomputed absolute paths.

https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html
2021-11-02 21:34:46 -05:00
PhilipDeegan
4564d9a131 github actions for mac/linux/windows (#1056) 2021-10-31 11:59:40 -05:00
Robert Sebastian Herlim
2f8997565b Use static_cast<unsigned char> on DecodeBase64 to prevent SEGV on negative values (#1051) 2021-10-20 10:18:08 -05:00
Michał Janiszewski
1713859b05 Remove unused code from parse util (#1048) 2021-10-13 15:56:11 -05:00
João Marcos Bezerra
393a02a225 README.md revision (#732) 2021-10-09 22:02:35 -05:00
Pino Toscano
0733aeb451 Revert "Revert "Hide most of non-public symbols by default (#984)" (#1038)" (#1045) 2021-10-09 21:48:05 -05:00
Jesse Beder
0d9dbcfe8c Revert "Hide most of non-public symbols by default (#984)" (#1038)
This reverts commit da1c8d360e. and fixes #1036.
2021-09-28 08:41:55 -05:00
Pino Toscano
da1c8d360e Hide most of non-public symbols by default (#984)
* Export YAML::detail::node::m_amount

The internal header node/detail/node.h is included by public headers;
YAML::detail::node is implemented in the header itself, and thus it gets
inlined... except for its static m_amount class member, which is
instantiated in the library only. Right now all the symbols of yaml-cpp
are exported (nothing is hidden), so the linker will find node::m_amount
in the yaml-cpp library.

As solution/workaround, explicitly export YAML::detail::node::m_amount.

* CMake: use GenerateExportHeader

Make use of the GenerateExportHeader CMake module to generate the dll.h
header with export macros.

While the produced dll.h is different, the result should be the same,
i.e. nothing changes for yaml-cpp or its users.

* CMake: hide all the symbols by default

Hide all the symbols that are not explicitly exported with YAML_CPP_API.
This way the ABI will be way smaller, and only actually exposing the
public classes/functions.
2021-09-25 12:10:58 -05:00
jwindgassen
6308112e54 Added UE-Wrapper link to Readme (#1024) 2021-08-30 06:11:08 -05:00
Snow Pettersen
db6deedcd3 Include name of anchor in invalid anchor error (#1015) 2021-07-23 14:52:21 -05:00
mjvankampen
79aa6d53e5 Add assert to enable compilation with libcxx + gcc (#947) 2021-07-15 16:09:05 -05:00
jbeach
ef0bba178d Bump minimum cmake versions in gtest to eliminate cmake deprecation warnings. (#1012) 2021-07-15 16:08:00 -05:00
JBPennington
b591d8ae2a Update node impl.h for GCC unused variable warning (#981)
Removed the variable name in the defaulted function to make GCC happy.
2021-07-10 11:07:12 -05:00
15 changed files with 94 additions and 52 deletions

40
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,40 @@
name: Github PR
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Build static
shell: bash
run: |
mkdir -p build && cd build
cmake ..
cmake --build . --parallel 4
- name: Test static
shell: bash
run: cd build && ctest --output-on-failure
- name: Build shared
shell: bash
run: |
rm -rf build && mkdir -p build && cd build
cmake .. -DYAML_BUILD_SHARED_LIBS=ON
cmake --build . --parallel 4
# tests are failing for unknown reasons
- if: matrix.os == 'ubuntu-latest'
name: Test shared
shell: bash
run: cd build && ctest --output-on-failure
# test all ASAP

View File

@@ -1,50 +1,46 @@
# yaml-cpp [![Build Status](https://travis-ci.org/jbeder/yaml-cpp.svg?branch=master)](https://travis-ci.org/jbeder/yaml-cpp) [![Documentation](https://codedocs.xyz/jbeder/yaml-cpp.svg)](https://codedocs.xyz/jbeder/yaml-cpp/) # yaml-cpp [![Build Status](https://travis-ci.org/jbeder/yaml-cpp.svg?branch=master)](https://travis-ci.org/jbeder/yaml-cpp) [![Documentation](https://codedocs.xyz/jbeder/yaml-cpp.svg)](https://codedocs.xyz/jbeder/yaml-cpp/)
yaml-cpp is a [YAML](http://www.yaml.org/) parser and emitter in C++ matching the [YAML 1.2 spec](http://www.yaml.org/spec/1.2/spec.html). `yaml-cpp` is a [YAML](http://www.yaml.org/) parser and emitter in C++ matching the [YAML 1.2 spec](http://www.yaml.org/spec/1.2/spec.html).
To get a feel for how it can be used, see the [Tutorial](https://github.com/jbeder/yaml-cpp/wiki/Tutorial) or [How to Emit YAML](https://github.com/jbeder/yaml-cpp/wiki/How-To-Emit-YAML). For the old API (version < 0.5.0), see [How To Parse A Document](https://github.com/jbeder/yaml-cpp/wiki/How-To-Parse-A-Document-(Old-API)). ## Usage
# Problems? # See [Tutorial](https://github.com/jbeder/yaml-cpp/wiki/Tutorial) and [How to Emit YAML](https://github.com/jbeder/yaml-cpp/wiki/How-To-Emit-YAML) for reference. For the old API (until 0.5.0), see [How To Parse A Document](https://github.com/jbeder/yaml-cpp/wiki/How-To-Parse-A-Document-(Old-API)).
## Any Problems?
If you find a bug, post an [issue](https://github.com/jbeder/yaml-cpp/issues)! If you have questions about how to use yaml-cpp, please post it on http://stackoverflow.com and tag it [`yaml-cpp`](http://stackoverflow.com/questions/tagged/yaml-cpp). If you find a bug, post an [issue](https://github.com/jbeder/yaml-cpp/issues)! If you have questions about how to use yaml-cpp, please post it on http://stackoverflow.com and tag it [`yaml-cpp`](http://stackoverflow.com/questions/tagged/yaml-cpp).
# How to Build # ## How to Build
yaml-cpp uses [CMake](http://www.cmake.org) to support cross-platform building. The basic steps to build are: `yaml-cpp` uses [CMake](http://www.cmake.org) to support cross-platform building. Install [CMake](http://www.cmake.org) _(Resources -> Download)_ before proceeding. The basic steps to build are:
1. Download and install [CMake](http://www.cmake.org) (Resources -> Download). **Note:** If you don't use the provided installer for your platform, make sure that you add `CMake`'s bin folder to your path.
**Note:** If you don't use the provided installer for your platform, make sure that you add CMake's bin folder to your path. #### 1. Navigate into the source directory, create build folder and run `CMake`:
2. Navigate into the source directory, and type: ```sh
```
mkdir build mkdir build
cd build cd build
cmake [-G generator] [-YAML_BUILD_SHARED_LIBS=on|OFF] ..
``` ```
3. Run CMake. The basic syntax is: * The `generator` option is the build system you'd like to use. Run `cmake` without arguments to see a full list of available generators.
* On Windows, you might use "Visual Studio 12 2013" (VS 2013 32-bits), or "Visual Studio 14 2015 Win64" (VS 2015 64-bits).
* On OS X, you might use "Xcode".
* On a UNIX-like system, omit the option (for a Makefile).
``` * `yaml-cpp` builds a static library by default, you may want to build a shared library by specifying `-YAML_BUILD_SHARED_LIBS=ON`.
cmake [-G generator] [-DYAML_BUILD_SHARED_LIBS=ON|OFF] ..
```
* The `generator` is whatever type of build system you'd like to use. To see a full list of generators on your platform, just run `cmake` (with no arguments). For example:
* On Windows, you might use "Visual Studio 12 2013" to generate a Visual Studio 2013 solution or "Visual Studio 14 2015 Win64" to generate a 64-bit Visual Studio 2015 solution.
* On OS X, you might use "Xcode" to generate an Xcode project
* On a UNIX-y system, simply omit the option to generate a makefile
* yaml-cpp defaults to building a static library, but you may build a shared library by specifying `-DYAML_BUILD_SHARED_LIBS=ON`.
* For more options on customizing the build, see the [CMakeLists.txt](https://github.com/jbeder/yaml-cpp/blob/master/CMakeLists.txt) file. * For more options on customizing the build, see the [CMakeLists.txt](https://github.com/jbeder/yaml-cpp/blob/master/CMakeLists.txt) file.
4. Build it! #### 2. Build it!
* The command you'll need to run depends on the generator you chose earlier.
5. To clean up, just remove the `build` directory. **Note:** To clean up, just remove the `build` directory.
# Recent Release # ## Recent Releases
[yaml-cpp 0.6.0](https://github.com/jbeder/yaml-cpp/releases/tag/yaml-cpp-0.6.0) has been released! This release requires C++11, and no longer depends on Boost. [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.3.0](https://github.com/jbeder/yaml-cpp/releases/tag/release-0.3.0) is still available if you want the old API. [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.
@@ -59,3 +55,4 @@ The autogenerated API reference is hosted on [CodeDocs](https://codedocs.xyz/jbe
The following projects are not officially supported: The following projects are not officially supported:
- [Qt wrapper](https://gist.github.com/brcha/d392b2fe5f1e427cc8a6) - [Qt wrapper](https://gist.github.com/brcha/d392b2fe5f1e427cc8a6)
- [UnrealEngine Wrapper](https://github.com/jwindgassen/UnrealYAML)

View File

@@ -65,7 +65,7 @@ const char* const ZERO_INDENT_IN_BLOCK =
const char* const CHAR_IN_BLOCK = "unexpected character in block scalar"; const char* const CHAR_IN_BLOCK = "unexpected character in block scalar";
const char* const AMBIGUOUS_ANCHOR = const char* const AMBIGUOUS_ANCHOR =
"cannot assign the same alias to multiple nodes"; "cannot assign the same alias to multiple nodes";
const char* const UNKNOWN_ANCHOR = "the referenced anchor is not defined"; const char* const UNKNOWN_ANCHOR = "the referenced anchor is not defined: ";
const char* const INVALID_NODE = const char* const INVALID_NODE =
"invalid node; this may result from using a map iterator as a sequence " "invalid node; this may result from using a map iterator as a sequence "

View File

@@ -169,7 +169,7 @@ class node {
using nodes = std::set<node*, less>; using nodes = std::set<node*, less>;
nodes m_dependencies; nodes m_dependencies;
size_t m_index; size_t m_index;
static std::atomic<size_t> m_amount; static YAML_CPP_API std::atomic<size_t> m_amount;
}; };
} // namespace detail } // namespace detail
} // namespace YAML } // namespace YAML

View File

@@ -42,7 +42,7 @@ inline Node::Node(const detail::iterator_value& rhs)
m_pMemory(rhs.m_pMemory), m_pMemory(rhs.m_pMemory),
m_pNode(rhs.m_pNode) {} m_pNode(rhs.m_pNode) {}
inline Node::Node(const Node& rhs) = default; inline Node::Node(const Node&) = default;
inline Node::Node(Zombie) inline Node::Node(Zombie)
: m_isValid(false), m_invalidKey{}, m_pMemory{}, m_pNode(nullptr) {} : m_isValid(false), m_invalidKey{}, m_pMemory{}, m_pNode(nullptr) {}

View File

@@ -15,6 +15,9 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
// Assert in place so gcc + libc++ combination properly builds
static_assert(std::is_constructible<YAML::Node, const YAML::Node&>::value, "Node must be copy constructable");
namespace YAML { namespace YAML {
namespace detail { namespace detail {
struct iterator_value : public Node, std::pair<Node, Node> { struct iterator_value : public Node, std::pair<Node, Node> {

View File

@@ -79,7 +79,7 @@ std::vector<unsigned char> DecodeBase64(const std::string &input) {
// skip newlines // skip newlines
continue; continue;
} }
unsigned char d = decoding[static_cast<unsigned>(input[i])]; unsigned char d = decoding[static_cast<unsigned char>(input[i])];
if (d == 255) if (d == 255)
return ret_type(); return ret_type();

View File

@@ -13,7 +13,7 @@
namespace YAML { namespace YAML {
namespace detail { namespace detail {
std::atomic<size_t> node::m_amount{0}; YAML_CPP_API std::atomic<size_t> node::m_amount{0};
const std::string& node_data::empty_scalar() { const std::string& node_data::empty_scalar() {
static const std::string svalue; static const std::string svalue;

View File

@@ -424,8 +424,11 @@ anchor_t SingleDocParser::RegisterAnchor(const std::string& name) {
anchor_t SingleDocParser::LookupAnchor(const Mark& mark, anchor_t SingleDocParser::LookupAnchor(const Mark& mark,
const std::string& name) const { const std::string& name) const {
auto it = m_anchors.find(name); auto it = m_anchors.find(name);
if (it == m_anchors.end()) if (it == m_anchors.end()) {
throw ParserException(mark, ErrorMsg::UNKNOWN_ANCHOR); std::stringstream ss;
ss << ErrorMsg::UNKNOWN_ANCHOR << name;
throw ParserException(mark, ss.str());
}
return it->second; return it->second;
} }

14
test/binary_test.cpp Normal file
View File

@@ -0,0 +1,14 @@
#include "gtest/gtest.h"
#include <yaml-cpp/binary.h>
TEST(BinaryTest, DecodingSimple) {
std::string input{90, 71, 86, 104, 90, 71, 74, 108, 90, 87, 89, 61};
const std::vector<unsigned char> &result = YAML::DecodeBase64(input);
EXPECT_EQ(std::string(result.begin(), result.end()), "deadbeef");
}
TEST(BinaryTest, DecodingNoCrashOnNegative) {
std::string input{-58, -1, -99, 109};
const std::vector<unsigned char> &result = YAML::DecodeBase64(input);
EXPECT_TRUE(result.empty());
}

View File

@@ -1,7 +1,7 @@
# Note: CMake support is community-based. The maintainers do not use CMake # Note: CMake support is community-based. The maintainers do not use CMake
# internally. # internally.
cmake_minimum_required(VERSION 2.8.8) cmake_minimum_required(VERSION 2.9)
if (POLICY CMP0048) if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW) cmake_policy(SET CMP0048 NEW)

View File

@@ -42,7 +42,7 @@ else()
cmake_policy(SET CMP0048 NEW) cmake_policy(SET CMP0048 NEW)
project(gmock VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C) project(gmock VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C)
endif() endif()
cmake_minimum_required(VERSION 2.6.4) cmake_minimum_required(VERSION 2.9)
if (COMMAND set_up_hermetic_build) if (COMMAND set_up_hermetic_build)
set_up_hermetic_build() set_up_hermetic_build()

View File

@@ -53,7 +53,7 @@ else()
cmake_policy(SET CMP0048 NEW) cmake_policy(SET CMP0048 NEW)
project(gtest VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C) project(gtest VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C)
endif() endif()
cmake_minimum_required(VERSION 2.6.4) cmake_minimum_required(VERSION 2.9)
if (POLICY CMP0063) # Visibility if (POLICY CMP0063) # Visibility
cmake_policy(SET CMP0063 NEW) cmake_policy(SET CMP0063 NEW)

View File

@@ -5,19 +5,6 @@
#include "yaml-cpp/eventhandler.h" #include "yaml-cpp/eventhandler.h"
#include "yaml-cpp/yaml.h" // IWYU pragma: keep #include "yaml-cpp/yaml.h" // IWYU pragma: keep
struct Params {
bool hasFile;
std::string fileName;
};
Params ParseArgs(int argc, char** argv) {
Params p;
std::vector<std::string> args(argv + 1, argv + argc);
return p;
}
class NullEventHandler : public YAML::EventHandler { class NullEventHandler : public YAML::EventHandler {
public: public:
void OnDocumentStart(const YAML::Mark&) override {} void OnDocumentStart(const YAML::Mark&) override {}
@@ -47,8 +34,6 @@ void parse(std::istream& input) {
} }
int main(int argc, char** argv) { int main(int argc, char** argv) {
Params p = ParseArgs(argc, argv);
if (argc > 1) { if (argc > 1) {
std::ifstream fin; std::ifstream fin;
fin.open(argv[1]); fin.open(argv[1]);

View File

@@ -1,7 +1,7 @@
prefix=@CMAKE_INSTALL_PREFIX@ prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix} exec_prefix=${prefix}
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ libdir=@CMAKE_INSTALL_FULL_LIBDIR@
Name: Yaml-cpp Name: Yaml-cpp
Description: A YAML parser and emitter for C++ Description: A YAML parser and emitter for C++