xtd - Reference Guide  0.1.1
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Modules | Classes | Functions
system

Definition

Contains system classes.

Modules

 collections
 collections definitions.
 
 diagnostics
 diagnostics definitions.
 
 io
 io definitions.
 
 media
 media definitions.
 
 net
 Network definitions.
 
 web
 web definitions.
 

Classes

class  xtd::bit_converter
 Converts base data types to an std::vector of bytes, and an std::vector of bytes to base data types. More...
 
class  xtd::console
 Represents the standard input, output, and error streams for console applications. More...
 
class  xtd::convert
 Represents API to convert base type code. More...
 
class  xtd::convert_pointer
 Represents API to convert pointers. More...
 
class  xtd::convert_string
 Represents API to convert string containers. More...
 
class  xtd::environment
 The environment class. More...
 
struct  xtd::guid
 Represents a globally unique identifier (GUID). A GUID is a 128-bit integer (16 bytes) that can be used across all computers and networks wherever a unique identifier is required. Such an identifier has a very low probability of being duplicated. More...
 
class  xtd::math
 Provides constants and static methods for trigonometric, logarithmic, and other common mathematical functions. More...
 
class  xtd::random
 Represents a pseudo-random number generator, a device that produces a sequence of numbers that meet certain statistical requirements for randomness. More...
 
class  xtd::translator
 Represents translator class. This class cannot be inherited. More...
 
class  xtd::ustring
 Represents text as a sequence of UTF-8 code units. More...
 
class  xtd::version
 Represents the version number of an assembly, operating system, or the xtd. This class cannot be inherited. More...
 

Functions

template<class type_t , class function_t >
void xtd::register_any_stringer (const function_t &func)
 Register an any stringer method for a specified type. More...
 

Function Documentation

◆ register_any_stringer()

template<class type_t , class function_t >
void xtd::register_any_stringer ( const function_t &  func)
inline

#include <xtd.core/include/xtd/any.h>

Register an any stringer method for a specified type.

Parameters
funcFunction to register any stringer for specified type.
Namespace
xtd
Library
xtd.core
Example
Show how to register your own class.
#include <xtd/xtd>
using namespace std;
using namespace xtd;
class character {
public:
character(const ustring& name, const ustring& rank) noexcept : name_(name), rank_(rank) {}
const ustring& name() const noexcept {return name_;}
const ustring& rank() const noexcept {return rank_;}
ustring to_string() const noexcept {return name_ + " (" + rank_ + ")";}
private:
ustring name_;
ustring rank_;
};
int main() {
any value = make_any<int>(42);
cout << ustring::format("{}", value) << endl;
value = make_any<ustring>("Star Trek: The Next Generation");
cout << ustring::format("{}", value) << endl;
value = character("Jean-Luc Picard", "Captain");
cout << ustring::format("{}", value) << endl;
register_any_stringer<character>([](character value) {return value.to_string();});
cout << ustring::format("{}", value) << endl;
}
// This code produces the following output :
//
static ustring format(const ustring &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition: ustring.h:689
std::string to_string(const value_t &value, const std::string &fmt, const std::locale &loc)
Convert a specified value into a string with specified format and locale.
Definition: to_string.h:37
@ any
Indicates that all styles except allow_binary_specifier, allow_octal_specifier and allow_hex_specifie...
@ character
Specifies that the text is trimmed to the nearest character.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17