xtd - Reference Guide  0.1.0
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.
 
 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 the string container converter class. 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 translatoor 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 :
//