diff --git a/.reuse/templates/fkYAML.commented.jinja2 b/.reuse/templates/fkYAML.commented.jinja2
index 1466db40..282e4002 100644
--- a/.reuse/templates/fkYAML.commented.jinja2
+++ b/.reuse/templates/fkYAML.commented.jinja2
@@ -1,6 +1,6 @@
/// _______ __ __ __ _____ __ __ __
/// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library
-/// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+/// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
/// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
///
{% for copyright_line in copyright_lines %}
diff --git a/.reuse/templates/fkYAML_support.jinja2 b/.reuse/templates/fkYAML_support.jinja2
index c9385265..752d95ec 100644
--- a/.reuse/templates/fkYAML_support.jinja2
+++ b/.reuse/templates/fkYAML_support.jinja2
@@ -1,6 +1,6 @@
_______ __ __ __ _____ __ __ __
| __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-| __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+| __| _ < \_ _/| ___ | _ | |___ version 0.3.12
|__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
{% for copyright_line in copyright_lines %}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c96e949c..019850d4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,21 @@
# Changelog
+## [v0.3.12](https://github.com/fktn-k/fkYAML/releases/tag/v0.3.12) (2024-09-21)
+
+[Full Changelog](https://github.com/fktn-k/fkYAML/compare/v0.3.11...v0.3.12)
+
+- Parse +.inf as the positive float infinity [\#393](https://github.com/fktn-k/fkYAML/pull/393) ([fktn-k](https://github.com/fktn-k))
+- Use \_MSVC\_LANG macro when compiled with MSVC for C++ standard detection [\#392](https://github.com/fktn-k/fkYAML/pull/392) ([fktn-k](https://github.com/fktn-k))
+- Fix detecting invalid contents of block scalar headers [\#387](https://github.com/fktn-k/fkYAML/pull/387) ([fktn-k](https://github.com/fktn-k))
+
+- Use likely/unlikely if available [\#395](https://github.com/fktn-k/fkYAML/pull/395) ([fktn-k](https://github.com/fktn-k))
+- Reduce string copies in parse [\#394](https://github.com/fktn-k/fkYAML/pull/394) ([fktn-k](https://github.com/fktn-k))
+- Improve conversion from scalars to native types [\#391](https://github.com/fktn-k/fkYAML/pull/391) ([fktn-k](https://github.com/fktn-k))
+- Refactor lexical analysis [\#390](https://github.com/fktn-k/fkYAML/pull/390) ([fktn-k](https://github.com/fktn-k))
+- Refactor node attributes management [\#389](https://github.com/fktn-k/fkYAML/pull/389) ([fktn-k](https://github.com/fktn-k))
+- Add node\_type/yaml\_version\_type enum class APIs [\#388](https://github.com/fktn-k/fkYAML/pull/388) ([fktn-k](https://github.com/fktn-k))
+- Improve UTF encoding detection [\#386](https://github.com/fktn-k/fkYAML/pull/386) ([fktn-k](https://github.com/fktn-k))
+
## [v0.3.11](https://github.com/fktn-k/fkYAML/releases/tag/v0.3.11) (2024-08-24)
[Full Changelog](https://github.com/fktn-k/fkYAML/compare/v0.3.10...v0.3.11)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 11c7e35a..f98ab363 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.8)
project(
fkYAML
- VERSION 0.3.11
+ VERSION 0.3.12
LANGUAGES CXX)
#############################################################
diff --git a/Makefile b/Makefile
index 6618aa9a..185cf323 100644
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,7 @@ TOOL_SRCS = $(shell find tool -type f -name '*.cpp' | sort)
# target version definition
TARGET_MAJOR_VERSION := 0
TARGET_MINOR_VERSION := 3
-TARGET_PATCH_VERSION := 11
+TARGET_PATCH_VERSION := 12
TARGET_VERSION_FULL := $(TARGET_MAJOR_VERSION).$(TARGET_MINOR_VERSION).$(TARGET_PATCH_VERSION)
VERSION_MACRO_FILE := include/fkYAML/detail/macros/version_macros.hpp
@@ -173,15 +173,21 @@ html-coverage: lcov-coverage
# Benchmark #
#################
-bm-debug:
+build-bm-debug:
cmake -B build_bm_debug -S . -DCMAKE_BUILD_TYPE=Debug -DFK_YAML_RUN_BENCHMARK=ON
cmake --build build_bm_debug --config Debug
- ./build_bm_debug/tool/benchmark/benchmarker ./tool/benchmark/macos.yml > ./tool/benchmark/result_debug.log
-bm-release:
+bm-debug: build-bm-debug
+ cmake -B build_bm_debug -S . -DCMAKE_BUILD_TYPE=Debug -DFK_YAML_RUN_BENCHMARK=ON
+ cmake --build build_bm_debug --config Debug
+ ./build_bm_debug/tool/benchmark/benchmarker ./tool/benchmark/macos.yml
+
+build-bm-release:
cmake -B build_bm_release -S . -DCMAKE_BUILD_TYPE=Release -DFK_YAML_RUN_BENCHMARK=ON
cmake --build build_bm_release --config Release
- ./build_bm_release/tool/benchmark/benchmarker ./tool/benchmark/macos.yml > ./tool/benchmark/result_release.log
+
+bm-release: build-bm-release
+ ./build_bm_release/tool/benchmark/benchmarker ./tool/benchmark/macos.yml
###################
# Maintenance #
diff --git a/README.md b/README.md
index 612e4ff9..4e8e3fa2 100644
--- a/README.md
+++ b/README.md
@@ -92,13 +92,13 @@ On an AMD Ryzen 7 5800H @3.20GHz with g++11.4.0 in Ubuntu22.04 (WSL2), fkYAML pa
| Benchmark | Release (MB/s) |
| ---------------------------------- | -------------- |
-| fkYAML | 40.491 |
+| fkYAML | 41.051 |
| libfyaml | 31.110 |
| rapidyaml
(with mutable buff) | 147.221 |
| rapidyaml
(with immutable buff) | 144.904 |
| yaml-cpp | 7.397 |
-Although [rapidyaml](https://github.com/biojppm/rapidyaml) is in general 4x faster than fkYAML as it focuses on high performance, fkYAML is 30% faster than [libfyaml](https://github.com/pantoniou/libfyaml) and also 5.4x faster than [yaml-cpp](https://github.com/jbeder/yaml-cpp).
+Although [rapidyaml](https://github.com/biojppm/rapidyaml) is in general 4x faster than fkYAML as it focuses on high performance, fkYAML is 30% faster than [libfyaml](https://github.com/pantoniou/libfyaml) and also 5.5x faster than [yaml-cpp](https://github.com/jbeder/yaml-cpp).
Note that, since fkYAML deserializes scalars into native booleans or integers during the parsing, the performance could be more faster in some real use cases.
## Supported compilers
diff --git a/docs/examples/ex_basic_node_add_anchor_name.cpp b/docs/examples/ex_basic_node_add_anchor_name.cpp
index 1dc257d3..1333fa80 100644
--- a/docs/examples/ex_basic_node_add_anchor_name.cpp
+++ b/docs/examples/ex_basic_node_add_anchor_name.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_add_tag_name.cpp b/docs/examples/ex_basic_node_add_tag_name.cpp
index 28bf5403..2ddfec7f 100644
--- a/docs/examples/ex_basic_node_add_tag_name.cpp
+++ b/docs/examples/ex_basic_node_add_tag_name.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_alias_of.cpp b/docs/examples/ex_basic_node_alias_of.cpp
index 21529e9b..ae7ae033 100644
--- a/docs/examples/ex_basic_node_alias_of.cpp
+++ b/docs/examples/ex_basic_node_alias_of.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_at_basic_node.cpp b/docs/examples/ex_basic_node_at_basic_node.cpp
index d7014840..18e34588 100644
--- a/docs/examples/ex_basic_node_at_basic_node.cpp
+++ b/docs/examples/ex_basic_node_at_basic_node.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_at_compatible_type.cpp b/docs/examples/ex_basic_node_at_compatible_type.cpp
index 3934e055..5646ba09 100644
--- a/docs/examples/ex_basic_node_at_compatible_type.cpp
+++ b/docs/examples/ex_basic_node_at_compatible_type.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_begin.cpp b/docs/examples/ex_basic_node_begin.cpp
index 496c43a0..77b25815 100644
--- a/docs/examples/ex_basic_node_begin.cpp
+++ b/docs/examples/ex_basic_node_begin.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_boolean_type.cpp b/docs/examples/ex_basic_node_boolean_type.cpp
index 5a79199c..7163baad 100644
--- a/docs/examples/ex_basic_node_boolean_type.cpp
+++ b/docs/examples/ex_basic_node_boolean_type.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_const_iterator.cpp b/docs/examples/ex_basic_node_const_iterator.cpp
index 98316b59..a5915cfc 100644
--- a/docs/examples/ex_basic_node_const_iterator.cpp
+++ b/docs/examples/ex_basic_node_const_iterator.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_constructor_1.cpp b/docs/examples/ex_basic_node_constructor_1.cpp
index bfbafe92..00811c2d 100644
--- a/docs/examples/ex_basic_node_constructor_1.cpp
+++ b/docs/examples/ex_basic_node_constructor_1.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_constructor_2.cpp b/docs/examples/ex_basic_node_constructor_2.cpp
index d25bf1cd..1f45fb53 100644
--- a/docs/examples/ex_basic_node_constructor_2.cpp
+++ b/docs/examples/ex_basic_node_constructor_2.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
@@ -10,7 +10,7 @@
#include
int main() {
- fkyaml::node n(fkyaml::node::node_t::INTEGER);
+ fkyaml::node n(fkyaml::node_type::INTEGER);
std::cout << n << std::endl;
return 0;
}
diff --git a/docs/examples/ex_basic_node_constructor_3.cpp b/docs/examples/ex_basic_node_constructor_3.cpp
index 4ebc35f3..9c9d45ec 100644
--- a/docs/examples/ex_basic_node_constructor_3.cpp
+++ b/docs/examples/ex_basic_node_constructor_3.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
@@ -10,8 +10,7 @@
#include
int main() {
- fkyaml::node n(fkyaml::node::node_t::BOOLEAN);
- fkyaml::node n2(n);
+ fkyaml::node n(fkyaml::node::node_t::INTEGER);
std::cout << n << std::endl;
return 0;
}
diff --git a/docs/examples/ex_basic_node_constructor_3.output b/docs/examples/ex_basic_node_constructor_3.output
index c508d536..573541ac 100644
--- a/docs/examples/ex_basic_node_constructor_3.output
+++ b/docs/examples/ex_basic_node_constructor_3.output
@@ -1 +1 @@
-false
+0
diff --git a/docs/examples/ex_basic_node_constructor_4.cpp b/docs/examples/ex_basic_node_constructor_4.cpp
index 4ebc35f3..614eb52b 100644
--- a/docs/examples/ex_basic_node_constructor_4.cpp
+++ b/docs/examples/ex_basic_node_constructor_4.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
@@ -12,6 +12,6 @@
int main() {
fkyaml::node n(fkyaml::node::node_t::BOOLEAN);
fkyaml::node n2(n);
- std::cout << n << std::endl;
+ std::cout << n2 << std::endl;
return 0;
}
diff --git a/docs/examples/ex_basic_node_constructor_5.cpp b/docs/examples/ex_basic_node_constructor_5.cpp
index aac95517..1eaef65c 100644
--- a/docs/examples/ex_basic_node_constructor_5.cpp
+++ b/docs/examples/ex_basic_node_constructor_5.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
@@ -10,8 +10,8 @@
#include
int main() {
- double pi = 3.141592;
- fkyaml::node n = pi;
- std::cout << n << std::endl;
+ fkyaml::node n(fkyaml::node::node_t::BOOLEAN);
+ fkyaml::node n2(std::move(n));
+ std::cout << n2 << std::endl;
return 0;
}
diff --git a/docs/examples/ex_basic_node_constructor_5.output b/docs/examples/ex_basic_node_constructor_5.output
index 41bec393..c508d536 100644
--- a/docs/examples/ex_basic_node_constructor_5.output
+++ b/docs/examples/ex_basic_node_constructor_5.output
@@ -1 +1 @@
-3.14159
+false
diff --git a/docs/examples/ex_basic_node_constructor_6.cpp b/docs/examples/ex_basic_node_constructor_6.cpp
index 4caccc3d..648b375b 100644
--- a/docs/examples/ex_basic_node_constructor_6.cpp
+++ b/docs/examples/ex_basic_node_constructor_6.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
@@ -10,7 +10,8 @@
#include
int main() {
- fkyaml::node n({true, false});
+ double pi = 3.141592;
+ fkyaml::node n = pi;
std::cout << n << std::endl;
return 0;
}
diff --git a/docs/examples/ex_basic_node_constructor_6.output b/docs/examples/ex_basic_node_constructor_6.output
index 70c48721..41bec393 100644
--- a/docs/examples/ex_basic_node_constructor_6.output
+++ b/docs/examples/ex_basic_node_constructor_6.output
@@ -1,3 +1 @@
-- true
-- false
-
+3.14159
diff --git a/docs/examples/ex_basic_node_constructor_7.cpp b/docs/examples/ex_basic_node_constructor_7.cpp
index 528b68fa..d32dd156 100644
--- a/docs/examples/ex_basic_node_constructor_7.cpp
+++ b/docs/examples/ex_basic_node_constructor_7.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
@@ -10,10 +10,7 @@
#include
int main() {
- fkyaml::node n = {true, false};
+ fkyaml::node n({true, false});
std::cout << n << std::endl;
-
- fkyaml::node n2 = {{"foo", 1024}};
- std::cout << n2 << std::endl;
return 0;
}
diff --git a/docs/examples/ex_basic_node_constructor_7.output b/docs/examples/ex_basic_node_constructor_7.output
index ee41427a..70c48721 100644
--- a/docs/examples/ex_basic_node_constructor_7.output
+++ b/docs/examples/ex_basic_node_constructor_7.output
@@ -1,5 +1,3 @@
- true
- false
-foo: 1024
-
diff --git a/docs/examples/ex_basic_node_constructor_8.cpp b/docs/examples/ex_basic_node_constructor_8.cpp
new file mode 100644
index 00000000..0f2fcfa6
--- /dev/null
+++ b/docs/examples/ex_basic_node_constructor_8.cpp
@@ -0,0 +1,19 @@
+// _______ __ __ __ _____ __ __ __
+// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
+// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
+//
+// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
+// SPDX-License-Identifier: MIT
+
+#include
+#include
+
+int main() {
+ fkyaml::node n = {true, false};
+ std::cout << n << std::endl;
+
+ fkyaml::node n2 = {{"foo", 1024}};
+ std::cout << n2 << std::endl;
+ return 0;
+}
diff --git a/docs/examples/ex_basic_node_constructor_8.output b/docs/examples/ex_basic_node_constructor_8.output
new file mode 100644
index 00000000..ee41427a
--- /dev/null
+++ b/docs/examples/ex_basic_node_constructor_8.output
@@ -0,0 +1,5 @@
+- true
+- false
+
+foo: 1024
+
diff --git a/docs/examples/ex_basic_node_contains.cpp b/docs/examples/ex_basic_node_contains.cpp
index 1c4fa25b..f563d2ef 100644
--- a/docs/examples/ex_basic_node_contains.cpp
+++ b/docs/examples/ex_basic_node_contains.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_copy_assignment_operator.cpp b/docs/examples/ex_basic_node_copy_assignment_operator.cpp
index 4774347c..b1fe6b1d 100644
--- a/docs/examples/ex_basic_node_copy_assignment_operator.cpp
+++ b/docs/examples/ex_basic_node_copy_assignment_operator.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_deserialize_char_array.cpp b/docs/examples/ex_basic_node_deserialize_char_array.cpp
index 100af37f..a4c51913 100644
--- a/docs/examples/ex_basic_node_deserialize_char_array.cpp
+++ b/docs/examples/ex_basic_node_deserialize_char_array.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_deserialize_docs_char_array.cpp b/docs/examples/ex_basic_node_deserialize_docs_char_array.cpp
index 09339275..bd2d608e 100644
--- a/docs/examples/ex_basic_node_deserialize_docs_char_array.cpp
+++ b/docs/examples/ex_basic_node_deserialize_docs_char_array.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_deserialize_docs_file_pointer.cpp b/docs/examples/ex_basic_node_deserialize_docs_file_pointer.cpp
index 0c5aa469..afb70366 100644
--- a/docs/examples/ex_basic_node_deserialize_docs_file_pointer.cpp
+++ b/docs/examples/ex_basic_node_deserialize_docs_file_pointer.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_deserialize_docs_iterators.cpp b/docs/examples/ex_basic_node_deserialize_docs_iterators.cpp
index 7c461335..2bdb73bb 100644
--- a/docs/examples/ex_basic_node_deserialize_docs_iterators.cpp
+++ b/docs/examples/ex_basic_node_deserialize_docs_iterators.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_deserialize_docs_string.cpp b/docs/examples/ex_basic_node_deserialize_docs_string.cpp
index 2a1d0b17..a8ad6fc1 100644
--- a/docs/examples/ex_basic_node_deserialize_docs_string.cpp
+++ b/docs/examples/ex_basic_node_deserialize_docs_string.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_deserialize_file_pointer.cpp b/docs/examples/ex_basic_node_deserialize_file_pointer.cpp
index 39f9ed54..a41d84d5 100644
--- a/docs/examples/ex_basic_node_deserialize_file_pointer.cpp
+++ b/docs/examples/ex_basic_node_deserialize_file_pointer.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_deserialize_iterators.cpp b/docs/examples/ex_basic_node_deserialize_iterators.cpp
index 73f3cdba..28f9b1ec 100644
--- a/docs/examples/ex_basic_node_deserialize_iterators.cpp
+++ b/docs/examples/ex_basic_node_deserialize_iterators.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_deserialize_string.cpp b/docs/examples/ex_basic_node_deserialize_string.cpp
index 6bdff01a..ea7d0537 100644
--- a/docs/examples/ex_basic_node_deserialize_string.cpp
+++ b/docs/examples/ex_basic_node_deserialize_string.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_empty.cpp b/docs/examples/ex_basic_node_empty.cpp
index 25368707..872d0704 100644
--- a/docs/examples/ex_basic_node_empty.cpp
+++ b/docs/examples/ex_basic_node_empty.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_end.cpp b/docs/examples/ex_basic_node_end.cpp
index 01dad692..f71e1577 100644
--- a/docs/examples/ex_basic_node_end.cpp
+++ b/docs/examples/ex_basic_node_end.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_extraction_operator.cpp b/docs/examples/ex_basic_node_extraction_operator.cpp
index 6e1a633c..798bd549 100644
--- a/docs/examples/ex_basic_node_extraction_operator.cpp
+++ b/docs/examples/ex_basic_node_extraction_operator.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_float_number_type.cpp b/docs/examples/ex_basic_node_float_number_type.cpp
index 99658c9b..5ceff085 100644
--- a/docs/examples/ex_basic_node_float_number_type.cpp
+++ b/docs/examples/ex_basic_node_float_number_type.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_get_anchor_name.cpp b/docs/examples/ex_basic_node_get_anchor_name.cpp
index f9864edf..60f83c83 100644
--- a/docs/examples/ex_basic_node_get_anchor_name.cpp
+++ b/docs/examples/ex_basic_node_get_anchor_name.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_get_tag_name.cpp b/docs/examples/ex_basic_node_get_tag_name.cpp
index 7571a1d8..c97af9d0 100644
--- a/docs/examples/ex_basic_node_get_tag_name.cpp
+++ b/docs/examples/ex_basic_node_get_tag_name.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_get_type.cpp b/docs/examples/ex_basic_node_get_type.cpp
new file mode 100644
index 00000000..eaaa3b91
--- /dev/null
+++ b/docs/examples/ex_basic_node_get_type.cpp
@@ -0,0 +1,34 @@
+// _______ __ __ __ _____ __ __ __
+// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
+// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
+//
+// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
+// SPDX-License-Identifier: MIT
+
+#include
+#include
+#include
+
+int main() {
+ // create YAML nodes.
+ fkyaml::node sequence_node = {1, 2, 3};
+ fkyaml::node mapping_node = {{"foo", true}, {"bar", false}};
+ fkyaml::node null_node;
+ fkyaml::node boolean_node = true;
+ fkyaml::node integer_node = 256;
+ fkyaml::node float_node = 3.14;
+ fkyaml::node string_node = "Hello, world!";
+
+ // query node value types by calling get_type().
+ std::cout << std::boolalpha;
+ std::cout << (sequence_node.get_type() == fkyaml::node_type::SEQUENCE) << std::endl;
+ std::cout << (mapping_node.get_type() == fkyaml::node_type::MAPPING) << std::endl;
+ std::cout << (null_node.get_type() == fkyaml::node_type::NULL_OBJECT) << std::endl;
+ std::cout << (boolean_node.get_type() == fkyaml::node_type::BOOLEAN) << std::endl;
+ std::cout << (integer_node.get_type() == fkyaml::node_type::INTEGER) << std::endl;
+ std::cout << (float_node.get_type() == fkyaml::node_type::FLOAT) << std::endl;
+ std::cout << (string_node.get_type() == fkyaml::node_type::STRING) << std::endl;
+
+ return 0;
+}
diff --git a/docs/examples/ex_basic_node_get_type.output b/docs/examples/ex_basic_node_get_type.output
new file mode 100644
index 00000000..814ccfee
--- /dev/null
+++ b/docs/examples/ex_basic_node_get_type.output
@@ -0,0 +1,7 @@
+true
+true
+true
+true
+true
+true
+true
diff --git a/docs/examples/ex_basic_node_get_value.cpp b/docs/examples/ex_basic_node_get_value.cpp
index c58b57a3..fcfec222 100644
--- a/docs/examples/ex_basic_node_get_value.cpp
+++ b/docs/examples/ex_basic_node_get_value.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_get_value.output b/docs/examples/ex_basic_node_get_value.output
index 0d4885da..1f00b91f 100644
--- a/docs/examples/ex_basic_node_get_value.output
+++ b/docs/examples/ex_basic_node_get_value.output
@@ -1,3 +1,3 @@
123
foo
-type_error: The target node value type is not float number type. type=string
+type_error: The target node value type is not float number type. type=STRING
diff --git a/docs/examples/ex_basic_node_get_value_ref.cpp b/docs/examples/ex_basic_node_get_value_ref.cpp
index 9ef2cb0c..156409e1 100644
--- a/docs/examples/ex_basic_node_get_value_ref.cpp
+++ b/docs/examples/ex_basic_node_get_value_ref.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_get_value_ref.output b/docs/examples/ex_basic_node_get_value_ref.output
index 9d8e9e9b..5b77725d 100644
--- a/docs/examples/ex_basic_node_get_value_ref.output
+++ b/docs/examples/ex_basic_node_get_value_ref.output
@@ -1,3 +1,3 @@
123
123
-type_error: The node value is not a mapping. type=integer
+type_error: The node value is not a mapping. type=INTEGER
diff --git a/docs/examples/ex_basic_node_get_yaml_version.cpp b/docs/examples/ex_basic_node_get_yaml_version.cpp
index 73108098..f3ab133a 100644
--- a/docs/examples/ex_basic_node_get_yaml_version.cpp
+++ b/docs/examples/ex_basic_node_get_yaml_version.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_get_yaml_version_type.cpp b/docs/examples/ex_basic_node_get_yaml_version_type.cpp
new file mode 100644
index 00000000..4b04c095
--- /dev/null
+++ b/docs/examples/ex_basic_node_get_yaml_version_type.cpp
@@ -0,0 +1,19 @@
+// _______ __ __ __ _____ __ __ __
+// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
+// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
+//
+// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
+// SPDX-License-Identifier: MIT
+
+#include
+#include
+#include
+
+int main() {
+ // A `fkyaml::node` object has `yaml_version_t::VER_1_2` by default.
+ fkyaml::node n;
+ std::cout << std::boolalpha << (n.get_yaml_version_type() == fkyaml::yaml_version_type::VERSION_1_2) << std::endl;
+
+ return 0;
+}
diff --git a/docs/examples/ex_basic_node_get_yaml_version_type.output b/docs/examples/ex_basic_node_get_yaml_version_type.output
new file mode 100644
index 00000000..27ba77dd
--- /dev/null
+++ b/docs/examples/ex_basic_node_get_yaml_version_type.output
@@ -0,0 +1 @@
+true
diff --git a/docs/examples/ex_basic_node_has_anchor_name.cpp b/docs/examples/ex_basic_node_has_anchor_name.cpp
index 361b0714..7ec66e0a 100644
--- a/docs/examples/ex_basic_node_has_anchor_name.cpp
+++ b/docs/examples/ex_basic_node_has_anchor_name.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_has_tag_name.cpp b/docs/examples/ex_basic_node_has_tag_name.cpp
index e958bbe6..18cc5185 100644
--- a/docs/examples/ex_basic_node_has_tag_name.cpp
+++ b/docs/examples/ex_basic_node_has_tag_name.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_insertion_operator.cpp b/docs/examples/ex_basic_node_insertion_operator.cpp
index b8e10bd6..334c57d2 100644
--- a/docs/examples/ex_basic_node_insertion_operator.cpp
+++ b/docs/examples/ex_basic_node_insertion_operator.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_integer_type.cpp b/docs/examples/ex_basic_node_integer_type.cpp
index e276afa4..72416f3d 100644
--- a/docs/examples/ex_basic_node_integer_type.cpp
+++ b/docs/examples/ex_basic_node_integer_type.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_is_alias.cpp b/docs/examples/ex_basic_node_is_alias.cpp
index 9728f23c..3ef18d67 100644
--- a/docs/examples/ex_basic_node_is_alias.cpp
+++ b/docs/examples/ex_basic_node_is_alias.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_is_anchor.cpp b/docs/examples/ex_basic_node_is_anchor.cpp
index 4ba0470b..fd281ad1 100644
--- a/docs/examples/ex_basic_node_is_anchor.cpp
+++ b/docs/examples/ex_basic_node_is_anchor.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_is_boolean.cpp b/docs/examples/ex_basic_node_is_boolean.cpp
index 4b987a27..7c35939c 100644
--- a/docs/examples/ex_basic_node_is_boolean.cpp
+++ b/docs/examples/ex_basic_node_is_boolean.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_is_float_number.cpp b/docs/examples/ex_basic_node_is_float_number.cpp
index 54ce41b5..22d05204 100644
--- a/docs/examples/ex_basic_node_is_float_number.cpp
+++ b/docs/examples/ex_basic_node_is_float_number.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_is_integer.cpp b/docs/examples/ex_basic_node_is_integer.cpp
index 073a2993..70ad97c3 100644
--- a/docs/examples/ex_basic_node_is_integer.cpp
+++ b/docs/examples/ex_basic_node_is_integer.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_is_mapping.cpp b/docs/examples/ex_basic_node_is_mapping.cpp
index c888c83e..9d8e5346 100644
--- a/docs/examples/ex_basic_node_is_mapping.cpp
+++ b/docs/examples/ex_basic_node_is_mapping.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_is_null.cpp b/docs/examples/ex_basic_node_is_null.cpp
index e4bac289..f53de4e3 100644
--- a/docs/examples/ex_basic_node_is_null.cpp
+++ b/docs/examples/ex_basic_node_is_null.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_is_scalar.cpp b/docs/examples/ex_basic_node_is_scalar.cpp
index fe97d35f..1cf878db 100644
--- a/docs/examples/ex_basic_node_is_scalar.cpp
+++ b/docs/examples/ex_basic_node_is_scalar.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
@@ -18,13 +18,13 @@ int main() {
fkyaml::node float_node = 3.14;
fkyaml::node string_node = "Hello, world!";
- // call type()
+ // check if the nodes are a scalar by calling is_scalar()
std::cout << std::boolalpha;
- std::cout << (null_node.type() == fkyaml::node::node_t::NULL_OBJECT) << std::endl;
- std::cout << (boolean_node.type() == fkyaml::node::node_t::BOOLEAN) << std::endl;
- std::cout << (integer_node.type() == fkyaml::node::node_t::INTEGER) << std::endl;
- std::cout << (float_node.type() == fkyaml::node::node_t::FLOAT_NUMBER) << std::endl;
- std::cout << (string_node.type() == fkyaml::node::node_t::STRING) << std::endl;
+ std::cout << null_node.is_scalar() << std::endl;
+ std::cout << boolean_node.is_scalar() << std::endl;
+ std::cout << integer_node.is_scalar() << std::endl;
+ std::cout << float_node.is_scalar() << std::endl;
+ std::cout << string_node.is_scalar() << std::endl;
return 0;
}
diff --git a/docs/examples/ex_basic_node_is_sequence.cpp b/docs/examples/ex_basic_node_is_sequence.cpp
index 52ef0a7b..a9fbfa6b 100644
--- a/docs/examples/ex_basic_node_is_sequence.cpp
+++ b/docs/examples/ex_basic_node_is_sequence.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_is_string.cpp b/docs/examples/ex_basic_node_is_string.cpp
index 6d1e877a..b9727d4c 100644
--- a/docs/examples/ex_basic_node_is_string.cpp
+++ b/docs/examples/ex_basic_node_is_string.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_iterator.cpp b/docs/examples/ex_basic_node_iterator.cpp
index a4c106c2..731f3f4d 100644
--- a/docs/examples/ex_basic_node_iterator.cpp
+++ b/docs/examples/ex_basic_node_iterator.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_mapping.cpp b/docs/examples/ex_basic_node_mapping.cpp
index 1140337c..65a9ca51 100644
--- a/docs/examples/ex_basic_node_mapping.cpp
+++ b/docs/examples/ex_basic_node_mapping.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_mapping_type.cpp b/docs/examples/ex_basic_node_mapping_type.cpp
index 89229c7d..fc9dac88 100644
--- a/docs/examples/ex_basic_node_mapping_type.cpp
+++ b/docs/examples/ex_basic_node_mapping_type.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_node.cpp b/docs/examples/ex_basic_node_node.cpp
index bcff18f4..56d60887 100644
--- a/docs/examples/ex_basic_node_node.cpp
+++ b/docs/examples/ex_basic_node_node.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_node_t.cpp b/docs/examples/ex_basic_node_node_t.cpp
index 066ab888..023a59ec 100644
--- a/docs/examples/ex_basic_node_node_t.cpp
+++ b/docs/examples/ex_basic_node_node_t.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_operator_eq.cpp b/docs/examples/ex_basic_node_operator_eq.cpp
index f1c84685..4a580fce 100644
--- a/docs/examples/ex_basic_node_operator_eq.cpp
+++ b/docs/examples/ex_basic_node_operator_eq.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_operator_ge.cpp b/docs/examples/ex_basic_node_operator_ge.cpp
index 41bce864..a4f6ce4a 100644
--- a/docs/examples/ex_basic_node_operator_ge.cpp
+++ b/docs/examples/ex_basic_node_operator_ge.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_operator_gt.cpp b/docs/examples/ex_basic_node_operator_gt.cpp
index ef48cb71..8d264e5d 100644
--- a/docs/examples/ex_basic_node_operator_gt.cpp
+++ b/docs/examples/ex_basic_node_operator_gt.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_operator_le.cpp b/docs/examples/ex_basic_node_operator_le.cpp
index 7a001665..c21080a1 100644
--- a/docs/examples/ex_basic_node_operator_le.cpp
+++ b/docs/examples/ex_basic_node_operator_le.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_operator_lt.cpp b/docs/examples/ex_basic_node_operator_lt.cpp
index fdade063..4dcb90ff 100644
--- a/docs/examples/ex_basic_node_operator_lt.cpp
+++ b/docs/examples/ex_basic_node_operator_lt.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_operator_ne.cpp b/docs/examples/ex_basic_node_operator_ne.cpp
index cb8a9288..feb70c83 100644
--- a/docs/examples/ex_basic_node_operator_ne.cpp
+++ b/docs/examples/ex_basic_node_operator_ne.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_sequence.cpp b/docs/examples/ex_basic_node_sequence.cpp
index a1e62535..097b263b 100644
--- a/docs/examples/ex_basic_node_sequence.cpp
+++ b/docs/examples/ex_basic_node_sequence.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_sequence_type.cpp b/docs/examples/ex_basic_node_sequence_type.cpp
index ffde35bb..3f7b4407 100644
--- a/docs/examples/ex_basic_node_sequence_type.cpp
+++ b/docs/examples/ex_basic_node_sequence_type.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_serialize.cpp b/docs/examples/ex_basic_node_serialize.cpp
index 217e4581..4f05b52c 100644
--- a/docs/examples/ex_basic_node_serialize.cpp
+++ b/docs/examples/ex_basic_node_serialize.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_serialize_docs.cpp b/docs/examples/ex_basic_node_serialize_docs.cpp
index 095f56b2..59a0ed31 100644
--- a/docs/examples/ex_basic_node_serialize_docs.cpp
+++ b/docs/examples/ex_basic_node_serialize_docs.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_set_yaml_version.cpp b/docs/examples/ex_basic_node_set_yaml_version.cpp
index 39123175..3e8b8373 100644
--- a/docs/examples/ex_basic_node_set_yaml_version.cpp
+++ b/docs/examples/ex_basic_node_set_yaml_version.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_set_yaml_version_type.cpp b/docs/examples/ex_basic_node_set_yaml_version_type.cpp
new file mode 100644
index 00000000..5b46ad19
--- /dev/null
+++ b/docs/examples/ex_basic_node_set_yaml_version_type.cpp
@@ -0,0 +1,24 @@
+// _______ __ __ __ _____ __ __ __
+// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
+// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
+//
+// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
+// SPDX-License-Identifier: MIT
+
+#include
+#include
+#include
+
+int main() {
+ fkyaml::node n;
+ n.set_yaml_version_type(fkyaml::yaml_version_type::VERSION_1_1);
+ fkyaml::node n2;
+ n2.set_yaml_version_type(fkyaml::yaml_version_type::VERSION_1_2);
+
+ std::cout << std::boolalpha;
+ std::cout << (n.get_yaml_version_type() == fkyaml::yaml_version_type::VERSION_1_1) << std::endl;
+ std::cout << (n2.get_yaml_version_type() == fkyaml::yaml_version_type::VERSION_1_2) << std::endl;
+
+ return 0;
+}
diff --git a/docs/examples/ex_basic_node_set_yaml_version_type.output b/docs/examples/ex_basic_node_set_yaml_version_type.output
new file mode 100644
index 00000000..bb101b64
--- /dev/null
+++ b/docs/examples/ex_basic_node_set_yaml_version_type.output
@@ -0,0 +1,2 @@
+true
+true
diff --git a/docs/examples/ex_basic_node_size.cpp b/docs/examples/ex_basic_node_size.cpp
index 78aad3c5..1e036749 100644
--- a/docs/examples/ex_basic_node_size.cpp
+++ b/docs/examples/ex_basic_node_size.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_string_type.cpp b/docs/examples/ex_basic_node_string_type.cpp
index 01bdc6dd..52e52d53 100644
--- a/docs/examples/ex_basic_node_string_type.cpp
+++ b/docs/examples/ex_basic_node_string_type.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_subscript_operator_basic_node.cpp b/docs/examples/ex_basic_node_subscript_operator_basic_node.cpp
index 12225e31..981ad043 100644
--- a/docs/examples/ex_basic_node_subscript_operator_basic_node.cpp
+++ b/docs/examples/ex_basic_node_subscript_operator_basic_node.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_subscript_operator_compatible_type.cpp b/docs/examples/ex_basic_node_subscript_operator_compatible_type.cpp
index 7c33df28..59364cda 100644
--- a/docs/examples/ex_basic_node_subscript_operator_compatible_type.cpp
+++ b/docs/examples/ex_basic_node_subscript_operator_compatible_type.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_swap_member.cpp b/docs/examples/ex_basic_node_swap_member.cpp
index 783ad09e..0b12f3bf 100644
--- a/docs/examples/ex_basic_node_swap_member.cpp
+++ b/docs/examples/ex_basic_node_swap_member.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_swap_std.cpp b/docs/examples/ex_basic_node_swap_std.cpp
index d3867313..4109bd4f 100644
--- a/docs/examples/ex_basic_node_swap_std.cpp
+++ b/docs/examples/ex_basic_node_swap_std.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_type.cpp b/docs/examples/ex_basic_node_type.cpp
index 066ab888..023a59ec 100644
--- a/docs/examples/ex_basic_node_type.cpp
+++ b/docs/examples/ex_basic_node_type.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_value_converter_type.cpp b/docs/examples/ex_basic_node_value_converter_type.cpp
index 4c213402..d6ec0511 100644
--- a/docs/examples/ex_basic_node_value_converter_type.cpp
+++ b/docs/examples/ex_basic_node_value_converter_type.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_basic_node_yaml_version_t.cpp b/docs/examples/ex_basic_node_yaml_version_t.cpp
index b4a8e3d2..b3ce83a6 100644
--- a/docs/examples/ex_basic_node_yaml_version_t.cpp
+++ b/docs/examples/ex_basic_node_yaml_version_t.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_exception_constructor_msg.cpp b/docs/examples/ex_exception_constructor_msg.cpp
index 36d5c601..08aa0fb4 100644
--- a/docs/examples/ex_exception_constructor_msg.cpp
+++ b/docs/examples/ex_exception_constructor_msg.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_exception_constructor_noarg.cpp b/docs/examples/ex_exception_constructor_noarg.cpp
index cd4d92d0..8cf32478 100644
--- a/docs/examples/ex_exception_constructor_noarg.cpp
+++ b/docs/examples/ex_exception_constructor_noarg.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_exception_what.cpp b/docs/examples/ex_exception_what.cpp
index 2fb0266a..3f8ee5f1 100644
--- a/docs/examples/ex_exception_what.cpp
+++ b/docs/examples/ex_exception_what.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_macros_versions.cpp b/docs/examples/ex_macros_versions.cpp
index 0b794213..2012a76c 100644
--- a/docs/examples/ex_macros_versions.cpp
+++ b/docs/examples/ex_macros_versions.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_node_type.cpp b/docs/examples/ex_node_type.cpp
new file mode 100644
index 00000000..8373f9c5
--- /dev/null
+++ b/docs/examples/ex_node_type.cpp
@@ -0,0 +1,34 @@
+// _______ __ __ __ _____ __ __ __
+// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
+// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
+//
+// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
+// SPDX-License-Identifier: MIT
+
+#include
+#include
+#include
+
+int main() {
+ // create YAML nodes.
+ fkyaml::node sequence_node = {1, 2, 3};
+ fkyaml::node mapping_node = {{"foo", true}, {"bar", false}};
+ fkyaml::node null_node;
+ fkyaml::node boolean_node = true;
+ fkyaml::node integer_node = 256;
+ fkyaml::node float_node = 3.14;
+ fkyaml::node string_node = "Hello, world!";
+
+ // query node value types by calling get_type()
+ std::cout << std::boolalpha;
+ std::cout << (sequence_node.get_type() == fkyaml::node_type::SEQUENCE) << std::endl;
+ std::cout << (mapping_node.get_type() == fkyaml::node_type::MAPPING) << std::endl;
+ std::cout << (null_node.get_type() == fkyaml::node_type::NULL_OBJECT) << std::endl;
+ std::cout << (boolean_node.get_type() == fkyaml::node_type::BOOLEAN) << std::endl;
+ std::cout << (integer_node.get_type() == fkyaml::node_type::INTEGER) << std::endl;
+ std::cout << (float_node.get_type() == fkyaml::node_type::FLOAT) << std::endl;
+ std::cout << (string_node.get_type() == fkyaml::node_type::STRING) << std::endl;
+
+ return 0;
+}
diff --git a/docs/examples/ex_node_type.output b/docs/examples/ex_node_type.output
new file mode 100644
index 00000000..814ccfee
--- /dev/null
+++ b/docs/examples/ex_node_type.output
@@ -0,0 +1,7 @@
+true
+true
+true
+true
+true
+true
+true
diff --git a/docs/examples/ex_node_value_converter_from_node.cpp b/docs/examples/ex_node_value_converter_from_node.cpp
index 0ad5290b..8a647920 100644
--- a/docs/examples/ex_node_value_converter_from_node.cpp
+++ b/docs/examples/ex_node_value_converter_from_node.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_node_value_converter_to_node.cpp b/docs/examples/ex_node_value_converter_to_node.cpp
index 69cb6d0e..b5875c6a 100644
--- a/docs/examples/ex_node_value_converter_to_node.cpp
+++ b/docs/examples/ex_node_value_converter_to_node.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_operator_literal_yaml.cpp b/docs/examples/ex_operator_literal_yaml.cpp
index 78fe7704..adf62d2b 100644
--- a/docs/examples/ex_operator_literal_yaml.cpp
+++ b/docs/examples/ex_operator_literal_yaml.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_ordered_map_at.cpp b/docs/examples/ex_ordered_map_at.cpp
index 0b9ab6d7..c667ffef 100644
--- a/docs/examples/ex_ordered_map_at.cpp
+++ b/docs/examples/ex_ordered_map_at.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_ordered_map_constructor_initializer_list.cpp b/docs/examples/ex_ordered_map_constructor_initializer_list.cpp
index 4486d4dd..ebbf9f10 100644
--- a/docs/examples/ex_ordered_map_constructor_initializer_list.cpp
+++ b/docs/examples/ex_ordered_map_constructor_initializer_list.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_ordered_map_constructor_noarg.cpp b/docs/examples/ex_ordered_map_constructor_noarg.cpp
index 3f783787..ece30874 100644
--- a/docs/examples/ex_ordered_map_constructor_noarg.cpp
+++ b/docs/examples/ex_ordered_map_constructor_noarg.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_ordered_map_emplace.cpp b/docs/examples/ex_ordered_map_emplace.cpp
index 0b610320..b1aa7824 100644
--- a/docs/examples/ex_ordered_map_emplace.cpp
+++ b/docs/examples/ex_ordered_map_emplace.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_ordered_map_find.cpp b/docs/examples/ex_ordered_map_find.cpp
index 1dfcad78..29686f22 100644
--- a/docs/examples/ex_ordered_map_find.cpp
+++ b/docs/examples/ex_ordered_map_find.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_ordered_map_subscript_operator.cpp b/docs/examples/ex_ordered_map_subscript_operator.cpp
index 700e122c..2edf8d6f 100644
--- a/docs/examples/ex_ordered_map_subscript_operator.cpp
+++ b/docs/examples/ex_ordered_map_subscript_operator.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/ex_yaml_version_type.cpp b/docs/examples/ex_yaml_version_type.cpp
new file mode 100644
index 00000000..935eb444
--- /dev/null
+++ b/docs/examples/ex_yaml_version_type.cpp
@@ -0,0 +1,32 @@
+// _______ __ __ __ _____ __ __ __
+// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
+// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
+//
+// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
+// SPDX-License-Identifier: MIT
+
+#include
+#include
+#include
+
+int main() {
+ char input[] = "%YAML 1.2\n"
+ "---\n"
+ "foo: bar\n";
+
+ // deserialize a YAML formatted string.
+ fkyaml::node n = fkyaml::node::deserialize(input);
+
+ // query the YAML version by calling get_yaml_version_type().
+ std::cout << std::boolalpha;
+ std::cout << (n.get_yaml_version_type() == fkyaml::yaml_version_type::VERSION_1_2) << std::endl;
+
+ // overwrite the YAML version to 1.1.
+ n.set_yaml_version_type(fkyaml::yaml_version_type::VERSION_1_1);
+
+ // query the YAML version again.
+ std::cout << (n.get_yaml_version_type() == fkyaml::yaml_version_type::VERSION_1_1) << std::endl;
+
+ return 0;
+}
diff --git a/docs/examples/ex_yaml_version_type.output b/docs/examples/ex_yaml_version_type.output
new file mode 100644
index 00000000..bb101b64
--- /dev/null
+++ b/docs/examples/ex_yaml_version_type.output
@@ -0,0 +1,2 @@
+true
+true
diff --git a/docs/examples/tutorial_1.cpp b/docs/examples/tutorial_1.cpp
index a9737943..5fd40a5e 100644
--- a/docs/examples/tutorial_1.cpp
+++ b/docs/examples/tutorial_1.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/tutorial_2.cpp b/docs/examples/tutorial_2.cpp
index 690fca16..0dea7d26 100644
--- a/docs/examples/tutorial_2.cpp
+++ b/docs/examples/tutorial_2.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/tutorial_3.cpp b/docs/examples/tutorial_3.cpp
index e4b74d85..22595568 100644
--- a/docs/examples/tutorial_3.cpp
+++ b/docs/examples/tutorial_3.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/examples/tutorial_4.cpp b/docs/examples/tutorial_4.cpp
index 106549ee..313869de 100644
--- a/docs/examples/tutorial_4.cpp
+++ b/docs/examples/tutorial_4.cpp
@@ -1,6 +1,6 @@
// _______ __ __ __ _____ __ __ __
// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library (supporting code)
-// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
//
// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
diff --git a/docs/mkdocs/docs/api/basic_node/constructor.md b/docs/mkdocs/docs/api/basic_node/constructor.md
index 10a094c3..b9f42a3e 100644
--- a/docs/mkdocs/docs/api/basic_node/constructor.md
+++ b/docs/mkdocs/docs/api/basic_node/constructor.md
@@ -5,11 +5,13 @@
```cpp
basic_node() = default; // (1)
-explicit basic_node(const node_t type); // (2)
+explicit basic_node(const node_type type); // (2)
-basic_node(const basic_node& rhs); // (3)
+explicit basic_node(const node_t type); // (3) deprecated
-basic_node(basic_node&& rhs) noexcept; // (4)
+basic_node(const basic_node& rhs); // (4)
+
+basic_node(basic_node&& rhs) noexcept; // (5)
template <
typename CompatibleType, typename U = detail::remove_cv_ref_t,
@@ -19,14 +21,14 @@ template <
detail::disjunction>>::value,
int> = 0>
basic_node(CompatibleType&& val) noexcept(
- noexcept(ConverterType::to_node(std::declval(), std::declval()))); // (5)
+ noexcept(ConverterType::to_node(std::declval(), std::declval()))); // (6)
template <
typename NodeRefStorageType,
detail::enable_if_t::value, int> = 0>
-basic_node(const NodeRefStorageType& node_ref_storage) noexcept; // (6)
+basic_node(const NodeRefStorageType& node_ref_storage) noexcept; // (7)
-basic_node(initializer_list_t init); // (7)
+basic_node(initializer_list_t init); // (8)
```
Constructs a new basic_node from a variety of data sources.
@@ -54,7 +56,7 @@ The resulting basic_node has the [`node_t::NULL_OBJECT`](node_t.md) type.
## Overload (2)
```cpp
-explicit basic_node(const node_t type);
+explicit basic_node(const node_type type);
```
Constructs a basic_node with the given type.
The resulting basic_node has a default value for the given type.
@@ -77,6 +79,45 @@ The resulting basic_node has a default value for the given type.
## Overload (3)
+```cpp
+explicit basic_node(const node_t type);
+```
+
+!!! warning "Deprecation"
+
+ The constructor `#!cpp basic_node(const node_type)` replaces the constructor `#!cpp basic_node(const node_t)` which has been deprecated in version 0.3.12. It will be removed in version 0.4.0. Please replace calls like
+
+ ```cpp
+ fkyaml::node n(fkyaml::node::node_t::MAPPING);
+ ```
+
+ with
+
+ ```cpp
+ fkyaml::node n(fkyaml::node_type::MAPPING);
+ ```
+
+Constructs a basic_node with the given type.
+The resulting basic_node has a default value for the given type.
+
+### **Parameters**
+
+***`type`*** [in]
+: A YAML node type.
+
+???+ Example
+
+ ```cpp
+ --8<-- "examples/ex_basic_node_constructor_3.cpp:9"
+ ```
+
+ output:
+ ```bash
+ --8<-- "examples/ex_basic_node_constructor_3.output"
+ ```
+
+## Overload (4)
+
```cpp
basic_node(const basic_node& rhs);
```
@@ -91,15 +132,15 @@ The resulting basic_node has the same type and value as `rhs`.
???+ Example
```cpp
- --8<-- "examples/ex_basic_node_constructor_3.cpp:9"
+ --8<-- "examples/ex_basic_node_constructor_4.cpp:9"
```
output:
```bash
- --8<-- "examples/ex_basic_node_constructor_3.output"
+ --8<-- "examples/ex_basic_node_constructor_4.output"
```
-## Overload (4)
+## Overload (5)
```cpp
basic_node(basic_node&& rhs) noexcept;
@@ -116,15 +157,15 @@ The value of the argument `rhs` after calling this move constructor, will be the
???+ Example
```cpp
- --8<-- "examples/ex_basic_node_constructor_4.cpp:9"
+ --8<-- "examples/ex_basic_node_constructor_5.cpp:9"
```
output:
```bash
- --8<-- "examples/ex_basic_node_constructor_4.output"
+ --8<-- "examples/ex_basic_node_constructor_5.output"
```
-## Overload (5)
+## Overload (6)
```cpp
template <
@@ -156,15 +197,15 @@ The resulting basic_node has the value of `val` and the type which is associated
???+ Example
```cpp
- --8<-- "examples/ex_basic_node_constructor_5.cpp:9"
+ --8<-- "examples/ex_basic_node_constructor_6.cpp:9"
```
output:
```bash
- --8<-- "examples/ex_basic_node_constructor_5.output"
+ --8<-- "examples/ex_basic_node_constructor_6.output"
```
-## Overload (6)
+## Overload (7)
```cpp
template <
@@ -194,15 +235,15 @@ The resulting basic_node has the value of the referenced basic_node by `node_ref
???+ Example
```cpp
- --8<-- "examples/ex_basic_node_constructor_6.cpp:9"
+ --8<-- "examples/ex_basic_node_constructor_7.cpp:9"
```
output:
```bash
- --8<-- "examples/ex_basic_node_constructor_6.output"
+ --8<-- "examples/ex_basic_node_constructor_7.output"
```
-## Overload (7)
+## Overload (8)
```cpp
basic_node(initializer_list_t init);
@@ -220,12 +261,12 @@ If `init` contains a sequence of basic_node objects in which the number of basic
???+ Example
```cpp
- --8<-- "examples/ex_basic_node_constructor_7.cpp:9"
+ --8<-- "examples/ex_basic_node_constructor_8.cpp:9"
```
output:
```bash
- --8<-- "examples/ex_basic_node_constructor_7.output"
+ --8<-- "examples/ex_basic_node_constructor_8.output"
```
---
diff --git a/docs/mkdocs/docs/api/basic_node/get_type.md b/docs/mkdocs/docs/api/basic_node/get_type.md
new file mode 100644
index 00000000..b8ad5cd2
--- /dev/null
+++ b/docs/mkdocs/docs/api/basic_node/get_type.md
@@ -0,0 +1,38 @@
+Defined in header [``](https://github.com/fktn-k/fkYAML/blob/develop/include/fkYAML/node.hpp)
+
+# fkyaml::basic_node::get_type
+
+```cpp
+node_type get_type() const noexcept;
+```
+
+Returns the type of the YAML node value as a value from the [`node_type`](../node_type.md) enumeration.
+
+### **Return Value**
+
+The type of the YAML node value.
+
+| Value Type | Return Value |
+| --------------------- | ---------------------- |
+| sequence | node_type::SEQUENCE |
+| mapping | node_type::MAPPING |
+| null | node_type::NULL_OBJECT |
+| boolean | node_type::BOOLEAN |
+| integer | node_type::INTEGER |
+| floating point number | node_type::FLOAT |
+| string | node_type::STRING |
+
+???+ Example
+
+ ```cpp
+ --8<-- "examples/ex_basic_node_get_type.cpp:9"
+ ```
+
+ output:
+ ```bash
+ --8<-- "examples/ex_basic_node_get_type.output"
+ ```
+
+### **See Also**
+
+* [node_type](../node_type.md)
diff --git a/docs/mkdocs/docs/api/basic_node/get_yaml_version.md b/docs/mkdocs/docs/api/basic_node/get_yaml_version.md
index 1dea35a4..eabc0f9b 100644
--- a/docs/mkdocs/docs/api/basic_node/get_yaml_version.md
+++ b/docs/mkdocs/docs/api/basic_node/get_yaml_version.md
@@ -6,6 +6,19 @@
yaml_version_t get_yaml_version() const noexcept;
```
+!!! warning "Deprecation"
+
+ The function [`#!cpp yaml_version_type get_yaml_version_type()`](set_yaml_version_type.md) replaces the function `#!cpp basic_node::yaml_version_t get_yaml_version()` which has been deprecated in version 0.3.12. It will be removed in version 0.4.0. Please replace calls like
+
+ ```cpp
+ fkyaml::node::yaml_version_t v = n.get_yaml_version();
+ ```
+ with
+
+ ```cpp
+ fkyaml::yaml_version_type v = n.get_yaml_version_type();
+ ```
+
Returns the version of the YAML format applied for the `basic_node` object.
### **Return Value**
diff --git a/docs/mkdocs/docs/api/basic_node/get_yaml_version_type.md b/docs/mkdocs/docs/api/basic_node/get_yaml_version_type.md
new file mode 100644
index 00000000..122e836c
--- /dev/null
+++ b/docs/mkdocs/docs/api/basic_node/get_yaml_version_type.md
@@ -0,0 +1,35 @@
+Defined in header [``](https://github.com/fktn-k/fkYAML/blob/develop/include/fkYAML/node.hpp)
+
+# fkyaml::basic_node::get_yaml_version_type
+
+```cpp
+yaml_version_type get_yaml_version_type() const noexcept;
+```
+
+Returns the version of the YAML format applied for the `basic_node` object.
+
+### **Return Value**
+
+The version of the YAML format applied to the basic_node object.
+
+| YAML version | Return Value |
+| ------------ | ------------------------------ |
+| 1.1 | yaml_version_type::VERSION_1_1 |
+| 1.2 | yaml_version_type::VERSION_1_2 |
+
+???+ Example
+
+ ```cpp
+ --8<-- "examples/ex_basic_node_get_yaml_version_type.cpp:9"
+ ```
+
+ output:
+ ```bash
+ --8<-- "examples/ex_basic_node_get_yaml_version_type.output"
+ ```
+
+## **See Also**
+
+* [basic_node](index.md)
+* [set_yaml_version_type](set_yaml_version_type.md)
+* [yaml_verion_type](../yaml_version_type.md)
diff --git a/docs/mkdocs/docs/api/basic_node/index.md b/docs/mkdocs/docs/api/basic_node/index.md
index ce896c11..8b9ad0ea 100644
--- a/docs/mkdocs/docs/api/basic_node/index.md
+++ b/docs/mkdocs/docs/api/basic_node/index.md
@@ -34,19 +34,19 @@ This class provides features to handle YAML nodes.
## Member Types
-| Name | Description |
-|-------------------------------------------------|------------------------------------------------------------|
-| [sequence_type](sequence_type.md) | The type used to store sequence node value containers. |
-| [mapping_type](mapping_type.md) | The type used to store mapping node value containers. |
-| [boolean_type](boolean_type.md) | The type used to store boolean node values. |
-| [integer_type](integer_type.md) | The type used to store integer node values. |
-| [float_number_type](float_number_type.md) | The type used to store float number node values. |
-| [string_type](string_type.md) | The type used to store string node values. |
-| [value_converter_type](value_converter_type.md) | The type used to convert between node and native data. |
-| [iterator](iterator.md) | The type for non-constant iterators. |
-| [const_iterator](const_iterator.md) | The type for constant iterators. |
-| [node_t](node_t.md) | The type used to store the internal value type. |
-| [yaml_version_t](yaml_version_t.md) | The type used to store the enable version of YAML. |
+| Name | Description |
+| ----------------------------------------------- | ------------------------------------------------------------------- |
+| [sequence_type](sequence_type.md) | The type used to store sequence node value containers. |
+| [mapping_type](mapping_type.md) | The type used to store mapping node value containers. |
+| [boolean_type](boolean_type.md) | The type used to store boolean node values. |
+| [integer_type](integer_type.md) | The type used to store integer node values. |
+| [float_number_type](float_number_type.md) | The type used to store float number node values. |
+| [string_type](string_type.md) | The type used to store string node values. |
+| [value_converter_type](value_converter_type.md) | The type used to convert between node and native data. |
+| [iterator](iterator.md) | The type for non-constant iterators. |
+| [const_iterator](const_iterator.md) | The type for constant iterators. |
+| [node_t](node_t.md) | **(DEPRECATED)** The type used to store the internal value type. |
+| [yaml_version_t](yaml_version_t.md) | **(DEPRECATED)** The type used to store the enable version of YAML. |
## Member Functions
@@ -61,17 +61,18 @@ This class provides features to handle YAML nodes.
| [alias_of](alias_of.md) | (static) | constructs a basic_node with an anchor node. |
### Inspection for Node Value Types
-| Name | Description |
-|---------------------------------------|-------------------------------------------------------|
-| [type](type.md) | returns the type of a node value in a basic_node. |
-| [is_sequence](is_sequence.md) | checks if a basic_node has a sequence node value. |
-| [is_mapping](is_mapping.md) | checks if a basic_node has a mapping node value. |
-| [is_null](is_null.md) | checks if a basic_node has a null node value. |
-| [is_scalar](is_scalar.md) | checks if a basic_node has a scalar node value. |
-| [is_boolean](is_boolean.md) | checks if a basic_node has a boolean node value. |
-| [is_integer](is_integer.md) | checks if a basic_node has an integer node value. |
-| [is_float_number](is_float_number.md) | checks if a basic_node has a float number node value. |
-| [is_string](is_string.md) | checks if a basic_node has a string node value. |
+| Name | Description |
+| ------------------------------------- | ------------------------------------------------------------------ |
+| [get_type](get_type.md) | returns the type of a node value in a basic_node. |
+| [type](type.md) | **(DEPRECATED)** returns the type of a node value in a basic_node. |
+| [is_sequence](is_sequence.md) | checks if a basic_node has a sequence node value. |
+| [is_mapping](is_mapping.md) | checks if a basic_node has a mapping node value. |
+| [is_null](is_null.md) | checks if a basic_node has a null node value. |
+| [is_scalar](is_scalar.md) | checks if a basic_node has a scalar node value. |
+| [is_boolean](is_boolean.md) | checks if a basic_node has a boolean node value. |
+| [is_integer](is_integer.md) | checks if a basic_node has an integer node value. |
+| [is_float_number](is_float_number.md) | checks if a basic_node has a float number node value. |
+| [is_string](is_string.md) | checks if a basic_node has a string node value. |
### Conversions
| Name | | Description |
@@ -114,7 +115,7 @@ This class provides features to handle YAML nodes.
| [operator>](operator_gt.md) | comparison: greater than |
| [operator>=](operator_ge.md) | comparison: greater than or equal |
-### Aliasing Nodes
+### Manipulations for Node Properties
| Name | Description |
| ------------------------------------- | -------------------------------------------------------- |
| [is_alias](is_alias.md) | checks if a basic_node is an alias node. |
@@ -122,6 +123,17 @@ This class provides features to handle YAML nodes.
| [add_anchor_name](add_anchor_name.md) | registers an anchor name to a basic_node object. |
| [get_anchor_name](get_anchor_name.md) | gets an anchor name associated with a basic_node object. |
| [has_anchor_name](has_anchor_name.md) | checks if a basic_node has any anchor name. |
+| [add_tag_name](add_tag_name.md) | registers a tag name to a basic_node object. |
+| [get_tag_name](get_tag_name.md) | gets a tag name associated with a basic_node object. |
+| [has_tag_name](has_tag_name.md) | checks if a basic_node has any tag name. |
+
+### Manipulations for Document Properties
+| Name | Description |
+| ------------------------------------------------- | ------------------------------------------------------------------------- |
+| [get_yaml_version_type](get_yaml_version_type.md) | gets a YAML version associated with a basic_node object. |
+| [set_yaml_version_type](set_yaml_version_type.md) | sets a YAML version to a basic_node object. |
+| [get_yaml_version](get_yaml_version.md) | **(DEPRECATED)** gets a YAML version associated with a basic_node object. |
+| [set_yaml_version](set_yaml_version.md) | **(DEPRECATED)** sets a YAML version to a basic_node object. |
### Modifiers
diff --git a/docs/mkdocs/docs/api/basic_node/node_t.md b/docs/mkdocs/docs/api/basic_node/node_t.md
index 2ec58f85..d337fd44 100644
--- a/docs/mkdocs/docs/api/basic_node/node_t.md
+++ b/docs/mkdocs/docs/api/basic_node/node_t.md
@@ -15,6 +15,20 @@ enum class node_t
};
```
+!!! warning "Deprecation"
+
+ The enum class [`#!cpp fkyaml::node_type`](../node_type.md) replaces the type alias `#!cpp fkyaml::basic_node::node_t` which has been deprecated in version 0.3.12. It will be removed in version 0.4.0. Please replace usages like
+
+ ```cpp
+ fkyaml::node::node_t t;
+ ```
+
+ with
+
+ ```cpp
+ fkyaml::node_type t;
+ ```
+
This enumeration collects the different YAML value types. They are internally used to distinguish the stored values, and the functions [`is_sequence`](is_sequence.md), [`is_mapping`](is_mapping.md) and [`is_scalar`](is_scalar.md) (with [`is_null`](is_null.md), [`is_boolean`](is_boolean.md), [`is_integer`](is_integer.md), [`is_float_number`](is_float_number.md), [`is_string`](is_string.md)) rely on it.
!!! Note "Types of scalars"
diff --git a/docs/mkdocs/docs/api/basic_node/set_yaml_version.md b/docs/mkdocs/docs/api/basic_node/set_yaml_version.md
index 55446c0b..9090762e 100644
--- a/docs/mkdocs/docs/api/basic_node/set_yaml_version.md
+++ b/docs/mkdocs/docs/api/basic_node/set_yaml_version.md
@@ -6,12 +6,26 @@
void set_yaml_version(const yaml_version_t version) noexcept;
```
-Sets the version of the YAML format to the `basic_node` object.
+!!! warning "Deprecation"
+
+ The function [`#!cpp void set_yaml_version_type(const yaml_version_type)`](set_yaml_version_type.md) replaces the function `#!cpp void set_yaml_version(const basic_node::yaml_version_t)` which has been deprecated in version 0.3.12. It will be removed in version 0.4.0. Please replace calls like
+
+ ```cpp
+ n.set_yaml_version(fkyaml::node::yaml_version_t::VER_1_2);
+ ```
+
+ with
+
+ ```cpp
+ n.set_yaml_version_type(fkyaml::yaml_version_type::VERSION_1_2);
+ ```
+
+Sets a target YAML version to the `basic_node` object.
### **Parameters**
***version*** [in]
-: A version of the YAML format.
+: A target YAML version.
???+ Example
diff --git a/docs/mkdocs/docs/api/basic_node/set_yaml_version_type.md b/docs/mkdocs/docs/api/basic_node/set_yaml_version_type.md
new file mode 100644
index 00000000..5884d71f
--- /dev/null
+++ b/docs/mkdocs/docs/api/basic_node/set_yaml_version_type.md
@@ -0,0 +1,31 @@
+Defined in header [``](https://github.com/fktn-k/fkYAML/blob/develop/include/fkYAML/node.hpp)
+
+# fkyaml::basic_node::set_yaml_version_type
+
+```cpp
+void set_yaml_version_type(const yaml_version_type version) noexcept;
+```
+
+Sets a target YAML version to the `basic_node` object.
+
+### **Parameters**
+
+***version*** [in]
+: A target YAML version.
+
+???+ Example
+
+ ```cpp
+ --8<-- "examples/ex_basic_node_set_yaml_version_type.cpp:9"
+ ```
+
+ output:
+ ```bash
+ --8<-- "examples/ex_basic_node_set_yaml_version_type.output"
+ ```
+
+## **See Also**
+
+* [basic_node](index.md)
+* [get_yaml_version_type](get_yaml_version_type.md)
+* [yaml_verion_type](../yaml_version_type.md)
diff --git a/docs/mkdocs/docs/api/basic_node/type.md b/docs/mkdocs/docs/api/basic_node/type.md
index 727f087f..8a3f0038 100644
--- a/docs/mkdocs/docs/api/basic_node/type.md
+++ b/docs/mkdocs/docs/api/basic_node/type.md
@@ -6,6 +6,20 @@
node_t type() const noexcept;
```
+!!! warning "Deprecation"
+
+ The function [`#!cpp node_type get_type()`](get_type.md) replaces the function `basic_node::node_t type()` which has been deprecated in version 0.3.12. It will be removed in version 0.4.0. Please replace calls like
+
+ ```cpp
+ fkyaml::node::node_t t = n.type();
+ ```
+
+ with
+
+ ```cpp
+ fkyaml::node_type t = n.get_type();
+ ```
+
Returns the type of the YAML node value as a value from the [`node_t`](node_t.md) enumeration.
### **Return Value**
diff --git a/docs/mkdocs/docs/api/basic_node/yaml_version_t.md b/docs/mkdocs/docs/api/basic_node/yaml_version_t.md
index 5f9a6e58..ad9d6700 100644
--- a/docs/mkdocs/docs/api/basic_node/yaml_version_t.md
+++ b/docs/mkdocs/docs/api/basic_node/yaml_version_t.md
@@ -10,6 +10,20 @@ enum class yaml_version_t
};
```
+!!! warning "Deprecation"
+
+ The enum class [`fkyaml::yaml_version_type`](../yaml_version_type.md) replaces the type alias `fkyaml::basic_node::yaml_version_t` which has been deprecated in version 0.3.12. It will be removed in version 0.4.0. Please replace usages like
+
+ ```cpp
+ fkyaml::node::yaml_version_t v;
+ ```
+
+ with
+
+ ```cpp
+ fkyaml::yaml_version_type v;
+ ```
+
This enumeration collects the used versions of YAML specification. It is used as meta data of a basic_node and the functions [`get_yaml_version`](get_yaml_version.md) and [`set_yaml_version`](set_yaml_version.md) rely on it.
???+ Example
diff --git a/docs/mkdocs/docs/api/exception/index.md b/docs/mkdocs/docs/api/exception/index.md
index e540efd9..876ab06b 100644
--- a/docs/mkdocs/docs/api/exception/index.md
+++ b/docs/mkdocs/docs/api/exception/index.md
@@ -13,6 +13,7 @@ A basic exception class used in the fkYAML library.
| Type | Description |
| --------------------------------------- | ---------------------------------------------------- |
| [invalid_encoding](invalid_encoding.md) | The exception indicating an encoding error. |
+| [out_of_range](out_of_range.md) | The exception indicating an out-of-range error. |
| [parse_error](parse_error.md) | The exception indicating an error in parsing. |
| [type_error](type_error.md) | The exception indicating an invalid type conversion. |
diff --git a/docs/mkdocs/docs/api/node_type.md b/docs/mkdocs/docs/api/node_type.md
new file mode 100644
index 00000000..24c573de
--- /dev/null
+++ b/docs/mkdocs/docs/api/node_type.md
@@ -0,0 +1,61 @@
+Defined in header [``](https://github.com/fktn-k/fkYAML/blob/develop/include/fkYAML/node_type.hpp)
+
+# fkyaml::node_type
+
+```cpp
+enum class node_type : std::uint32_t
+{
+ SEQUENCE,
+ MAPPING,
+ NULL_OBJECT,
+ BOOLEAN,
+ INTEGER,
+ FLOAT,
+ STRING,
+};
+```
+
+This enumeration collects the different YAML value types. They are internally used to distinguish the stored values, and the following [basic_node](basic_node/index.md)'s functions rely on it:
+
+* [`is_sequence()`](basic_node/is_sequence.md)
+* [`is_mapping()`](basic_node/is_mapping.md)
+* [`is_scalar()`](basic_node/is_scalar.md)
+ * [`is_null()`](basic_node/is_null.md)
+ * [`is_boolean()`](basic_node/is_boolean.md)
+ * [`is_integer()`](basic_node/is_integer.md)
+ * [`is_float_number()`](basic_node/is_float_number.md)
+ * [`is_string()`](basic_node/is_string.md)
+
+!!! Note "Types of scalars"
+
+ There are five enumerators for scalars (`NULL_OBJECT`, `BOOLEAN`, `INTEGER`, `FLOAT`, `STRING`) to distinguish between different types of scalars:
+
+ * `std::nullptr_t` for null scalar values
+ * [`basic_node::boolean_type`](basic_node/boolean_type.md) for boolean scalar values
+ * [`basic_node::integer_type`](basic_node/integer_type.md) for integer scalar values
+ * [`basic_node::float_number_type`](basic_node/float_number_type.md) for float number scalar values
+ * [`basic_node::string_type`](basic_node/string_type.md) for string scalar values
+
+???+ Example
+
+ ```cpp
+ --8<-- "examples/ex_node_type.cpp:9"
+ ```
+
+ output:
+ ```bash
+ --8<-- "examples/ex_node_type.output"
+ ```
+
+### **See Also**
+
+* [basic_node](basic_node/index.md)
+ * [get_type](basic_node/get_type.md)
+ * [is_sequence](basic_node/is_sequence.md)
+ * [is_mapping](basic_node/is_mapping.md)
+ * [is_scalar](basic_node/is_scalar.md)
+ * [is_null](basic_node/is_null.md)
+ * [is_boolean](basic_node/is_boolean.md)
+ * [is_integer](basic_node/is_integer.md)
+ * [is_float_number](basic_node/is_float_number.md)
+ * [is_string](basic_node/is_string.md)
diff --git a/docs/mkdocs/docs/api/yaml_version_type.md b/docs/mkdocs/docs/api/yaml_version_type.md
new file mode 100644
index 00000000..bba81947
--- /dev/null
+++ b/docs/mkdocs/docs/api/yaml_version_type.md
@@ -0,0 +1,33 @@
+Defined in header [``](https://github.com/fktn-k/fkYAML/blob/develop/include/fkYAML/yaml_version_type.hpp)
+
+# fkyaml::yaml_version_type
+
+```cpp
+enum class yaml_version_type
+{
+ VERSION_1_1,
+ VERSION_1_2,
+};
+```
+
+This enumeration collects the used versions of YAML specification. It is used as meta data of a basic_node and the following [basic_node](basic_node/index.md)'s functions rely on it:
+
+* [`get_yaml_version_type()`](basic_node/get_yaml_version_type.md)
+* [`set_yaml_version_type()`](basic_node/set_yaml_version_type.md)
+
+???+ Example
+
+ ```cpp
+ --8<-- "examples/ex_yaml_version_type.cpp:9"
+ ```
+
+ output:
+ ```bash
+ --8<-- "examples/ex_yaml_version_type.output"
+ ```
+
+### **See Also**
+
+* [deserialize](basic_node/deserialize.md)
+* [get_yaml_version_type](basic_node/get_yaml_version_type.md)
+* [set_yaml_version_type](basic_node/set_yaml_version_type.md)
diff --git a/docs/mkdocs/docs/home/releases.md b/docs/mkdocs/docs/home/releases.md
index a7659dcf..91f9832f 100644
--- a/docs/mkdocs/docs/home/releases.md
+++ b/docs/mkdocs/docs/home/releases.md
@@ -1,5 +1,59 @@
# Releases
+## [v0.3.12](https://github.com/fktn-k/fkYAML/releases/tag/v0.3.12) (2024-09-21)
+
+!!! abstract "Release Packages"
+
+ * [fkYAML.zip](https://github.com/fktn-k/fkYAML/releases/download/v0.3.12/fkYAML.zip)
+ * [fkYAML.tgz](https://github.com/fktn-k/fkYAML/releases/download/v0.3.12/fkYAML.tgz)
+ * [fkYAML_single_header.zip](https://github.com/fktn-k/fkYAML/releases/download/v0.3.12/fkYAML_single_header.zip)
+ * [fkYAML_single_header.tgz](https://github.com/fktn-k/fkYAML/releases/download/v0.3.12/fkYAML_single_header.tgz)
+ * [node.hpp](https://github.com/fktn-k/fkYAML/releases/download/v0.3.12/node.hpp) (single header)
+
+### Summary
+
+This release adds some basic_node APIs to get/set node attributes for more secure backwards compatibilities in future releases. Because of that, some existing APIs have been deprecated (see the list down below). It's recommended for users to replace deprecated API usages with new APIs.
+Furthermore, relatively large refactoring has been made for better performance and more flexible node attribute configurations (just preparation for now, but will be added within a few coming releases). As a result, deserialization performance has increased. See the Benchmarking section in README.md for details.
+Last but not least, several bugs have also been resolved in deserialization, and active C++ standard is now correctly detected at compile time when using MSVC compilers where `__cplusplus` macro doesn't hold a correct value by default.
+
+#### :sparkles: New Features
+
+- Add node\_type/yaml\_version\_type enum class APIs by [fktn-k](https://github.com/fktn-k) in [\#388](https://github.com/fktn-k/fkYAML/pull/388)
+ - In this PR, the following APIs has been deprecated. Although they still work as before except for compile-time deprecation warnings, it's highly recommended to replace their usages with new APIs since they are planned to be removed in v0.4.0. See the Deprecation notes in each deprecated API reference page for migration guides.
+ - [`fkyaml::basic_node::node_t`](https://fktn-k.github.io/fkYAML/api/basic_node/node_t/)
+ - Replace with: [`fkyaml::node_type`](https://fktn-k.github.io/fkYAML/api/node_type/)
+ - [`fkyaml::basic_node::basic_node(const fkyaml::basic_node::node_t)`](https://fktn-k.github.io/fkYAML/api/basic_node/constructor/#overload-3)
+ - Replace with: [`fkyaml::basic_node::basic_node(const fkyaml::node_type)`](https://fktn-k.github.io/fkYAML/api/basic_node/constructor/#overload-2)
+ - [`fkyaml::basic_node::node_t fkyaml::basic_node::type()`](https://fktn-k.github.io/fkYAML/api/basic_node/type/)
+ - Replace with: [`fkyaml::basic_node::get_type()`](https://fktn-k.github.io/fkYAML/api/basic_node/get_type/)
+ - [`fkyaml::basic_node::yaml_version_t`](https://fktn-k.github.io/fkYAML/api/basic_node/yaml_version_t/)
+ - Replace with: [`fkyaml::yaml_version_type`](https://fktn-k.github.io/fkYAML/api/yaml_version_type/)
+ - [`fkyaml::basic_node::yaml_version_t fkyaml::basic_node::get_yaml_version()`](https://fktn-k.github.io/fkYAML/api/basic_node/get_yaml_version/)
+ - Replace with: [`fkyaml::yaml_version_type fkyaml::basic_node::get_yaml_version_type()`](https://fktn-k.github.io/fkYAML/api/basic_node/get_yaml_version_type/)
+ - [`void fkyaml::basic_node::set_yaml_version(const fkyaml::basic_node::yaml_version_t)`](https://fktn-k.github.io/fkYAML/api/basic_node/set_yaml_version/)
+ - Replace with: [`void fkyaml::basic_node::set_yaml_version_type(const fkyaml::yaml_version_type)`](https://fktn-k.github.io/fkYAML/api/basic_node/set_yaml_version_type/)
+
+
+#### :zap: Improvements
+
+- Improve UTF encoding detection by [fktn-k](https://github.com/fktn-k) in [\#386](https://github.com/fktn-k/fkYAML/pull/386)
+- Refactor node attributes management by [fktn-k](https://github.com/fktn-k) in [\#389](https://github.com/fktn-k/fkYAML/pull/389)
+- Refactor lexical analysis by [fktn-k](https://github.com/fktn-k) in [\#390](https://github.com/fktn-k/fkYAML/pull/390)
+- Improve conversion from scalars to native types by [fktn-k](https://github.com/fktn-k) in [\#391](https://github.com/fktn-k/fkYAML/pull/391)
+- Reduce string copies in parse by [fktn-k](https://github.com/fktn-k) in [\#394](https://github.com/fktn-k/fkYAML/pull/394)
+- Use likely/unlikely if available by [fktn-k](https://github.com/fktn-k) in [\#395](https://github.com/fktn-k/fkYAML/pull/395)
+
+#### :bug: Bug Fixes
+
+- Fix detecting invalid contents of block scalar headers by [fktn-k](https://github.com/fktn-k) in [\#387](https://github.com/fktn-k/fkYAML/pull/387)
+- Use \_MSVC\_LANG macro when compiled with MSVC for C++ standard detection by [fktn-k](https://github.com/fktn-k) in [\#392](https://github.com/fktn-k/fkYAML/pull/392)
+- Parse +.inf as the positive float infinity by [fktn-k](https://github.com/fktn-k) in [\#393](https://github.com/fktn-k/fkYAML/pull/393)
+
+
+**Full Changelog**: https://github.com/fktn-k/fkYAML/compare/v0.3.11...v0.3.12
+
+---
+
## **fkYAML version 0.3.11**
!!! abstract "Release Packages"
diff --git a/docs/mkdocs/docs/tutorials/cmake_integration.md b/docs/mkdocs/docs/tutorials/cmake_integration.md
index 9b1972a9..da75b79e 100644
--- a/docs/mkdocs/docs/tutorials/cmake_integration.md
+++ b/docs/mkdocs/docs/tutorials/cmake_integration.md
@@ -57,7 +57,7 @@ Since CMake v3.11, [`FetchContent`](https://cmake.org/cmake/help/latest/module/F
FetchContent_Declare(
fkYAML
GIT_REPOSITORY https://github.com/fktn-k/fkYAML.git
- GIT_TAG v0.3.11
+ GIT_TAG v0.3.12
)
FetchContent_MakeAvailable(fkYAML)
diff --git a/docs/mkdocs/mkdocs.yml b/docs/mkdocs/mkdocs.yml
index 82960ce1..1d404255 100644
--- a/docs/mkdocs/mkdocs.yml
+++ b/docs/mkdocs/mkdocs.yml
@@ -55,7 +55,7 @@ markdown_extensions:
pygments_lang_class: true
- pymdownx.inlinehilite
- pymdownx.magiclink
- - pymdownx.superfences:
+ - pymdownx.superfences
- pymdownx.tabbed:
alternate_style: true
- pymdownx.tilde
@@ -116,9 +116,11 @@ nav:
- float_number_type: api/basic_node/float_number_type.md
- get_anchor_name: api/basic_node/get_anchor_name.md
- get_tag_name: api/basic_node/get_tag_name.md
+ - get_type: api/basic_node/get_type.md
- get_value: api/basic_node/get_value.md
- get_value_ref: api/basic_node/get_value_ref.md
- get_yaml_version: api/basic_node/get_yaml_version.md
+ - get_yaml_version_type: api/basic_node/get_yaml_version_type.md
- has_anchor_name: api/basic_node/has_anchor_name.md
- has_tag_name: api/basic_node/has_tag_name.md
- integer_type: api/basic_node/integer_type.md
@@ -142,6 +144,7 @@ nav:
- serialize: api/basic_node/serialize.md
- serialize_docs: api/basic_node/serialize_docs.md
- set_yaml_version: api/basic_node/set_yaml_version.md
+ - set_yaml_version_type: api/basic_node/set_yaml_version_type.md
- size: api/basic_node/size.md
- string_type: api/basic_node/string_type.md
- swap: api/basic_node/swap.md
@@ -165,6 +168,7 @@ nav:
- parse_error: api/exception/parse_error.md
- type_error: api/exception/type_error.md
- macros: api/macros.md
+ - node_type: api/node_type.md
- node_value_converter:
- node_value_converter: api/node_value_converter/index.md
- from_node: api/node_value_converter/from_node.md
@@ -180,3 +184,4 @@ nav:
- emplace: api/ordered_map/emplace.md
- find: api/ordered_map/find.md
- operator[]: api/ordered_map/operator[].md
+ - yaml_version_type: api/yaml_version_type.md
diff --git a/fkYAML.natvis b/fkYAML.natvis
index a3d2b4bb..609fe880 100644
--- a/fkYAML.natvis
+++ b/fkYAML.natvis
@@ -4,26 +4,26 @@
-
-
- {*(m_node_value.p_sequence)}
- {*(m_node_value.p_mapping)}
- nullptr
- {m_node_value.boolean}
- {m_node_value.integer}
- {m_node_value.float_val}
- {*(m_node_value.p_string)}
+
+
+ {*(m_node_value.p_sequence)}
+ {*(m_node_value.p_mapping)}
+ nullptr
+ {m_node_value.boolean}
+ {m_node_value.integer}
+ {m_node_value.float_val}
+ {*(m_node_value.p_string)}
-
+
*(m_node_value.p_sequence),view(simple)
-
+
*(m_node_value.p_mapping),view(simple)
-
+
{second}
second
diff --git a/include/fkYAML/detail/assert.hpp b/include/fkYAML/detail/assert.hpp
index a83b6e16..c2db086d 100644
--- a/include/fkYAML/detail/assert.hpp
+++ b/include/fkYAML/detail/assert.hpp
@@ -1,6 +1,6 @@
/// _______ __ __ __ _____ __ __ __
/// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library
-/// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+/// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
/// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
///
/// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
@@ -15,9 +15,9 @@
#ifndef FK_YAML_ASSERT
#ifndef NDEBUG
#include
-#define FK_YAML_ASSERT(x) assert(x) // NOLINT(cppcoreguidelines-macro-usage)
+#define FK_YAML_ASSERT(x) assert(x)
#else
-#define FK_YAML_ASSERT(x) // NOLINT(cppcoreguidelines-macro-usage)
+#define FK_YAML_ASSERT(x)
#endif
#endif
diff --git a/include/fkYAML/detail/conversions/from_node.hpp b/include/fkYAML/detail/conversions/from_node.hpp
index 5551d750..ff9e212f 100644
--- a/include/fkYAML/detail/conversions/from_node.hpp
+++ b/include/fkYAML/detail/conversions/from_node.hpp
@@ -1,6 +1,6 @@
/// _______ __ __ __ _____ __ __ __
/// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library
-/// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
+/// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
/// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
///
/// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
@@ -35,8 +35,8 @@ FK_YAML_DETAIL_NAMESPACE_BEGIN
/// @param s A sequence node value object.
template ::value, int> = 0>
inline void from_node(const BasicNodeType& n, typename BasicNodeType::sequence_type& s) {
- if (!n.is_sequence()) {
- throw type_error("The target node value type is not sequence type.", n.type());
+ if FK_YAML_UNLIKELY (!n.is_sequence()) {
+ throw type_error("The target node value type is not sequence type.", n.get_type());
}
s = n.template get_value_ref();
}
@@ -55,8 +55,8 @@ template <
negation, typename BasicNodeType::sequence_type>>>::value,
int> = 0>
inline void from_node(const BasicNodeType& n, std::vector& s) {
- if (!n.is_sequence()) {
- throw type_error("The target node value is not sequence type.", n.type());
+ if FK_YAML_UNLIKELY (!n.is_sequence()) {
+ throw type_error("The target node value is not sequence type.", n.get_type());
}
s.reserve(n.size());
@@ -72,8 +72,8 @@ inline void from_node(const BasicNodeType& n, std::vector&
/// @param m A mapping node value object.
template ::value, int> = 0>
inline void from_node(const BasicNodeType& n, typename BasicNodeType::mapping_type& m) {
- if (!n.is_mapping()) {
- throw type_error("The target node value type is not mapping type.", n.type());
+ if FK_YAML_UNLIKELY (!n.is_mapping()) {
+ throw type_error("The target node value type is not mapping type.", n.get_type());
}
for (auto pair : n.template get_value_ref()) {
@@ -91,8 +91,8 @@ template <
has_from_node>::value,
int> = 0>
inline void from_node(const BasicNodeType& n, std::map& m) {
- if (!n.is_mapping()) {
- throw type_error("The target node value type is not mapping type.", n.type());
+ if FK_YAML_UNLIKELY (!n.is_mapping()) {
+ throw type_error("The target node value type is not mapping type.", n.get_type());
}
for (auto pair : n.template get_value_ref()) {
@@ -108,8 +108,8 @@ inline void from_node(const BasicNodeType& n, std::map::value, int> = 0>
inline void from_node(const BasicNodeType& n, std::nullptr_t& null) {
// to ensure the target node value type is null.
- if (!n.is_null()) {
- throw type_error("The target node value type is not null type.", n.type());
+ if FK_YAML_UNLIKELY (!n.is_null()) {
+ throw type_error("The target node value type is not null type.", n.get_type());
}
null = nullptr;
}
@@ -120,8 +120,8 @@ inline void from_node(const BasicNodeType& n, std::nullptr_t& null) {
/// @param b A boolean node value object.
template ::value, int> = 0>
inline void from_node(const BasicNodeType& n, typename BasicNodeType::boolean_type& b) {
- if (!n.is_boolean()) {
- throw type_error("The target node value type is not boolean type.", n.type());
+ if FK_YAML_UNLIKELY (!n.is_boolean()) {
+ throw type_error("The target node value type is not boolean type.", n.get_type());
}
b = n.template get_value_ref();
}
@@ -132,8 +132,8 @@ inline void from_node(const BasicNodeType& n, typename BasicNodeType::boolean_ty
/// @param i An integer node value object.
template ::value, int> = 0>
inline void from_node(const BasicNodeType& n, typename BasicNodeType::integer_type& i) {
- if (!n.is_integer()) {
- throw type_error("The target node value type is not integer type.", n.type());
+ if FK_YAML_UNLIKELY (!n.is_integer()) {
+ throw type_error("The target node value type is not integer type.", n.get_type());
}
i = n.template get_value_ref();
}
@@ -151,17 +151,17 @@ template <
negation>>::value,
int> = 0>
inline void from_node(const BasicNodeType& n, IntegerType& i) {
- if (!n.is_integer()) {
- throw type_error("The target node value type is not integer type.", n.type());
+ if FK_YAML_UNLIKELY (!n.is_integer()) {
+ throw type_error("The target node value type is not integer type.", n.get_type());
}
// under/overflow check.
using node_int_type = typename BasicNodeType::integer_type;
node_int_type tmp_int = n.template get_value_ref();
- if (tmp_int < static_cast(std::numeric_limits::min())) {
+ if FK_YAML_UNLIKELY (tmp_int < static_cast(std::numeric_limits::min())) {
throw exception("Integer value underflow detected.");
}
- if (static_cast(std::numeric_limits::max()) < tmp_int) {
+ if FK_YAML_UNLIKELY (static_cast(std::numeric_limits::max()) < tmp_int) {
throw exception("Integer value overflow detected.");
}
@@ -174,8 +174,8 @@ inline void from_node(const BasicNodeType& n, IntegerType& i) {
/// @param f A float number node value object.
template ::value, int> = 0>
inline void from_node(const BasicNodeType& n, typename BasicNodeType::float_number_type& f) {
- if (!n.is_float_number()) {
- throw type_error("The target node value type is not float number type.", n.type());
+ if FK_YAML_UNLIKELY (!n.is_float_number()) {
+ throw type_error("The target node value type is not float number type.", n.get_type());
}
f = n.template get_value_ref();
}
@@ -193,15 +193,15 @@ template <
negation>>::value,
int> = 0>
inline void from_node(const BasicNodeType& n, FloatType& f) {
- if (!n.is_float_number()) {
- throw type_error("The target node value type is not float number type.", n.type());
+ if FK_YAML_UNLIKELY (!n.is_float_number()) {
+ throw type_error("The target node value type is not float number type.", n.get_type());
}
auto tmp_float = n.template get_value_ref();
- if (tmp_float < std::numeric_limits::lowest()) {
+ if FK_YAML_UNLIKELY (tmp_float < std::numeric_limits::lowest()) {
throw exception("Floating point value underflow detected.");
}
- if (std::numeric_limits::max() < tmp_float) {
+ if FK_YAML_UNLIKELY (std::numeric_limits::max() < tmp_float) {
throw exception("Floating point value overflow detected.");
}
@@ -214,8 +214,8 @@ inline void from_node(const BasicNodeType& n, FloatType& f) {
/// @param s A string node value object.
template ::value, int> = 0>
inline void from_node(const BasicNodeType& n, typename BasicNodeType::string_type& s) {
- if (!n.is_string()) {
- throw type_error("The target node value type is not string type.", n.type());
+ if FK_YAML_UNLIKELY (!n.is_string()) {
+ throw type_error("The target node value type is not string type.", n.get_type());
}
s = n.template get_value_ref();
}
@@ -236,8 +236,8 @@ template <
std::is_assignable>>::value,
int> = 0>
inline void from_node(const BasicNodeType& n, CompatibleStringType& s) {
- if (!n.is_string()) {
- throw type_error("The target node value type is not string type.", n.type());
+ if FK_YAML_UNLIKELY (!n.is_string()) {
+ throw type_error("The target node value type is not string type.", n.get_type());
}
s = n.template get_value_ref();
}
diff --git a/include/fkYAML/detail/conversions/from_string.hpp b/include/fkYAML/detail/conversions/from_string.hpp
deleted file mode 100644
index 2a082d44..00000000
--- a/include/fkYAML/detail/conversions/from_string.hpp
+++ /dev/null
@@ -1,241 +0,0 @@
-/// _______ __ __ __ _____ __ __ __
-/// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library
-/// | __| _ < \_ _/| ___ | _ | |___ version 0.3.11
-/// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
-///
-/// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
-/// SPDX-License-Identifier: MIT
-///
-/// @file
-
-#ifndef FK_YAML_DETAIL_CONVERSIONS_FROM_STRING_HPP_
-#define FK_YAML_DETAIL_CONVERSIONS_FROM_STRING_HPP_
-
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-
-FK_YAML_DETAIL_NAMESPACE_BEGIN
-
-/// @brief Convert a string YAML token to a ValueType object.
-/// @tparam ValueType A target value type.
-/// @tparam CharType The type of characters in a source string.
-template
-inline ValueType from_string(const std::basic_string& s, type_tag /*unused*/);
-
-/// @brief Specialization of from_string() for null values with std::string
-/// @tparam N/A
-template <>
-inline std::nullptr_t from_string(const std::string& s, type_tag /*unused*/) {
- if (s == "null" || s == "Null" || s == "NULL" || s == "~") {
- return nullptr;
- }
-
- throw exception("Cannot convert a string into a null value.");
-}
-
-/// @brief Specialization of from_string() for boolean values with std::string.
-/// @tparam N/A
-template <>
-inline bool from_string(const std::string& s, type_tag /*unused*/) {
- if (s == "true" || s == "True" || s == "TRUE") {
- return true;
- }
-
- if (s == "false" || s == "False" || s == "FALSE") {
- return false;
- }
-
- throw exception("Cannot convert a string into a boolean value.");
-}
-
-/// @brief Specialization of from_string() for int values with std::string.
-/// @tparam N/A
-template <>
-inline int from_string(const std::string& s, type_tag /*unused*/) {
- std::size_t idx = 0;
- long ret = 0;
-
- try {
- ret = std::stoi(s, &idx, 0);
- }
- catch (const std::exception& /*unused*/) {
- throw exception("Failed to convert a string into an int value.");
- }
-
- return ret;
-}
-
-/// @brief Specialization of from_string() for long values with std::string.
-/// @tparam N/A
-template <>
-inline long from_string(const std::string& s, type_tag /*unused*/) {
- std::size_t idx = 0;
- long ret = 0;
-
- try {
- ret = std::stol(s, &idx, 0);
- }
- catch (const std::exception& /*unused*/) {
- throw exception("Failed to convert a string into a long value.");
- }
-
- return ret;
-}
-
-/// @brief Specialization of from_string() for long long values with std::string.
-/// @tparam N/A
-template <>
-inline long long from_string(const std::string& s, type_tag /*unused*/) {
- std::size_t idx = 0;
- long long ret = 0;
-
- try {
- ret = std::stoll(s, &idx, 0);
- }
- catch (const std::exception& /*unused*/) {
- throw exception("Failed to convert a string into a long long value.");
- }
-
- return ret;
-}
-
-/// @brief Partial specialization of from_string() for other signed integer types with std::string.
-/// @tparam SignedIntType A signed integer type other than long long.
-template
-inline enable_if_t<
- conjunction<
- is_non_bool_integral, std::is_signed, negation>,
- negation>, negation>>::value,
- SignedIntType>
-from_string(const std::string& s, type_tag /*unused*/) {
- const auto tmp_ret = from_string(s, type_tag {});
- if (static_cast(std::numeric_limits::max()) < tmp_ret) {
- throw exception("Failed to convert a long long value into a SignedIntegerType value.");
- }
-
- return static_cast(tmp_ret);
-}
-
-/// @brief Specialization of from_string() for unsigned long values with std::string.
-/// @tparam N/A
-template <>
-inline unsigned long from_string(const std::string& s, type_tag /*unused*/) {
- std::size_t idx = 0;
- unsigned long ret = 0;
-
- try {
- ret = std::stoul(s, &idx, 0);
- }
- catch (const std::exception& /*unused*/) {
- throw exception("Failed to convert a string into an unsigned long value.");
- }
-
- return ret;
-}
-
-/// @brief Specialization of from_string() for unsigned long long values with std::string.
-/// @tparam N/A
-template <>
-inline unsigned long long from_string(const std::string& s, type_tag /*unused*/) {
- std::size_t idx = 0;
- unsigned long long ret = 0;
-
- try {
- ret = std::stoull(s, &idx, 0);
- }
- catch (const std::exception& /*unused*/) {
- throw exception("Failed to convert a string into an unsigned long long value.");
- }
-
- return ret;
-}
-
-/// @brief Partial specialization of from_string() for other unsigned integer types with std::string.
-/// @tparam UnsignedIntType An unsigned integer type other than unsigned long long.
-template
-inline enable_if_t<
- conjunction<
- is_non_bool_integral, std::is_unsigned,
- negation>,
- negation>>::value,
- UnsignedIntType>
-from_string(const std::string& s, type_tag /*unused*/) {
- const auto tmp_ret = from_string(s, type_tag {});
- if (static_cast(std::numeric_limits::max()) < tmp_ret) {
- throw exception("Failed to convert an unsigned long long into an unsigned integer value.");
- }
-
- return static_cast(tmp_ret);
-}
-
-/// @brief Specialization of from_string() for float values with std::string.
-/// @tparam N/A
-template <>
-inline float from_string(const std::string& s, type_tag /*unused*/) {
- if (s == ".inf" || s == ".Inf" || s == ".INF") {
- return std::numeric_limits::infinity();
- }
-
- if (s == "-.inf" || s == "-.Inf" || s == "-.INF") {
- static_assert(std::numeric_limits::is_iec559, "IEEE 754 required.");
- return -1 * std::numeric_limits::infinity();
- }
-
- if (s == ".nan" || s == ".NaN" || s == ".NAN") {
- return std::nanf("");
- }
-
- std::size_t idx = 0;
- float ret = 0.0f;
-
- try {
- ret = std::stof(s, &idx);
- }
- catch (const std::exception& /*unused*/) {
- throw exception("Failed to convert a string into a float value.");
- }
-
- return ret;
-}
-
-/// @brief Specialization of from_string() for double values with std::string.
-/// @tparam N/A
-template <>
-inline double from_string(const std::string& s, type_tag /*unused*/) {
- if (s == ".inf" || s == ".Inf" || s == ".INF") {
- return std::numeric_limits::infinity();
- }
-
- if (s == "-.inf" || s == "-.Inf" || s == "-.INF") {
- static_assert(std::numeric_limits::is_iec559, "IEEE 754 required.");
- return -1 * std::numeric_limits::infinity();
- }
-
- if (s == ".nan" || s == ".NaN" || s == ".NAN") {
- return std::nan("");
- }
-
- std::size_t idx = 0;
- double ret = 0.0;
-
- try {
- ret = std::stod(s, &idx);
- }
- catch (const std::exception& /*unused*/) {
- throw exception("Failed to convert a string into a double value.");
- }
-
- return ret;
-}
-
-FK_YAML_DETAIL_NAMESPACE_END
-
-#endif /* FK_YAML_DETAIL_CONVERSIONS_FROM_STRING_HPP_ */
diff --git a/include/fkYAML/detail/conversions/scalar_conv.hpp b/include/fkYAML/detail/conversions/scalar_conv.hpp
new file mode 100644
index 00000000..ae78448c
--- /dev/null
+++ b/include/fkYAML/detail/conversions/scalar_conv.hpp
@@ -0,0 +1,834 @@
+/// _______ __ __ __ _____ __ __ __
+/// | __| |_/ | \_/ |/ _ \ / \/ \| | fkYAML: A C++ header-only YAML library
+/// | __| _ < \_ _/| ___ | _ | |___ version 0.3.12
+/// |__| |_| \__| |_| |_| |_|___||___|______| https://github.com/fktn-k/fkYAML
+///
+/// SPDX-FileCopyrightText: 2023-2024 Kensuke Fukutani
+/// SPDX-License-Identifier: MIT
+///
+/// @file
+
+// **NOTE FOR LIBARARY DEVELOPERS**:
+// Implementations in this header file are intentionally optimized for conversions between YAML scalars and native C++
+// types. So, some implementations don't follow the convensions in the standard C++ functions. For example, octals must
+// begin with "0o" (not "0"), which is specified in the YAML spec 1.2.
+
+#ifndef FK_YAML_CONVERSIONS_SCALAR_CONV_HPP_
+#define FK_YAML_CONVERSIONS_SCALAR_CONV_HPP_
+
+#include
+#include
+#include
+
+#include
+#include
+
+#if FK_YAML_HAS_TO_CHARS
+// Prefer std::to_chars() and std::from_chars() functions if available.
+#include
+#else
+// Fallback to legacy string conversion functions otherwise.
+#include // std::stof(), std::stod(), std::stold()
+#endif
+
+FK_YAML_DETAIL_NAMESPACE_BEGIN
+
+//////////////////////////
+// conv_limits_base //
+//////////////////////////
+
+/// @brief A structure which provides limits for conversions between scalars and integers.
+/// @note This structure contains common limits in both signed and unsigned integers.
+/// @tparam NumBytes The number of bytes for the integer type.
+template
+struct conv_limits_base {};
+
+/// @brief The specialization of conv_limits_base for 1 byte integers, e.g., int8_t, uint8_t.
+template <>
+struct conv_limits_base<1u> {
+ /// max characters for octals (0o377) without the prefix part.
+ static constexpr std::size_t max_chars_oct = 3;
+ /// max characters for hexadecimals (0xFF) without the prefix part.
+ static constexpr std::size_t max_chars_hex = 2;
+
+ /// @brief Check if the given octals are safely converted into 1 byte integer.
+ /// @param octs The pointer to octal characters
+ /// @param len The length of octal characters
+ /// @return true is safely convertible, false otherwise.
+ static bool check_if_octs_safe(const char* octs, std::size_t len) noexcept {
+ return (len < max_chars_oct) || (len == max_chars_oct && octs[0] <= '3');
+ }
+
+ /// @brief Check if the given hexadecimals are safely converted into 1 byte integer.
+ /// @param octs The pointer to hexadecimal characters
+ /// @param len The length of hexadecimal characters
+ /// @return true is safely convertible, false otherwise.
+ static bool check_if_hexs_safe(const char* /*unused*/, std::size_t len) noexcept {
+ return len <= max_chars_hex;
+ }
+};
+
+/// @brief The specialization of conv_limits_base for 2 byte integers, e.g., int16_t, uint16_t.
+template <>
+struct conv_limits_base<2u> {
+ /// max characters for octals (0o177777) without the prefix part.
+ static constexpr std::size_t max_chars_oct = 6;
+ /// max characters for hexadecimals (0xFFFF) without the prefix part.
+ static constexpr std::size_t max_chars_hex = 4;
+
+ /// @brief Check if the given octals are safely converted into 2 byte integer.
+ /// @param octs The pointer to octal characters
+ /// @param len The length of octal characters
+ /// @return true is safely convertible, false otherwise.
+ static bool check_if_octs_safe(const char* octs, std::size_t len) noexcept {
+ return (len < max_chars_oct) || (len == max_chars_oct && octs[0] <= '1');
+ }
+
+ /// @brief Check if the given hexadecimals are safely converted into 2 byte integer.
+ /// @param octs The pointer to hexadecimal characters
+ /// @param len The length of hexadecimal characters
+ /// @return true is safely convertible, false otherwise.
+ static bool check_if_hexs_safe(const char* /*unused*/, std::size_t len) noexcept {
+ return len <= max_chars_hex;
+ }
+};
+
+/// @brief The specialization of conv_limits_base for 4 byte integers, e.g., int32_t, uint32_t.
+template <>
+struct conv_limits_base<4u> {
+ /// max characters for octals (0o37777777777) without the prefix part.
+ static constexpr std::size_t max_chars_oct = 11;
+ /// max characters for hexadecimals (0xFFFFFFFF) without the prefix part.
+ static constexpr std::size_t max_chars_hex = 8;
+
+ /// @brief Check if the given octals are safely converted into 4 byte integer.
+ /// @param octs The pointer to octal characters
+ /// @param len The length of octal characters
+ /// @return true is safely convertible, false otherwise.
+ static bool check_if_octs_safe(const char* octs, std::size_t len) noexcept {
+ return (len < max_chars_oct) || (len == max_chars_oct && octs[0] <= '3');
+ }
+
+ /// @brief Check if the given hexadecimals are safely converted into 4 byte integer.
+ /// @param octs The pointer to hexadecimal characters
+ /// @param len The length of hexadecimal characters
+ /// @return true is safely convertible, false otherwise.
+ static bool check_if_hexs_safe(const char* /*unused*/, std::size_t len) noexcept {
+ return len <= max_chars_hex;
+ }
+};
+
+/// @brief The specialization of conv_limits_base for 8 byte integers, e.g., int64_t, uint64_t.
+template <>
+struct conv_limits_base<8u> {
+ /// max characters for octals (0o1777777777777777777777) without the prefix part.
+ static constexpr std::size_t max_chars_oct = 22;
+ /// max characters for hexadecimals (0xFFFFFFFFFFFFFFFF) without the prefix part.
+ static constexpr std::size_t max_chars_hex = 16;
+
+ /// @brief Check if the given octals are safely converted into 8 byte integer.
+ /// @param octs The pointer to octal characters
+ /// @param len The length of octal characters
+ /// @return true is safely convertible, false otherwise.
+ static bool check_if_octs_safe(const char* octs, std::size_t len) noexcept {
+ return (len < max_chars_oct) || (len == max_chars_oct && octs[0] <= '1');
+ }
+
+ /// @brief Check if the given hexadecimals are safely converted into 8 byte integer.
+ /// @param octs The pointer to hexadecimal characters
+ /// @param len The length of hexadecimal characters
+ /// @return true is safely convertible, false otherwise.
+ static bool check_if_hexs_safe(const char* /*unused*/, std::size_t len) noexcept {
+ return len <= max_chars_hex;
+ }
+};
+
+/////////////////////
+// conv_limits //
+/////////////////////
+
+/// @brief A structure which provides limits for conversions between scalars and integers.
+/// @note This structure contains limits which differs based on signedness.
+/// @tparam NumBytes The number of bytes for the integer type.
+/// @tparam IsSigned Whether an integer is signed or unsigned
+template
+struct conv_limits {};
+
+/// @brief The specialization of conv_limits for 1 byte signed integers, e.g., int8_t.
+template <>
+struct conv_limits<1u, true> : conv_limits_base<1u> {
+ /// with or without sign.
+ static constexpr bool is_signed = true;
+
+ /// max characters for decimals (-128..127) without sign.
+ static constexpr std::size_t max_chars_dec = 3;
+
+ /// string representation of max decimal value.
+ static const char* max_value_chars_dec() noexcept {
+ // Making this function a static constexpr variable, a link error happens.
+ // Although the issue has been fixed since C++17, this workaround is necessary to let this functionality work
+ // with C++11 (the library's default C++ standard version).
+ // The same thing is applied to similar functions in the other specializations.
+
+ static constexpr char max_value_chars[] = "127";
+ return &max_value_chars[0];
+ }
+
+ /// string representation of min decimal value without sign.
+ static const char* min_value_chars_dec() noexcept {
+ static constexpr char min_value_chars[] = "128";
+ return &min_value_chars[0];
+ }
+};
+
+/// @brief The specialization of conv_limits for 1 byte unsigned integers, e.g., uint8_t.
+template <>
+struct conv_limits<1u, false> : conv_limits_base<1u> {
+ /// with or without sign.
+ static constexpr bool is_signed = false;
+
+ /// max characters for decimals (0..255) without sign.
+ static constexpr std::size_t max_chars_dec = 3;
+
+ /// string representation of max decimal value.
+ static const char* max_value_chars_dec() noexcept {
+ static constexpr char max_value_chars[] = "255";
+ return &max_value_chars[0];
+ }
+
+ /// string representation of min decimal value.
+ static const char* min_value_chars_dec() noexcept {
+ static constexpr char min_value_chars[] = "0";
+ return &min_value_chars[0];
+ }
+};
+
+/// @brief The specialization of conv_limits for 2 byte signed integers, e.g., int16_t.
+template <>
+struct conv_limits<2u, true> : conv_limits_base<2u> {
+ /// with or without sign.
+ static constexpr bool is_signed = true;
+
+ /// max characters for decimals (-32768..32767) without sign.
+ static constexpr std::size_t max_chars_dec = 5;
+
+ /// string representation of max decimal value.
+ static const char* max_value_chars_dec() noexcept {
+ static constexpr char max_value_chars[] = "32767";
+ return &max_value_chars[0];
+ }
+
+ /// string representation of min decimal value without sign.
+ static const char* min_value_chars_dec() noexcept {
+ static constexpr char min_value_chars[] = "32768";
+ return &min_value_chars[0];
+ }
+};
+
+/// @brief The specialization of conv_limits for 2 byte unsigned integers, e.g., uint16_t.
+template <>
+struct conv_limits<2u, false> : conv_limits_base<2u> {
+ /// with or without sign.
+ static constexpr bool is_signed = false;
+
+ /// max characters for decimals (0..65535) without sign.
+ static constexpr std::size_t max_chars_dec = 5;
+
+ /// string representation of max decimal value.
+ static const char* max_value_chars_dec() noexcept {
+ static constexpr char max_value_chars[] = "65535";
+ return &max_value_chars[0];
+ }
+
+ /// string representation of min decimal value.
+ static const char* min_value_chars_dec() noexcept {
+ static constexpr char min_value_chars[] = "0";
+ return &min_value_chars[0];
+ }
+};
+
+/// @brief The specialization of conv_limits for 4 byte signed integers, e.g., int32_t.
+template <>
+struct conv_limits<4u, true> : conv_limits_base<4u> {
+ /// with or without sign.
+ static constexpr bool is_signed = true;
+
+ /// max characters for decimals (-2147483648..2147483647) without sign.
+ static constexpr std::size_t max_chars_dec = 10;
+
+ /// string representation of max decimal value.
+ static const char* max_value_chars_dec() noexcept {
+ static constexpr char max_value_chars[] = "2147483647";
+ return &max_value_chars[0];
+ }
+
+ /// string representation of min decimal value without sign.
+ static const char* min_value_chars_dec() noexcept {
+ static constexpr char min_value_chars[] = "2147483648";
+ return &min_value_chars[0];
+ }
+};
+
+/// @brief The specialization of conv_limits for 4 byte unsigned integers, e.g., uint32_t.
+template <>
+struct conv_limits<4u, false> : conv_limits_base<4u> {
+ /// with or without sign.
+ static constexpr bool is_signed = false;
+
+ /// max characters for decimals (0..4294967295) without sign.
+ static constexpr std::size_t max_chars_dec = 10;
+
+ /// string representation of max decimal value.
+ static const char* max_value_chars_dec() noexcept {
+ static constexpr char max_value_chars[] = "4294967295";
+ return &max_value_chars[0];
+ }
+
+ /// string representation of min decimal value.
+ static const char* min_value_chars_dec() noexcept {
+ static constexpr char min_value_chars[] = "0";
+ return &min_value_chars[0];
+ }
+};
+
+/// @brief The specialization of conv_limits for 8 byte signed integers, e.g., int64_t.
+template <>
+struct conv_limits<8u, true> : conv_limits_base<8u> {
+ /// with or without sign.
+ static constexpr bool is_signed = true;
+
+ /// max characters for decimals (-9223372036854775808..9223372036854775807) without sign.
+ static constexpr std::size_t max_chars_dec = 19;
+
+ /// string representation of max decimal value.
+ static const char* max_value_chars_dec() noexcept {
+ static constexpr char max_value_chars[] = "9223372036854775807";
+ return &max_value_chars[0];
+ }
+
+ /// string representation of min decimal value without sign.
+ static const char* min_value_chars_dec() noexcept {
+ static constexpr char min_value_chars[] = "9223372036854775808";
+ return &min_value_chars[0];
+ }
+};
+
+/// @brief The specialization of conv_limits for 8 byte unsigned integers, e.g., uint64_t.
+template <>
+struct conv_limits<8u, false> : conv_limits_base<8u> {
+ /// with or without sign.
+ static constexpr bool is_signed = false;
+
+ /// max characters for decimals (0..18446744073709551615) without sign.
+ static constexpr std::size_t max_chars_dec = 20;
+
+ /// string representation of max decimal value.
+ static const char* max_value_chars_dec() noexcept {
+ static constexpr char max_value_chars[] = "18446744073709551615";
+ return &max_value_chars[0];
+ }
+
+ /// string representation of min decimal value.
+ static const char* min_value_chars_dec() noexcept {
+ static constexpr char min_value_chars[] = "0";
+ return &min_value_chars[0];
+ }
+};
+
+//////////////////////////
+// scalar <--> null //
+//////////////////////////
+
+/// @brief Converts a scalar into a null value
+/// @tparam CharItr Type of char iterators. Its value type must be `char` (maybe cv-qualified).
+/// @param begin The iterator to the first element of the scalar.
+/// @param end The iterator to the past-the-end element of the scalar.
+/// @param /*unused*/ The null value holder (unused since it can only have `nullptr`)
+/// @return true if the conversion completes successfully, false otherwise.
+template
+inline bool aton(CharItr begin, CharItr end, std::nullptr_t& /*unused*/) noexcept {
+ static_assert(is_iterator_of::value, "aton() accepts iterators for char type");
+
+ if FK_YAML_UNLIKELY (begin == end) {
+ return false;
+ }
+
+ uint32_t len = static_cast(std::distance(begin, end));
+
+ // This path is the most probable case, so check it first.
+ if FK_YAML_LIKELY (len == 4) {
+ const char* p_begin = &*begin;
+ return (std::strncmp(p_begin, "null", 4) == 0) || (std::strncmp(p_begin, "Null", 4) == 0) ||
+ (std::strncmp(p_begin, "NULL", 4) == 0);
+ }
+
+ if (len == 1) {
+ return *begin == '~';
+ }
+
+ return false;
+}
+
+/////////////////////////////
+// scalar <--> boolean //
+/////////////////////////////
+
+/// @brief Converts a scalar into a boolean value
+/// @tparam CharItr The type of char iterators. Its value type must be `char` (maybe cv-qualified).
+/// @tparam BoolType The output boolean type.
+/// @param begin The iterator to the first element of the scalar.
+/// @param end The iterator to the past-the-end element of the scalar.
+/// @param boolean The boolean value holder.
+/// @return true if the conversion completes successfully, false otherwise.
+template
+inline bool atob(CharItr begin, CharItr end, BoolType& boolean) noexcept {
+ static_assert(is_iterator_of::value, "atob() accepts iterators for char type");
+
+ if FK_YAML_UNLIKELY (begin == end) {
+ return false;
+ }
+
+ uint32_t len = static_cast(std::distance(begin, end));
+ const char* p_begin = &*begin;
+
+ if (len == 4) {
+ bool is_true_scalar = (std::strncmp(p_begin, "true", 4) == 0) || (std::strncmp(p_begin, "True", 4) == 0) ||
+ (std::strncmp(p_begin, "TRUE", 4) == 0);
+
+ if FK_YAML_LIKELY (is_true_scalar) {
+ boolean = static_cast(true);
+ }
+ return is_true_scalar;
+ }
+
+ if (len == 5) {
+ bool is_false_scalar = (std::strncmp(p_begin, "false", 5) == 0) || (std::strncmp(p_begin, "False", 5) == 0) ||
+ (std::strncmp(p_begin, "FALSE", 5) == 0);
+
+ if FK_YAML_LIKELY (is_false_scalar) {
+ boolean = static_cast(false);
+ }
+ return is_false_scalar;
+ }
+
+ return false;
+}
+
+/////////////////////////////
+// scalar <--> integer //
+/////////////////////////////
+
+//
+// scalar --> decimals
+//
+
+/// @brief Converts a scalar into decimals. This is common implementation for both signed/unsigned integer types.
+/// @warning
+/// This function does NOT care about overflows if IntType is unsigned. The source string value must be validated
+/// beforehand by calling either atoi_dec_pos() or atoi_dec_neg() functions.
+/// Furthermore, `p_begin` and `p_end` must NOT be null. Validate them before calling this function.
+/// @tparam IntType The output integer type. It can be either signed or unsigned.
+/// @param p_begin The pointer to the first element of the scalar.
+/// @param p_end The pointer to the past-the-end element of the scalar.
+/// @param i The output integer value holder.
+/// @return true if the conversion completes successfully, false otherwise.
+template
+inline bool atoi_dec_unchecked(const char* p_begin, const char* p_end, IntType& i) noexcept {
+ static_assert(
+ is_non_bool_integral::value,
+ "atoi_dec_unchecked() accepts non-boolean integral types as an output type");
+
+ i = 0;
+ do {
+ char c = *p_begin;
+ if FK_YAML_UNLIKELY (c < '0' || '9' < c) {
+ return false;
+ }
+ // Overflow is intentional when the IntType is signed.
+ i = i * IntType(10) + IntType(c - '0');
+ } while (++p_begin != p_end);
+
+ return true;
+}
+
+/// @brief Converts a scalar into positive decimals. This function executes bounds check to avoid overflow.
+/// @warning `p_begin` and `p_end` must not be null. Validate them before calling this function.
+/// @tparam IntType The output integer type. It can be either signed or unsigned.
+/// @param p_begin The pointer to the first element of the scalar.
+/// @param p_end The pointer to the past-the-end element of the scalar.
+/// @param i The output integer value holder.
+/// @return true if the conversion completes successfully, false otherwise.
+template
+inline bool atoi_dec_pos(const char* p_begin, const char* p_end, IntType& i) noexcept {
+ static_assert(
+ is_non_bool_integral::value, "atoi_dec_pos() accepts non-boolean integral types as an output type");
+
+ if FK_YAML_UNLIKELY (p_begin == p_end) {
+ return false;
+ }
+
+ using conv_limits_type = conv_limits::value>;
+
+ std::size_t len = static_cast(p_end - p_begin);
+ if FK_YAML_UNLIKELY (len > conv_limits_type::max_chars_dec) {
+ // Overflow will happen.
+ return false;
+ }
+
+ if (len == conv_limits_type::max_chars_dec) {
+ const char* p_max_value_chars_dec = conv_limits_type::max_value_chars_dec();
+
+ for (std::size_t idx = 0; idx < conv_limits_type::max_chars_dec; idx++) {
+ if (p_begin[idx] < p_max_value_chars_dec[idx]) {
+ // No need to check the lower digits. Overflow will no longer happen.
+ break;
+ }
+
+ if FK_YAML_UNLIKELY (p_begin[idx] > p_max_value_chars_dec[idx]) {
+ // Overflow will happen.
+ return false;
+ }
+ }
+ }
+
+ return atoi_dec_unchecked(p_begin, p_end, i);
+}
+
+/// @brief Converts a scalar into negative decimals. This function executes bounds check to avoid underflow.
+/// @warning `p_begin` and `p_end` must not be null. Validate them before calling this function.
+/// @tparam IntType The output integer type. It must be signed.
+/// @param p_begin The pointer to the first element of the scalar.
+/// @param p_end The pointer to the past-the-end element of the scalar.
+/// @param i The output integer value holder.
+/// @return true if the conversion completes successfully, false otherwise.
+template
+inline bool atoi_dec_neg(const char* p_begin, const char* p_end, IntType& i) noexcept {
+ static_assert(
+ is_non_bool_integral::value, "atoi_dec_neg() accepts non-boolean integral types as an output type");
+
+ if FK_YAML_UNLIKELY (p_begin == p_end) {
+ return false;
+ }
+
+ using conv_limits_type = conv_limits::value>;
+
+ std::size_t len = static_cast(p_end - p_begin);
+ if FK_YAML_UNLIKELY (len > conv_limits_type::max_chars_dec) {
+ // Underflow will happen.
+ return false;
+ }
+
+ if (len == conv_limits_type::max_chars_dec) {
+ const char* p_min_value_chars_dec = conv_limits_type::min_value_chars_dec();
+
+ for (std::size_t idx = 0; idx < conv_limits_type::max_chars_dec; idx++) {
+ if (p_begin[idx] < p_min_value_chars_dec[idx]) {
+ // No need to check the lower digits. Underflow will no longer happen.
+ break;
+ }
+
+ if FK_YAML_UNLIKELY (p_begin[idx] > p_min_value_chars_dec[idx]) {
+ // Underflow will happen.
+ return false;
+ }
+ }
+ }
+
+ return atoi_dec_unchecked(p_begin, p_end, i);
+}
+
+//
+// scalar --> octals
+//
+
+/// @brief Converts a scalar into octals. This function executes bounds check to avoid overflow.
+/// @warning `p_begin` and `p_end` must not be null. Validate them before calling this function.
+/// @tparam IntType The output integer type. It can be either signed or unsigned.
+/// @param p_begin The pointer to the first element of the scalar.
+/// @param p_end The pointer to the past-the-end element of the scalar.
+/// @param i The output integer value holder.
+/// @return true if the conversion completes successfully, false otherwise.
+template
+inline bool atoi_oct(const char* p_begin, const char* p_end, IntType& i) noexcept {
+ static_assert(
+ is_non_bool_integral::value, "atoi_oct() accepts non-boolean integral types as an output type");
+
+ if FK_YAML_UNLIKELY (p_begin == p_end) {
+ return false;
+ }
+
+ using conv_limits_type = conv_limits::value>;
+
+ std::size_t len = static_cast(p_end - p_begin);
+ if FK_YAML_UNLIKELY (!conv_limits_type::check_if_octs_safe(p_begin, len)) {
+ return false;
+ }
+
+ i = 0;
+ do {
+ char c = *p_begin;
+ if FK_YAML_UNLIKELY (c < '0' || '7' < c) {
+ return false;
+ }
+ i = i * IntType(8) + IntType(c - '0');
+ } while (++p_begin != p_end);
+
+ return true;
+}
+
+//
+// scalar --> hexadecimals
+//
+
+/// @brief Converts a scalar into hexadecimals. This function executes bounds check to avoid overflow.
+/// @warning `p_begin` and `p_end` must not be null. Validate them before calling this function.
+/// @tparam IntType The output integer type. It can be either signed or unsigned.
+/// @param p_begin The pointer to the first element of the scalar.
+/// @param p_end The pointer to the past-the-end element of the scalar.
+/// @param i The output integer value holder.
+/// @return true if the conversion completes successfully, false otherwise.
+template
+inline bool atoi_hex(const char* p_begin, const char* p_end, IntType& i) noexcept {
+ static_assert(
+ is_non_bool_integral