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.
Public Member Functions | Static Public Member Functions | List of all members
xtd::object Class Reference

#include <object.h>

Definition

Supports all classes in the xtd class hierarchy and provides low-level services to derived classes. This is the ultimate base class of all classes in the xtd. It is the root of the type hierarchy.

Namespace
xtd
Library
xtd.core
Examples
The following example defines a point type derived from the Oobject class and virtuals many of the virtual methods of the object class. In addition, the example shows how to call many of the static and instance methods of the object class.

Public Member Functions

 object ()=default
 Create a new instance of the ultimate base class object. More...
 
virtual bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object. More...
 
virtual size_t get_hash_code () const noexcept
 Serves as a hash function for a particular type. More...
 
template<typename object_t >
std::unique_ptr< object_t > memberwise_clone () const
 Gets the type of the current instance. More...
 
virtual xtd::ustring to_string () const noexcept
 Returns a std::string that represents the current object. More...
 

Static Public Member Functions

static bool equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are considered equal. More...
 
static bool reference_equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are the same instance. More...
 

Constructor & Destructor Documentation

◆ object()

xtd::object::object ( )
default

Create a new instance of the ultimate base class object.

Remarks
This constructor is called by constructors in derived classes, but it can also be used to directly create an instance of the object class.

Member Function Documentation

◆ equals() [1/2]

virtual bool xtd::object::equals ( const object obj) const
virtualnoexcept

Determines whether the specified object is equal to the current object.

Parameters
objThe object to compare with the current object.
Returns
true if the specified object is equal to the current object. otherwise, false.
Examples
The following code example compares the current instance with another object.

Reimplemented in xtd::guid, and xtd::net::ip_address.

◆ equals() [2/2]

static bool xtd::object::equals ( const object object_a,
const object object_b 
)
staticnoexcept

Determines whether the specified object instances are considered equal.

Parameters
object_aThe first object to compare.
object_bThe second object to compare.
Returns
true if object_a is the same instance as object_b or if both are null references or if object_a(object_b) returns true. otherwise, false.
Examples
The following code example compares different objects.

◆ get_hash_code()

virtual size_t xtd::object::get_hash_code ( ) const
virtualnoexcept

Serves as a hash function for a particular type.

Returns
size_t A hash code for the current object.

Reimplemented in xtd::ustring.

◆ memberwise_clone()

template<typename object_t >
std::unique_ptr<object_t> xtd::object::memberwise_clone ( ) const
inline

Gets the type of the current instance.

Returns
The type instance that represents the exact runtime type of the current instance.
Examples
The following code example demonstrates that GetType returns the runtime type of the current instance.
Creates a shallow copy of the current object.
Returns
A shallow copy of the current object.
Examples
The following code example shows how to copy an instance of a class using memberwise_clone.

◆ reference_equals()

static bool xtd::object::reference_equals ( const object object_a,
const object object_b 
)
staticnoexcept

Determines whether the specified object instances are the same instance.

Parameters
object_aThe first object to compare.
object_bThe second object to compare.
Returns
true if object_a is the same instance as object_b or if both are null references; otherwise, false.
Examples
The following code example uses reference_equals to determine if two objects are the same instance.

◆ to_string()

virtual xtd::ustring xtd::object::to_string ( ) const
virtualnoexcept

The documentation for this class was generated from the following file: