xtd 0.2.0
Loading...
Searching...
No Matches
__iformatable_formatter.h
Go to the documentation of this file.
1
3#pragma once
5#if !defined(__XTD_CORE_INTERNAL__)
6#error "Do not include this file: Internal use only"
7#endif
9
10#include "__enum_formatter.h"
11#include "../iformatable.h"
12#include "../istringable.h"
13
15namespace xtd {
16 class object;
17}
18
19std::string __to_string_object_to_string(const xtd::object* obj);
20std::string __to_string_istringable_to_string(const xtd::istringable* obj);
21
22template<typename value_t>
23static std::string __to_string_polymorphic(const value_t& value, const std::string& fmt, const std::locale& loc, std::true_type) {
24 if (dynamic_cast<const std::exception*>(&value)) return std::string {"exception: "} + dynamic_cast<const std::exception&>(value).what();
25 if (dynamic_cast<const xtd::iformatable*>(&value)) return dynamic_cast<const xtd::iformatable&>(value).__opague_internal_formatable__(reinterpret_cast<intptr_t>(&fmt), reinterpret_cast<intptr_t>(&loc), 0, INTPTR_MAX);
26 if (dynamic_cast<const xtd::istringable*>(&value)) return __to_string_istringable_to_string(dynamic_cast<const xtd::istringable*>(&value));
27 if (dynamic_cast<const xtd::object*>(&value)) return __to_string_object_to_string(dynamic_cast<const xtd::object*>(&value));
28 __format_exception(typeid(value)); return {};
29}
30
31template<typename value_t>
32static std::string __to_string_polymorphic(const value_t& value, const std::string& fmt, const std::locale& loc, std::false_type) {
33 return __to_string_enum(value, fmt, loc, std::is_enum<value_t>());
34}
Contains __enum_formatter method.
Provides functionality to format the value of an object into a string representation.
Definition iformatable.h:35
Provides a way to represent the current object as a string.
Definition istringable.h:23
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:42
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10