rapidyaml  0.16.0
parseandemitYAML,anddoitfast
Quickstart

Example code for every feature. More...

Modules

 Overview
 
 Using csubstr
 
 Parsing
 
 Tree
 
 Serialization
 
 Emitting
 
 JSON
 
 YAML styles
 
 YAML anchors
 
 YAML tags
 
 YAML documents
 
 Errors and error handlers
 
 Allocators
 
 Static trees
 
 Sample helpers
 Helper utilities used in the quickstart.
 

Detailed Description

Example code for every feature.

Best seen online at https://rapidyaml.readthedocs.io/v0.16.0/doxygen/.

This file does a quick tour of ryml. It has multiple self-contained and well-commented samples that illustrate how to use ryml, and how it works.

Although this is not a unit test, the samples are written as a sequence of actions and predicate checks to better convey what is the expected result at any stage. And to ensure the code here is correct and up to date, it's also run as part of the CI tests.

If something is unclear, please open an issue or send a pull request at https://github.com/biojppm/rapidyaml . If you have an issue while using ryml, it is also encouraged to try to reproduce the issue here, or look first through the relevant section.

Happy ryml'ing!

Note on use of raw strings

This sample uses multiline C strings instead of C++11 R"(raw strings)" because the doxygen parser is badly broken when handling raw strings.

Some guidance on building

The directories that exist side-by-side with this file contain several examples on how to build this with cmake, such that you can hit the ground running. See the relevant section of the main README for an overview of the different choices. I suggest starting first with the add_subdirectory example, treating it just like any other self-contained cmake project.

Or very quickly, to build and run this sample on your PC, start by creating this CMakeLists.txt:

1 cmake_minimum_required(VERSION 3.13)
2 project(ryml-quickstart LANGUAGES CXX)
3 include(FetchContent)
4 FetchContent_Declare(ryml
5  GIT_REPOSITORY https://github.com/biojppm/rapidyaml.git
6  GIT_TAG v0.16.0
7 )
8 FetchContent_MakeAvailable(ryml)
9 add_executable(ryml-quickstart ${ryml_SOURCE_DIR}/samples/quickstart.cpp)
10 target_link_libraries(ryml-quickstart ryml::ryml)
11 add_custom_target(run ryml-quickstart
12  COMMAND $<TARGET_FILE:ryml-quickstart>
13  DEPENDS ryml-quickstart
14  COMMENT "running: $<TARGET_FILE:ryml-quickstart>")

Now run the following commands in the same folder:

1 # configure the project
2 cmake -B build
3 # build and run
4 cmake --build build --target run -j
5 # optionally, open in your IDE
6 cmake --open build