b41e12f736
also: - fixed extended-precision fractional times causing parse error instead of truncating per the spec (closes #127) - fixed some non-spec vertical whitespace being accepted as line breaks (closes #128) - added `format_flags::allow_unicode_strings`
125 lines
3.4 KiB
C++
125 lines
3.4 KiB
C++
//# 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 "std_string.h"
|
|
#include "forward_declarations.h"
|
|
#include "header_start.h"
|
|
|
|
TOML_IMPL_NAMESPACE_START
|
|
{
|
|
// Q: "why does print_to_stream() exist? why not just use ostream::write(), ostream::put() etc?"
|
|
// A: - I'm supporting C++20's char8_t as well; wrapping streams allows switching string modes transparently.
|
|
// - I'm using <charconv> to format numerics. Faster and locale-independent.
|
|
// - I can (potentially) avoid forcing users to drag in <sstream> and <iomanip>.
|
|
// - Strings in C++. Honestly.
|
|
|
|
TOML_API
|
|
TOML_ATTR(nonnull)
|
|
void print_to_stream(std::ostream&, const char*, size_t);
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, std::string_view);
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, const std::string&);
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, char);
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, int8_t, value_flags = {}, size_t min_digits = 0);
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, int16_t, value_flags = {}, size_t min_digits = 0);
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, int32_t, value_flags = {}, size_t min_digits = 0);
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, int64_t, value_flags = {}, size_t min_digits = 0);
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, uint8_t, value_flags = {}, size_t min_digits = 0);
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, uint16_t, value_flags = {}, size_t min_digits = 0);
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, uint32_t, value_flags = {}, size_t min_digits = 0);
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, uint64_t, value_flags = {}, size_t min_digits = 0);
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, float, value_flags = {});
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, double, value_flags = {});
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, bool);
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, const toml::date&);
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, const toml::time&);
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, const toml::time_offset&);
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, const toml::date_time&);
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, const source_position&);
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, const source_region&);
|
|
|
|
#if TOML_ENABLE_FORMATTERS
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, const array&);
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, const table&);
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, const value<std::string>&);
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, const value<int64_t>&);
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, const value<double>&);
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, const value<bool>&);
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, const value<date>&);
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, const value<time>&);
|
|
|
|
TOML_API
|
|
void print_to_stream(std::ostream&, const value<date_time>&);
|
|
|
|
#endif
|
|
|
|
template <typename T, typename U>
|
|
inline void print_to_stream_bookended(std::ostream & stream, const T& val, const U& bookend)
|
|
{
|
|
print_to_stream(stream, bookend);
|
|
print_to_stream(stream, val);
|
|
print_to_stream(stream, bookend);
|
|
}
|
|
}
|
|
TOML_IMPL_NAMESPACE_END;
|
|
|
|
#include "header_end.h"
|