summaryrefslogtreecommitdiffhomepage
path: root/vendor/toml++/impl/formatter.hpp
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2026-03-08 15:47:16 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2026-03-08 15:47:16 +0100
commitddb1cbc831b6d13b985d91022f01e955e24ae871 (patch)
tree985c7eda4fafa827eaad88b6b469b0baba791817 /vendor/toml++/impl/formatter.hpp
parent7a469801ecb55fcde0199d4e41b1cec3a17dcb05 (diff)
[CHORE] Patching TOML manifest parser to avoid null deref.nebuild-patches-deref
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'vendor/toml++/impl/formatter.hpp')
-rw-r--r--vendor/toml++/impl/formatter.hpp323
1 files changed, 145 insertions, 178 deletions
diff --git a/vendor/toml++/impl/formatter.hpp b/vendor/toml++/impl/formatter.hpp
index 0c97833..ba3a349 100644
--- a/vendor/toml++/impl/formatter.hpp
+++ b/vendor/toml++/impl/formatter.hpp
@@ -1,194 +1,161 @@
-//# This file is a part of toml++ and is subject to the the terms of the MIT license.
-//# Copyright (c) Mark Gillard <mark.gillard@outlook.com.au>
-//# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text.
-// SPDX-License-Identifier: MIT
+// # This file is a part of toml++ and is subject to the the terms of the MIT license.
+// # Copyright (c) Mark Gillard <mark.gillard@outlook.com.au>
+// # See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text.
+// SPDX-License-Identifier: MIT
#pragma once
#include "preprocessor.hpp"
#if TOML_ENABLE_FORMATTERS
#include "forward_declarations.hpp"
-#include "print_to_stream.hpp"
#include "header_start.hpp"
+#include "print_to_stream.hpp"
/// \cond
-TOML_IMPL_NAMESPACE_START
-{
- struct formatter_constants
- {
- format_flags mandatory_flags;
- format_flags ignored_flags;
-
- std::string_view float_pos_inf;
- std::string_view float_neg_inf;
- std::string_view float_nan;
-
- std::string_view bool_true;
- std::string_view bool_false;
- };
-
- struct formatter_config
- {
- format_flags flags;
- std::string_view indent;
- };
-
- class TOML_EXPORTED_CLASS formatter
- {
- private:
- const node* source_;
+TOML_IMPL_NAMESPACE_START {
+ struct formatter_constants {
+ format_flags mandatory_flags;
+ format_flags ignored_flags;
+
+ std::string_view float_pos_inf;
+ std::string_view float_neg_inf;
+ std::string_view float_nan;
+
+ std::string_view bool_true;
+ std::string_view bool_false;
+ };
+
+ struct formatter_config {
+ format_flags flags;
+ std::string_view indent;
+ };
+
+ class TOML_EXPORTED_CLASS formatter {
+ private:
+ const node* source_;
#if TOML_ENABLE_PARSER && !TOML_EXCEPTIONS
- const parse_result* result_;
+ const parse_result* result_;
#endif
- const formatter_constants* constants_;
- formatter_config config_;
- size_t indent_columns_;
- format_flags int_format_mask_;
- std::ostream* stream_; //
- int indent_; // these are set in attach()
- bool naked_newline_; //
-
- protected:
- TOML_PURE_INLINE_GETTER
- const node& source() const noexcept
- {
- return *source_;
- }
-
- TOML_PURE_INLINE_GETTER
- std::ostream& stream() const noexcept
- {
- return *stream_;
- }
-
- TOML_PURE_INLINE_GETTER
- int indent() const noexcept
- {
- return indent_;
- }
-
- void indent(int level) noexcept
- {
- indent_ = level;
- }
-
- void increase_indent() noexcept
- {
- indent_++;
- }
-
- void decrease_indent() noexcept
- {
- indent_--;
- }
-
- TOML_PURE_INLINE_GETTER
- size_t indent_columns() const noexcept
- {
- return indent_columns_;
- }
-
- TOML_PURE_INLINE_GETTER
- bool indent_array_elements() const noexcept
- {
- return !!(config_.flags & format_flags::indent_array_elements);
- }
-
- TOML_PURE_INLINE_GETTER
- bool indent_sub_tables() const noexcept
- {
- return !!(config_.flags & format_flags::indent_sub_tables);
- }
-
- TOML_PURE_INLINE_GETTER
- bool literal_strings_allowed() const noexcept
- {
- return !!(config_.flags & format_flags::allow_literal_strings);
- }
-
- TOML_PURE_INLINE_GETTER
- bool multi_line_strings_allowed() const noexcept
- {
- return !!(config_.flags & format_flags::allow_multi_line_strings);
- }
-
- TOML_PURE_INLINE_GETTER
- bool real_tabs_in_strings_allowed() const noexcept
- {
- return !!(config_.flags & format_flags::allow_real_tabs_in_strings);
- }
-
- TOML_PURE_INLINE_GETTER
- bool unicode_strings_allowed() const noexcept
- {
- return !!(config_.flags & format_flags::allow_unicode_strings);
- }
-
- TOML_PURE_INLINE_GETTER
- bool terse_kvps() const noexcept
- {
- return !!(config_.flags & format_flags::terse_key_value_pairs);
- }
-
- TOML_EXPORTED_MEMBER_FUNCTION
- void attach(std::ostream& stream) noexcept;
-
- TOML_EXPORTED_MEMBER_FUNCTION
- void detach() noexcept;
-
- TOML_EXPORTED_MEMBER_FUNCTION
- void print_newline(bool force = false);
-
- TOML_EXPORTED_MEMBER_FUNCTION
- void print_indent();
-
- TOML_EXPORTED_MEMBER_FUNCTION
- void print_unformatted(char);
-
- TOML_EXPORTED_MEMBER_FUNCTION
- void print_unformatted(std::string_view);
-
- TOML_EXPORTED_MEMBER_FUNCTION
- void print_string(std::string_view str,
- bool allow_multi_line = true,
- bool allow_bare = false,
- bool allow_literal_whitespace = true);
-
- TOML_EXPORTED_MEMBER_FUNCTION
- void print(const value<std::string>&);
-
- TOML_EXPORTED_MEMBER_FUNCTION
- void print(const value<int64_t>&);
-
- TOML_EXPORTED_MEMBER_FUNCTION
- void print(const value<double>&);
-
- TOML_EXPORTED_MEMBER_FUNCTION
- void print(const value<bool>&);
-
- TOML_EXPORTED_MEMBER_FUNCTION
- void print(const value<date>&);
-
- TOML_EXPORTED_MEMBER_FUNCTION
- void print(const value<time>&);
-
- TOML_EXPORTED_MEMBER_FUNCTION
- void print(const value<date_time>&);
-
- TOML_EXPORTED_MEMBER_FUNCTION
- void print_value(const node&, node_type);
-
- TOML_NODISCARD
- TOML_EXPORTED_MEMBER_FUNCTION
- bool dump_failed_parse_result();
-
- TOML_NODISCARD_CTOR
- TOML_EXPORTED_MEMBER_FUNCTION
- formatter(const node*, const parse_result*, const formatter_constants&, const formatter_config&) noexcept;
- };
+ const formatter_constants* constants_;
+ formatter_config config_;
+ size_t indent_columns_;
+ format_flags int_format_mask_;
+ std::ostream* stream_; //
+ int indent_; // these are set in attach()
+ bool naked_newline_; //
+
+ protected:
+ TOML_PURE_INLINE_GETTER
+ const node& source() const noexcept { return *source_; }
+
+ TOML_PURE_INLINE_GETTER
+ std::ostream& stream() const noexcept { return *stream_; }
+
+ TOML_PURE_INLINE_GETTER
+ int indent() const noexcept { return indent_; }
+
+ void indent(int level) noexcept { indent_ = level; }
+
+ void increase_indent() noexcept { indent_++; }
+
+ void decrease_indent() noexcept { indent_--; }
+
+ TOML_PURE_INLINE_GETTER
+ size_t indent_columns() const noexcept { return indent_columns_; }
+
+ TOML_PURE_INLINE_GETTER
+ bool indent_array_elements() const noexcept {
+ return !!(config_.flags & format_flags::indent_array_elements);
+ }
+
+ TOML_PURE_INLINE_GETTER
+ bool indent_sub_tables() const noexcept {
+ return !!(config_.flags & format_flags::indent_sub_tables);
+ }
+
+ TOML_PURE_INLINE_GETTER
+ bool literal_strings_allowed() const noexcept {
+ return !!(config_.flags & format_flags::allow_literal_strings);
+ }
+
+ TOML_PURE_INLINE_GETTER
+ bool multi_line_strings_allowed() const noexcept {
+ return !!(config_.flags & format_flags::allow_multi_line_strings);
+ }
+
+ TOML_PURE_INLINE_GETTER
+ bool real_tabs_in_strings_allowed() const noexcept {
+ return !!(config_.flags & format_flags::allow_real_tabs_in_strings);
+ }
+
+ TOML_PURE_INLINE_GETTER
+ bool unicode_strings_allowed() const noexcept {
+ return !!(config_.flags & format_flags::allow_unicode_strings);
+ }
+
+ TOML_PURE_INLINE_GETTER
+ bool terse_kvps() const noexcept {
+ return !!(config_.flags & format_flags::terse_key_value_pairs);
+ }
+
+ TOML_EXPORTED_MEMBER_FUNCTION
+ void attach(std::ostream& stream) noexcept;
+
+ TOML_EXPORTED_MEMBER_FUNCTION
+ void detach() noexcept;
+
+ TOML_EXPORTED_MEMBER_FUNCTION
+ void print_newline(bool force = false);
+
+ TOML_EXPORTED_MEMBER_FUNCTION
+ void print_indent();
+
+ TOML_EXPORTED_MEMBER_FUNCTION
+ void print_unformatted(char);
+
+ TOML_EXPORTED_MEMBER_FUNCTION
+ void print_unformatted(std::string_view);
+
+ TOML_EXPORTED_MEMBER_FUNCTION
+ void print_string(std::string_view str, bool allow_multi_line = true, bool allow_bare = false,
+ bool allow_literal_whitespace = true);
+
+ TOML_EXPORTED_MEMBER_FUNCTION
+ void print(const value<std::string>&);
+
+ TOML_EXPORTED_MEMBER_FUNCTION
+ void print(const value<int64_t>&);
+
+ TOML_EXPORTED_MEMBER_FUNCTION
+ void print(const value<double>&);
+
+ TOML_EXPORTED_MEMBER_FUNCTION
+ void print(const value<bool>&);
+
+ TOML_EXPORTED_MEMBER_FUNCTION
+ void print(const value<date>&);
+
+ TOML_EXPORTED_MEMBER_FUNCTION
+ void print(const value<time>&);
+
+ TOML_EXPORTED_MEMBER_FUNCTION
+ void print(const value<date_time>&);
+
+ TOML_EXPORTED_MEMBER_FUNCTION
+ void print_value(const node&, node_type);
+
+ TOML_NODISCARD
+ TOML_EXPORTED_MEMBER_FUNCTION
+ bool dump_failed_parse_result();
+
+ TOML_NODISCARD_CTOR
+ TOML_EXPORTED_MEMBER_FUNCTION
+ formatter(const node*, const parse_result*, const formatter_constants&,
+ const formatter_config&) noexcept;
+ };
}
TOML_IMPL_NAMESPACE_END;
/// \endcond
#include "header_end.hpp"
-#endif // TOML_ENABLE_FORMATTERS
+#endif // TOML_ENABLE_FORMATTERS