Table Of Contents

Previous topic

SObjectClass Structure

Next topic

SObjectClass Functions

SObject Functions

Provides object type function.

Summary

SObjectSize Return the size of the given object in bytes.
SObjectIsType Test if an object is derived from the given object type.
SObjectType Get the given object’s type name.
SObjectInheritance Get the given object’s inheritance.
SObjectCompare Compare two objects.
SObjectRead Read an SObject from a data source reader.
SObjectWrite Write an SObject to a data source writer.
SObjectTypeIsReadable Query if object instances of the given type are readable.
SObjectIsWritable Query if the given object is writable in the given format.
SObjectSave Save the given object in the given format to the given path.
SObjectLoad Load data of an object in the given format from the given path.
SObjectIncRef Increment the object’s reference count.
SObjectDecRef Decrement the object’s reference count.
SObjectPrint Print the contents of the given SObject to a character buffer.
SObjectCopy Copy an SObject.

Query

size_t SObjectSize(const SObject *self, s_erc *error)

Return the size of the given object in bytes.

Parameters:
  • self

    The object.

  • error

    Error code.

Return:

The size of the object in bytes.

s_bool SObjectIsType(const SObject *self, const char *type, s_erc *error)

Test if an object is derived from the given object type.

Parameters:
  • self

    The object to test.

  • type

    The object type to test against.

  • error

    Error code.

Return:

TRUE or FALSE.

const char *SObjectType(const SObject *self, s_erc *error)

Get the given object’s type name.

Parameters:
  • self

    The given object.

  • error

    Error code.

Return:

Pointer to the given object’s type name.

const char *SObjectInheritance(const SObject *self, s_erc *error)

Get the given object’s inheritance.

Parameters:
  • self

    The given object.

  • error

    Error Code.

Return:

A colon (”:”) separated string of the given object’s inheritance hierarchy, excluding SObject.

s_bool SObjectCompare(const SObject *oa, const SObject *ob, s_erc *error)

Compare two objects.

Parameters:
  • oa

    First object of comparison.

  • ob

    Second object of comparison.

  • error

    Error code.

Return:

TRUE if the objects are the same, else FALSE.

Note:

The reference count of two objects needn’t be equal for objects to be equal.

Will only work if the SObjectClasscompare function pointer has been implemented for the object type, otherwise FALSE is returned.

Read/Write

void SObjectRead(SObject *self, const SSerializedObject *formater, SDataReader *reader, s_erc *error)

Read an SObject from a data source reader.

Parameters:
  • self

    The SObject to be read, the caller must create this SObject from the correct class beforehand.

  • formater

    The serialized object formater.

  • reader

    The serialized data reader.

  • error

    Error code.

void SObjectWrite(const SObject *self, const SSerializedObject *formater, SDataWriter *writer, s_erc *error)

Write an SObject to a data source writer.

Parameters:
  • self

    The SObject to be written.

  • formater

    The serialized object formater.

  • writer

    The serialized data writer.

  • error

    Error code.

s_bool SObjectTypeIsReadable(const char *object_type, const char *format, s_erc *error)

Query if object instances of the given type are readable.

Checks that there are SSerializedObjectClass classes registered to read object instances of the given type and in the given format.

Parameters:
  • object_type

    The object type to query for.

  • format

    Format in which the object is wished to be read.

  • error

    Error code.

Return:

TRUE or FALSE.

s_bool SObjectIsWritable(const SObject *object, const char *format, s_erc *error)

Query if the given object is writable in the given format.

Checks that there are SSerializedObjectClass classes registered to write the given object in the given format.

Parameters:
  • object

    The object for which the query is done.

  • format

    Format in which the object is wished to be written.

  • error

    Error code.

Return:

TRUE or FALSE.

Save/Load

void SObjectSave(const SObject *object, const char *path, const char *format, s_erc *error)

Save the given object in the given format to the given path.

Parameters:
  • object

    The object to save.

  • path

    The full path and file name of the object file.

  • format

    The format in which the object should be saved.

  • error

    Error code.

SObject *SObjectLoad(const char *path, const char *format, s_erc *error)

Load data of an object in the given format from the given path.

Parameters:
  • path

    The full path and file name of the object file.

  • format

    The format of the object file.

  • error

    Error code.

Return:

The loaded object.

Reference Counting

void SObjectIncRef(SObject *self)

Increment the object’s reference count.

Parameters:
Warning:

Use with care

void SObjectDecRef(SObject *self)

Decrement the object’s reference count.

Parameters:
Warning:

Use with care

Warning

Reference counting functions should be used with utmost care. They are normally not required, and are here just for expert use.

Miscellaneous

char *SObjectPrint(const SObject *self, s_erc *error)

Print the contents of the given SObject to a character buffer.

The caller is responsible for the memory of the buffer.

Parameters:
  • self

    The SObject to print.

  • error

    Error code.

Return:

Pointer to a character buffer containing the contents of the given SObject.

Note:

Will only work if the SObjectClassprint function pointer has been implemented for the object type, otherwise FALSE is returned.

Copy

SObject *SObjectCopy(const SObject *self, s_erc *error)

Copy an SObject.

Parameters:
  • self

    The SObject to copy.

  • error

    Error code.

Return:

Pointer to a copy of the given SObject.

Note:

This is a deep copy.

Caller is responsible for returned object’s memory.

Will only work if the SObjectClasscopy function pointer has been implemented for the object type, otherwise FALSE is returned.