40 mutable std::string cache_string_;
74 explicit operator std::string()
const;
82 explicit operator const char*()
const;
126 template<
typename TYPE>
138 template<Pr
intable TYPE>
150 template<EnumType TYPE>
170 template <
typename TYPE>
189 template<
typename TYPE>
207 template<
typename TYPE>
275 struct formatter<T> {
284 static constexpr auto parse(format_parse_context& ctx);
295 static auto format(
const T& p, format_context& ctx);
301inline original::printable::~printable() =
default;
310 std::stringstream
ss;
311 ss << this->className() <<
"(" << formatString(
this) <<
")";
316inline original::printable::operator std::string()
const {
317 return this->toString(
false);
320inline original::printable::operator
const char*()
const {
321 return this->toCString(
false);
326 this->cache_string_ = this->toString(
enter);
327 return this->cache_string_.c_str();
330template<
typename TYPE>
333 std::stringstream
ss;
334 ss <<
typeid(
t).
name() <<
"(" << formatString(&
t) <<
")";
338template<original::Pr
intable TYPE>
341 std::stringstream
ss;
346template <original::EnumType TYPE>
349 return formatEnum(
t);
352template <
typename TYPE>
356 std::make_unique<std::string>(formatString<TYPE>(t));
357 return result->c_str();
360template <
typename TYPE>
363 const std::string enum_name =
typeid(t).name();
364 const int enum_value =
static_cast<std::underlying_type_t<TYPE>
>(t);
369inline auto original::printable::formatString<std::nullptr_t>(
const std::nullptr_t&) -> std::string
375inline auto original::printable::formatString<std::string>(
const std::string& t) -> std::string
377 return "\"" + t +
"\"";
381inline auto original::printable::formatString<char>(
const char& t) -> std::string
383 return "'" + std::string(1, t) +
"'";
387inline auto original::printable::formatString<bool>(
const bool& t) -> std::string
389 return t ?
"true" :
"false";
392template <
typename TYPE>
398 std::stringstream ss;
404inline auto original::printable::formatString<const char>(
const char*
const &ptr) -> std::string {
405 return formatString<std::string>(ptr);
422constexpr auto std::formatter<T>::parse(std::format_parse_context &ctx) {
428auto std::formatter<T>::format(
const T &p, std::format_context &ctx) {
429 return formatter<std::string>().format(
static_cast<std::string
>(p), ctx);
Unique ownership smart pointer with move semantics.
Definition ownerPtr.h:37
Base class providing polymorphic string conversion capabilities.
Definition printable.h:39
const char * toCString(bool enter) const
Direct C-string access with formatting control.
Definition printable.h:324
static std::string formatString(const TYPE &t)
Universal value-to-string conversion with type-specific formatting.
Definition printable.h:339
static std::string formatString(TYPE *const &ptr)
Pointer-specific formatting with null safety.
friend std::ostream & operator<<(std::ostream &os, const printable &p)
Stream insertion operator for printable objects.
virtual std::string toString(bool enter) const
Generates formatted string representation.
Definition printable.h:308
virtual std::string className() const
Gets the class name for type identification.
Definition printable.h:303
static const char * formatCString(const TYPE &t)
C-string cache for temporary usage with static storage.
static std::string formatEnum(const TYPE &t)
Enum formatting utility with underlying value extraction.
static std::string formatString(const TYPE &t)
Specialization for types deriving from printable.
Checks derivation or type identity using std::derived_from.
Definition types.h:472
Main namespace for the project Original.
Definition algorithms.h:21
std::ostream & operator<<(std::ostream &os, const printable &p)
Stream insertion operator for printable objects.
Definition printable.h:408
Standard namespace extensions for original::alternative.
Definition allocator.h:351
std::string to_string(const T &t)
std::to_string overload for printable-derived types
Definition printable.h:415
Core type system foundations and concept definitions.