xtd 0.2.0
Loading...
Searching...
No Matches
__iformatable_formatter.hpp
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
11#include "../iformatable.hpp"
12#include "../istringable.hpp"
13#include <type_traits>
14
16namespace xtd {
17 class object;
18}
19
20std::string __to_string_iformatable_to_string(const xtd::iformatable* obj, const std::string& fmt, const std::locale& loc);
21std::string __to_string_istringable_to_string(const xtd::istringable* obj);
22std::string __to_string_object_to_string(const xtd::object* obj);
23
24template<class value_t>
25inline static std::string __to_string_polymorphic(const value_t& value, const std::string& fmt, const std::locale& loc) {
26 if constexpr (std::is_base_of<xtd::iformatable, value_t>()) return __to_string_iformatable_to_string(static_cast<const xtd::iformatable*>(&value), fmt, loc);
27 else if constexpr (std::is_base_of<xtd::istringable, value_t>()) return __to_string_istringable_to_string(static_cast<const xtd::istringable*>(&value));
28 else if constexpr (std::is_base_of<xtd::object, value_t>()) return __to_string_object_to_string(static_cast<const xtd::object*>(&value));
29 else if constexpr (std::is_base_of<std::exception, value_t>()) return std::string {"exception: "} + static_cast<const std::exception&>(value).what();
31}
static void throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current())
Throws an exption with specified exception case.
Provides functionality to format the value of an object into a string representation.
Definition iformatable.hpp:42
Provides a way to represent the current object as a string.
Definition istringable.hpp:23
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:45
@ format_not_iformatable
The object is not iformatable.
Definition exception_case.hpp:59
Contains xtd::iformatable interface.
Contains xtd::istringable interface.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Contains xtd::helpers::throw_helper class.