xtd_c - Reference Guide 0.2.0
object

Definition

Represent an instance of the ultimate base object.

Data Structures

struct  xtd_object
 Represent an instance of the ultimate base object. More...
 

Converter

#define XTD_OBJECT(object)   (XTD_TYPE_CAST(object, XTD_OBJECT_TYPE, xtd_object))
 Convert an xtd object to ultimate base object. More...
 

Creation/Destruction

xtd_objectxtd_object_create (void)
 Create a new instance of the ultimate base object. More...
 
void xtd_object_destroy (xtd_object *value)
 Destroy the instance of the specfied object. More...
 

Methods

const char * xtd_object_to_string (const xtd_object *value)
 Returns a string that represents the specified object. More...
 
size_t xtd_object_to_string_s (const xtd_object *value, char *string, size_t size)
 Returns a string that represents the specified object. More...
 

Macro Definition Documentation

◆ XTD_OBJECT

#define XTD_OBJECT (   object)    (XTD_TYPE_CAST(object, XTD_OBJECT_TYPE, xtd_object))

Convert an xtd object to ultimate base object.

Library
xtd_c.core

Function Documentation

◆ xtd_object_create()

xtd_object* xtd_object_create ( void  )

Create a new instance of the ultimate base object.

Returns
New object created.
Library
xtd_c.core
Remarks
You must call xtd_object_destroy to free memory and resources.
Examples
This example shows how to use xtd_object_create and xtd_object_destroy to create and destroy an xtd_object.
int main(int argc, char* argv[]) {
}

◆ xtd_object_destroy()

void xtd_object_destroy ( xtd_object value)

Destroy the instance of the specfied object.

Parameters
valueThe object to delete.
Library
xtd_c.core
Remarks
You can use this method to destroy any xtd object.
Examples
This example shows how to use xtd_object_create and xtd_object_destroy to create and destroy an xtd_object.
int main(int argc, char* argv[]) {
}
This example shows how to use xtd_object_destroy to destroy an xtd_version object by using the XTD_OBJECT method to convert xtd_version to xtd_object.
int main(int argc, char* argv[]) {
xtd_version* version = xtd_create_version(1, 2, 3);
}

◆ xtd_object_to_string()

const char* xtd_object_to_string ( const xtd_object value)

Returns a string that represents the specified object.

Parameters
valueThe object to retrieve the string.
Returns
pointer to the string that will contain the representation of the specified object.
Library
xtd_c.core

◆ xtd_object_to_string_s()

size_t xtd_object_to_string_s ( const xtd_object value,
char *  string,
size_t  size 
)

Returns a string that represents the specified object.

Parameters
valueThe object to retrieve the string.
stringA pointer to the string that will contain the representation of the specified object.
sizeThe size og the specified string.
Returns
The size in characters of the representation of the specified object.
Library
xtd_c.core
Remarks
If the string is NULL, this method returns only the necessary size with the ending 0 character that you can use to allocate your string.
Examples
This example shows how to use xtd_object_to_string with an xtd_version object.
int main(int argc, char* argv[]) {
xtd_version* version = xtd_create_version(1, 2, 3);
size_t size = xtd_object_to_string(XTD_OBJECT(version), NULL, 0);
char version_string[256];
xtd_object_to_string(XTD_OBJECT(version), version_string, 256);
console::write_line("%s", version_string);
xtd_version_destroy(version);
}
Examples
This example shows how to use xtd_object_to_string with the xtd_version object by using the possibility to get the size before allocating the string.
xtd_version* version = xtd_create_version(1, 2, 3);
size_t size = xtd_object_to_string(XTD_OBJECT(version), NULL, 0);
char* version_string = (char*)malloc(size);
xtd_object_to_string(XTD_OBJECT(version), version_string, size);
console_write_line("%s", version_string);
free(version_string);
xtd_version_destroy(version);
}