|
JH-Toolkit v1.4.1
An engineering-oriented C++20 toolkit with duck-typed concepts, static design, async coroutines, and semantic containers — header-only, RTTI-free, and concurrency-friendly.
|
Stream output adapters (operator<<) for POD containers and utilities.
More...
#include "jh/pods/pod_like.h"#include <ostream>#include <sstream>#include <iomanip>#include "jh/typing/monostate.h"#include "jh/serialize_io/base64.h"#include "jh/macros/type_name.h"#include "jh/pods/array.h"#include "jh/pods/bits.h"#include "jh/pods/bytes_view.h"#include "jh/pods/optional.h"#include "jh/pods/pair.h"#include "jh/pods/span.h"#include "jh/pods/string_view.h"#include "jh/pods/tuple.h"Go to the source code of this file.
Namespaces | |
| namespace | jh::pod |
| Aggregated entry point for Plain-Old-Data and layout-stable value utilities. | |
| namespace | jh::typed |
| Aggregated entry point for lightweight typing and semantic placeholder utilities. | |
Concepts | |
| concept | jh::pod::streamable |
Checks whether a type can be streamed to std::ostream. | |
| concept | jh::pod::streamable_pod |
Debug-only constraint for POD-like types printable to std::ostream. | |
Functions | |
| template<streamable T, std::uint16_t N> | |
| std::ostream & | jh::pod::operator<< (std::ostream &os, const jh::pod::array< T, N > &arr) |
| template<std::uint16_t N> | |
| std::ostream & | jh::pod::operator<< (std::ostream &os, const jh::pod::array< char, N > &str) |
| std::ostream & | jh::pod::operator<< (std::ostream &os, jh::typed::monostate &) |
| template<streamable T1, streamable T2> | |
| std::ostream & | jh::pod::operator<< (std::ostream &os, const jh::pod::pair< T1, T2 > &t) |
| template<streamable T> | |
| std::ostream & | jh::pod::operator<< (std::ostream &os, const jh::pod::optional< T > &opt) |
| template<std::uint16_t N> | |
| std::ostream & | jh::pod::operator<< (std::ostream &os, const jh::pod::bitflags< N > &flags) |
| std::ostream & | jh::pod::operator<< (std::ostream &os, const jh::pod::bytes_view bv) |
| template<streamable T> | |
| std::ostream & | jh::pod::operator<< (std::ostream &os, const span< T > &sp) |
| std::ostream & | jh::pod::operator<< (std::ostream &os, const string_view &sv) |
| template<streamable_pod Pod> | |
| std::string | jh::pod::to_string (const Pod &p) |
| template<streamable... Ts> | |
| std::ostream & | jh::pod::operator<< (std::ostream &os, const jh::pod::tuple< Ts... > &t) |
| std::ostream & | jh::typed::operator<< (std::ostream &os, const jh::typed::monostate &) |
Stream output adapters (operator<<) for POD containers and utilities.
This header provides inline operator<< overloads for types in jh::pod, producing human-readable, debug-friendly representations on std::ostream.
operator<< / to_string overloads. jh::utils::base64 helpers, which provide proper encode/decode. inline. In C++17+, this does not force inlining, but provides weak linkage semantics, allowing safe inclusion in multiple translation units without ODR violations, and optional overriding elsewhere. Provides a minimal and consistent interface for encoding and decoding binary data.
std::string encode(const std::uint8_t *data, std::size_t len) noexcept;
Encode raw bytes into a Base64 string.
std::vector<std::uint8_t> decode(const std::string &input);
Decode a Base64 string into a new byte buffer.
jh::pod::bytes_view decode(const std::string &input, std::vector<std::uint8_t>& buffer);
Decode into a provided std::vector<std::uint8_t> and return a bytes_view pointing into it (useful for flat binary operations).
jh::pod::string_view decode(const std::string &input, std::string& buffer);std::string and return a string_view pointing into it (useful for text-like operations). These APIs are suitable for real serialization and deserialization, unlike the human-readable printers in this file.
These APIs provide predictable serialization and deserialization. Use them if you need to persist or exchange data between systems.
Stream adapters (operator<<) follow a layered visual convention distinguishing between owning types, view types, and semantic wrappers.
pod::array<T, N> → [1, 2, 3] pod::array<char, N> → "escaped\tstring" pod::pair<T1, T2> → {a, b} pod::tuple<Ts...> → (), (1,), (1, 2, 3) pod::span<T> → span<int>[1, 2, 3] pod::string_view → string_view"hello" pod::bytes_view → base64'...' pod::optional<T> → value or nullopt typed::monostate → null pod::bitflags<N> → 0x'ABCD' or 0b'0101' pod::array<pod::tuple<int, int>, 2> → [(1, 2), (3, 4)]