GenericContainer
GenericContaine a tool for C++ programming
Loading...
Searching...
No Matches
GenericContainer C Interface

This module provides the C interface for the GenericContainer class. More...

Classes

struct  c_complex_type
 A structure representing a complex number, with real and imaginary components. More...
 

Enumerations

enum  {
  GENERIC_CONTAINER_OK = 0 , GENERIC_CONTAINER_BAD_TYPE , GENERIC_CONTAINER_NO_DATA , GENERIC_CONTAINER_NOT_EMPTY ,
  GENERIC_CONTAINER_BAD_HEAD
}
 

Functions

int GC_new (char const id[])
 Create a new GenericContainer object.
 
int GC_select (char const id[])
 Select an existing GenericContainer object.
 
int GC_delete (char const id[])
 Delete a GenericContainer object.
 
int GC_fill_for_test (char const id[])
 Fill a GenericContainer with test data.
 
int GC_pop_head ()
 Move the head pointer up one level in the GenericContainer.
 
int GC_reset_head ()
 Reset the head pointer to the first level in the GenericContainer.
 
int GC_dump ()
 Dump the contents of the current GenericContainer.
 
int GC_print_content_types ()
 Print the content types of the current GenericContainer.
 
int GC_get_type ()
 Retrieve the type of the current element pointed by the head in the GenericContainer.
 
char const * GC_get_type_name ()
 Retrieve the name of the type of the current element in the GenericContainer.
 
void * GC_mem_ptr (char const id[])
 Get a pointer to the internal memory of the GenericContainer object.
 
int GC_set_bool (int a)
 
int GC_set_int (int a)
 Set the current element of the GenericContainer to an integer value.
 
int GC_set_real (double a)
 Set the current element of the GenericContainer to a real number.
 
int GC_set_complex (c_complex_type const *a)
 Set the current element of the GenericContainer to a complex number.
 
int GC_set_complex2 (double re, double im)
 Set the current element of the GenericContainer to a complex number using real and imaginary parts.
 
int GC_set_string (char const a[])
 Set the current element of the GenericContainer to a string.
 
int GC_get_bool ()
 Retrieve the boolean value from the current element of the GenericContainer.
 
int GC_get_int ()
 Retrieve the integer value from the current element of the GenericContainer.
 
long GC_get_long ()
 Retrieve the long integer value from the current element of the GenericContainer.
 
double GC_get_real ()
 Retrieve the real number value from the current element of the GenericContainer.
 
c_complex_type GC_get_complex ()
 Retrieve the complex number from the current element of the GenericContainer.
 
double GC_get_complex_re ()
 Retrieve the real part of a complex number from the current element of the GenericContainer.
 
double GC_get_complex_im ()
 Retrieve the imaginary part of a complex number from the current element of the GenericContainer.
 
char const * GC_get_string ()
 Retrieve the string from the current element of the GenericContainer.
 
int GC_push_bool (int a)
 Append a boolean value to the currently selected vector of booleans in the GenericContainer.
 
int GC_push_int (int a)
 Append an integer value to the currently selected vector of integers in the GenericContainer.
 
int GC_push_real (double a)
 Append a floating-point value to the currently selected vector of real numbers in the GenericContainer.
 
int GC_push_complex (c_complex_type const *a)
 Append a complex number to the currently selected vector of complex numbers in the GenericContainer.
 
int GC_push_complex2 (double re, double im)
 Append a complex number to the currently selected vector using real and imaginary parts.
 
int GC_push_string (char const a[])
 Append a string to the currently selected vector of strings in the GenericContainer.
 
int GC_get_bool_at_pos (int pos)
 Retrieve a boolean value at a specified position from a vector of booleans in the GenericContainer.
 
int GC_get_int_at_pos (int pos)
 Retrieve an integer value at a specified position from a vector of integers in the GenericContainer.
 
double GC_get_real_at_pos (int pos)
 Retrieve a real number at a specified position from a vector of real numbers in the GenericContainer.
 
c_complex_type GC_get_complex_at_pos (int pos)
 Retrieve a complex number at a specified position from a vector of complex numbers in the GenericContainer.
 
double GC_get_complex_real_at_pos (int pos)
 Retrieve the real part of a complex number at a specified position from a vector of complex numbers.
 
double GC_get_complex_imag_at_pos (int pos)
 Retrieve the imaginary part of a complex number at a specified position from a vector of complex numbers.
 
char const * GC_get_string_at_pos (int pos)
 Retrieve a string at a specified position from a vector of strings in the GenericContainer.
 
double GC_get_real_at_coor (int i, int j)
 Retrieve a real number at the specified row and column from a matrix of real numbers in the GenericContainer.
 
c_complex_type GC_get_complex_at_coor (int i, int j)
 Retrieve a complex number at the specified row and column from a matrix of complex numbers.
 
double GC_get_complex_real_at_coor (int i, int j)
 Retrieve the real part of a complex number at the specified row and column from a matrix.
 
double GC_get_complex_imag_at_coor (int i, int j)
 Retrieve the imaginary part of a complex number at the specified row and column from a matrix.
 
int GC_set_empty_vector_of_bool ()
 Initialize the current element of the GenericContainer to an empty vector of booleans.
 
int GC_set_empty_vector_of_int ()
 Initialize the current element of the GenericContainer to an empty vector of integers.
 
int GC_set_empty_vector_of_real ()
 Initialize the current element of the GenericContainer to an empty vector of real numbers.
 
int GC_set_empty_vector_of_complex ()
 Initialize the current element of the GenericContainer to an empty vector of complex numbers.
 
int GC_set_empty_vector_of_string ()
 Initialize the current element of the GenericContainer to an empty vector of strings.
 
int GC_set_vector_of_bool (int const *a, int nelem)
 Set the current element of the GenericContainer to a vector of booleans, and copy the provided values.
 
int GC_set_vector_of_int (int const *a, int nelem)
 Set the current element of the GenericContainer to a vector of integers, and copy the provided values.
 
int GC_set_vector_of_real (double const *a, int nelem)
 Set the current element of the GenericContainer to a vector of real numbers, and copy the provided values.
 
int GC_set_vector_of_complex (double const *re, double const *im, int nelem)
 Set the current element of the GenericContainer to a vector of complex numbers, and copy the provided values.
 
int GC_set_vector_of_string (char const **a, int nelem)
 Set the current element of the GenericContainer to a vector of strings, and copy the provided values.
 
int GC_set_vector (int nelem)
 Set the current element of the GenericContainer to a vector of GenericContainer elements with the specified size.
 
int GC_set_empty_vector ()
 Set the current element of the GenericContainer to an empty vector of GenericContainer elements.
 
int GC_get_vector_size ()
 Retrieve the number of elements in the current vector of the GenericContainer.
 
int GC_get_matrix_num_rows ()
 Retrieve the number of rows in the current matrix of the GenericContainer.
 
int GC_get_matrix_num_cols ()
 Retrieve the number of columns in the current matrix of the GenericContainer.
 
int GC_push_vector_position (int pos)
 Set the insertion point in the current vector of the GenericContainer.
 
int GC_set_map ()
 Initialize the current element of the GenericContainer to a map.
 
int GC_init_map_key ()
 Initialize the current element as a map key in the GenericContainer.
 
char const * GC_get_next_key (void)
 Retrieve the key of the next element in a map from the GenericContainer.
 
int GC_push_map_position (char const pos[])
 Set the insertion point to the specified key in the current map of the GenericContainer.
 

Detailed Description

This module provides the C interface for the GenericContainer class.

The GenericContainer (GC) module offers a flexible container for storing various data types such as booleans, integers, floating-point numbers, complex numbers, and strings. It also supports structured data types such as vectors and maps. The C interface allows for seamless interaction with the container, enabling users to perform operations like adding elements, retrieving data, and managing hierarchical structures.

Functionality includes:

Basic Usage Pattern

  1. Initialization: Create an empty container.
  2. Setting Data: Populate the container with the desired data type.
  3. Accessing Data: Retrieve data stored within the container.
  4. Manipulation: Modify or update data within the container.

Let's go through these steps in more detail.

Initialization of a GenericContainer

To start using a GenericContainer, you need to initialize it using the GC_init() function. Once initialized, the container is ready to store any supported data type.

int main() {
// Initialize an empty container
GenericContainer gc;
GC_init(&gc);
// Further operations on the container
GC_clear(&gc); // Clear the container at the end
return 0;
}

Setting Data in the GenericContainer

The GenericContainer can store different types of data. Below are examples of how to set various types of data.

Set an Integer

To store an integer, use the GC_set_int() function.

GC_set_int(&gc, 42);
int GC_set_int(int a)
Set the current element of the GenericContainer to an integer value.

Set a Real Number

To store a floating-point number, use GC_set_real():

GC_set_real(&gc, 3.14159);
int GC_set_real(double a)
Set the current element of the GenericContainer to a real number.

Set a String

You can store a string using the GC_set_string() function:

GC_set_string(&gc, "Hello, GenericContainer!");
int GC_set_string(char const a[])
Set the current element of the GenericContainer to a string.

Set a Vector of Integers

If you want to store an array of integers, use the GC_set_vector_of_int() function:

int values[] = {1, 2, 3, 4, 5};
GC_set_vector_of_int(&gc, values, 5);
int GC_set_vector_of_int(int const *a, int nelem)
Set the current element of the GenericContainer to a vector of integers, and copy the provided values...

Accessing Data from the GenericContainer

Once data is stored in the GenericContainer, you can retrieve it using the appropriate getter functions.

Retrieve an Integer

int value = GC_get_int(&gc);
printf("Integer value: %d\n", value);
int GC_get_int()
Retrieve the integer value from the current element of the GenericContainer.

Retrieve a Real Number

double real_value = GC_get_real(&gc);
printf("Real value: %f\n", real_value);
double GC_get_real()
Retrieve the real number value from the current element of the GenericContainer.

Retrieve a String

const char* str = GC_get_string(&gc);
printf("String: %s\n", str);
char const * GC_get_string()
Retrieve the string from the current element of the GenericContainer.

Retrieve Elements from a Vector of Integers

To retrieve elements from a vector, use GC_get_vector_size() to get the size of the vector, and GC_get_int_at_pos() to access individual elements.

int size = GC_get_vector_size(&gc);
for (int i = 0; i < size; ++i) {
int elem = GC_get_int_at_pos(&gc, i);
printf("Element %d: %d\n", i, elem);
}
int GC_get_vector_size()
Retrieve the number of elements in the current vector of the GenericContainer.
int GC_get_int_at_pos(int pos)
Retrieve an integer value at a specified position from a vector of integers in the GenericContainer.

Advanced Manipulation: Vectors and Maps

The GenericContainer also supports more complex structures like vectors of vectors or maps (key-value pairs). This allows you to represent hierarchical or complex data.

Creating a Vector of GenericContainer

You can create a vector of GenericContainer objects, where each element may hold a different data type:

GC_set_vector(&gc, 3); // Initialize a vector of 3 elements
GC_push_vector_position(0); // Select the first element
GC_set_int(&gc, 10); // Set an integer in the first element
GC_push_vector_position(1); // Select the second element
GC_set_real(&gc, 2.718); // Set a real number in the second element
int GC_push_vector_position(int pos)
Set the insertion point in the current vector of the GenericContainer.
int GC_set_vector(int nelem)
Set the current element of the GenericContainer to a vector of GenericContainer elements with the spe...

Creating a Map

You can create a map where each key is associated with a value. For example, to map a string to another value:

GC_set_map(&gc); // Initialize a map
GC_push_map_position("key"); // Insert an element with key "key"
GC_set_string(&gc, "value"); // Set a string value for the key
int GC_push_map_position(char const pos[])
Set the insertion point to the specified key in the current map of the GenericContainer.
int GC_set_map()
Initialize the current element of the GenericContainer to a map.

Cleanup and Deallocation

At the end of the lifecycle of a GenericContainer, it's important to release the memory using GC_clear():

GC_clear(&gc);

Error Handling

Many GenericContainer functions return an error code to help you detect and handle issues. For example, after setting an integer, check the return code:

int ret = GC_set_int(&gc, 42);
if (ret != 0) {
printf("Error setting integer\n");
}

Key Functions

Function Description
GC_init(GenericContainer*) Initializes a GenericContainer.
GC_set_int(GenericContainer*, int) Sets an integer in the container.
GC_set_real(GenericContainer*, double) Sets a floating-point number in the container.
GC_set_string(GenericContainer*, const char*) Sets a string in the container.
GC_set_vector_of_int(GenericContainer*, const int*, int) Sets an integer vector.
GC_get_int(const GenericContainer*) Retrieves an integer from the container.
GC_get_real(const GenericContainer*) Retrieves a floating-point number.
GC_get_string(const GenericContainer*) Retrieves a string.
GC_clear(GenericContainer*) Frees the memory used by the container.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
GENERIC_CONTAINER_OK 
GENERIC_CONTAINER_BAD_TYPE 
GENERIC_CONTAINER_NO_DATA 
GENERIC_CONTAINER_NOT_EMPTY 
GENERIC_CONTAINER_BAD_HEAD 

Function Documentation

◆ GC_delete()

int GC_delete ( char const id[])

Delete a GenericContainer object.

Parameters
[in]idA string identifying the GenericContainer to delete.
Returns
Error code: 0 = OK.

◆ GC_dump()

int GC_dump ( )

Dump the contents of the current GenericContainer.

Returns
Error code: 0 = OK.

◆ GC_fill_for_test()

int GC_fill_for_test ( char const id[])

Fill a GenericContainer with test data.

Parameters
[in]idA string identifying the GenericContainer.
Returns
Error code: 0 = OK.

◆ GC_get_bool()

int GC_get_bool ( )

Retrieve the boolean value from the current element of the GenericContainer.

This function returns the boolean value (stored as an integer) from the currently selected element of the GenericContainer. If the element is not of the correct type, an error code or unexpected value may be returned.

Returns
The boolean value (as integer, 0 = false, 1 = true).

◆ GC_get_bool_at_pos()

int GC_get_bool_at_pos ( int pos)

Retrieve a boolean value at a specified position from a vector of booleans in the GenericContainer.

This function retrieves the boolean value (stored as an integer) at position pos from a vector of booleans in the currently selected element of the GenericContainer. If the element is not a vector or if pos is out of range, an error code or unexpected value may be returned.

Parameters
[in]posIndex position of the value to be retrieved.
Returns
The boolean value at the specified position.

◆ GC_get_complex()

c_complex_type GC_get_complex ( )

Retrieve the complex number from the current element of the GenericContainer.

This function returns the complex number (as a c_complex_type structure) from the currently selected element of the GenericContainer. If the element is not of the correct type, an error code or unexpected value may be returned.

Returns
The complex number value as c_complex_type.

◆ GC_get_complex_at_coor()

c_complex_type GC_get_complex_at_coor ( int i,
int j )

Retrieve a complex number at the specified row and column from a matrix of complex numbers.

This function retrieves the complex number (as a c_complex_type structure) at the matrix coordinates (row i, column j) from a matrix of complex numbers in the currently selected element of the GenericContainer. If the element is not a matrix or if the coordinates are out of range, an error code or unexpected value may be returned.

Parameters
[in]iRow index of the value to be retrieved.
[in]jColumn index of the value to be retrieved.
Returns
The complex number at the specified coordinates.

◆ GC_get_complex_at_pos()

c_complex_type GC_get_complex_at_pos ( int pos)

Retrieve a complex number at a specified position from a vector of complex numbers in the GenericContainer.

This function retrieves the complex number (as a c_complex_type structure) at position pos from a vector of complex numbers in the currently selected element of the GenericContainer. If the element is not a vector or if pos is out of range, an error code or unexpected value may be returned.

Parameters
[in]posIndex position of the value to be retrieved.
Returns
The complex number at the specified position.

◆ GC_get_complex_im()

double GC_get_complex_im ( )

Retrieve the imaginary part of a complex number from the current element of the GenericContainer.

This function returns the imaginary part of a complex number stored in the currently selected element of the GenericContainer. If the element is not of the correct type, an error code or unexpected value may be returned.

Returns
The imaginary part of the complex number.

◆ GC_get_complex_imag_at_coor()

double GC_get_complex_imag_at_coor ( int i,
int j )

Retrieve the imaginary part of a complex number at the specified row and column from a matrix.

This function retrieves the imaginary part of a complex number at the matrix coordinates (row i, column j) from a matrix of complex numbers in the currently selected element of the GenericContainer. If the element is not a matrix or if the coordinates are out of range, an error code or unexpected value may be returned.

Parameters
[in]iRow index of the value to be retrieved.
[in]jColumn index of the value to be retrieved.
Returns
The imaginary part of the complex number at the specified coordinates.

◆ GC_get_complex_imag_at_pos()

double GC_get_complex_imag_at_pos ( int pos)

Retrieve the imaginary part of a complex number at a specified position from a vector of complex numbers.

This function retrieves the imaginary part of a complex number at position pos from a vector of complex numbers in the currently selected element of the GenericContainer. If the element is not a vector or if pos is out of range, an error code or unexpected value may be returned.

Parameters
[in]posIndex position of the value to be retrieved.
Returns
The imaginary part of the complex number at the specified position.

◆ GC_get_complex_re()

double GC_get_complex_re ( )

Retrieve the real part of a complex number from the current element of the GenericContainer.

This function returns the real part of a complex number stored in the currently selected element of the GenericContainer. If the element is not of the correct type, an error code or unexpected value may be returned.

Returns
The real part of the complex number.

◆ GC_get_complex_real_at_coor()

double GC_get_complex_real_at_coor ( int i,
int j )

Retrieve the real part of a complex number at the specified row and column from a matrix.

This function retrieves the real part of a complex number at the matrix coordinates (row i, column j) from a matrix of complex numbers in the currently selected element of the GenericContainer. If the element is not a matrix or if the coordinates are out of range, an error code or unexpected value may be returned.

Parameters
[in]iRow index of the value to be retrieved.
[in]jColumn index of the value to be retrieved.
Returns
The real part of the complex number at the specified coordinates.

◆ GC_get_complex_real_at_pos()

double GC_get_complex_real_at_pos ( int pos)

Retrieve the real part of a complex number at a specified position from a vector of complex numbers.

This function retrieves the real part of a complex number at position pos from a vector of complex numbers in the currently selected element of the GenericContainer. If the element is not a vector or if pos is out of range, an error code or unexpected value may be returned.

Parameters
[in]posIndex position of the value to be retrieved.
Returns
The real part of the complex number at the specified position.

◆ GC_get_int()

int GC_get_int ( )

Retrieve the integer value from the current element of the GenericContainer.

This function returns the integer value from the currently selected element of the GenericContainer. If the element is not of the correct type, an error code or unexpected value may be returned.

Returns
The integer value.

◆ GC_get_int_at_pos()

int GC_get_int_at_pos ( int pos)

Retrieve an integer value at a specified position from a vector of integers in the GenericContainer.

This function retrieves the integer value at position pos from a vector of integers in the currently selected element of the GenericContainer. If the element is not a vector or if pos is out of range, an error code or unexpected value may be returned.

Parameters
[in]posIndex position of the value to be retrieved.
Returns
The integer value at the specified position.

◆ GC_get_long()

long GC_get_long ( )

Retrieve the long integer value from the current element of the GenericContainer.

This function returns the long integer value from the currently selected element of the GenericContainer. If the element is not of the correct type, an error code or unexpected value may be returned.

Returns
The long integer value.

◆ GC_get_matrix_num_cols()

int GC_get_matrix_num_cols ( )

Retrieve the number of columns in the current matrix of the GenericContainer.

This function returns the number of columns in the currently selected matrix of the GenericContainer. If the element is not a matrix, an error code or unexpected value may be returned.

Returns
The number of columns in the current matrix, or an error code.

◆ GC_get_matrix_num_rows()

int GC_get_matrix_num_rows ( )

Retrieve the number of rows in the current matrix of the GenericContainer.

This function returns the number of rows in the currently selected matrix of the GenericContainer. If the element is not a matrix, an error code or unexpected value may be returned.

Returns
The number of rows in the current matrix, or an error code.

◆ GC_get_next_key()

char const * GC_get_next_key ( void )

Retrieve the key of the next element in a map from the GenericContainer.

This function returns the key of the next element in a map within the GenericContainer. If the element is not a map or there are no more keys, an error code or unexpected value may be returned.

Returns
The key as a C-string (null-terminated), or an error code.

◆ GC_get_real()

double GC_get_real ( )

Retrieve the real number value from the current element of the GenericContainer.

This function returns the floating-point value from the currently selected element of the GenericContainer. If the element is not of the correct type, an error code or unexpected value may be returned.

Returns
The floating-point value.

◆ GC_get_real_at_coor()

double GC_get_real_at_coor ( int i,
int j )

Retrieve a real number at the specified row and column from a matrix of real numbers in the GenericContainer.

This function retrieves a floating-point value at the matrix coordinates (row i, column j) from a matrix of real numbers in the currently selected element of the GenericContainer. If the element is not a matrix or if the coordinates are out of range, an error code or unexpected value may be returned.

Parameters
[in]iRow index of the value to be retrieved.
[in]jColumn index of the value to be retrieved.
Returns
The floating-point value at the specified coordinates.

◆ GC_get_real_at_pos()

double GC_get_real_at_pos ( int pos)

Retrieve a real number at a specified position from a vector of real numbers in the GenericContainer.

This function retrieves the floating-point value at position pos from a vector of real numbers in the currently selected element of the GenericContainer. If the element is not a vector or if pos is out of range, an error code or unexpected value may be returned.

Parameters
[in]posIndex position of the value to be retrieved.
Returns
The floating-point value at the specified position.

◆ GC_get_string()

char const * GC_get_string ( )

Retrieve the string from the current element of the GenericContainer.

This function returns the C-string stored in the currently selected element of the GenericContainer. If the element is not of the correct type, an error code or unexpected value may be returned.

Returns
The C-string (null-terminated).

◆ GC_get_string_at_pos()

char const * GC_get_string_at_pos ( int pos)

Retrieve a string at a specified position from a vector of strings in the GenericContainer.

This function retrieves the C-string stored at position pos from a vector of strings in the currently selected element of the GenericContainer. If the element is not a vector or if pos is out of range, an error code or unexpected value may be returned.

Parameters
[in]posIndex position of the string to be retrieved.
Returns
The C-string (null-terminated) at the specified position.

◆ GC_get_type()

int GC_get_type ( )

Retrieve the type of the current element pointed by the head in the GenericContainer.

Returns
Error code: 0 = OK.

◆ GC_get_type_name()

char const * GC_get_type_name ( )

Retrieve the name of the type of the current element in the GenericContainer.

Returns
The type name as a string.

◆ GC_get_vector_size()

int GC_get_vector_size ( )

Retrieve the number of elements in the current vector of the GenericContainer.

This function returns the number of elements in the currently selected vector of the GenericContainer. If the element is not a vector, an error code or unexpected value may be returned.

Returns
The number of elements in the current vector, or an error code.

◆ GC_init_map_key()

int GC_init_map_key ( )

Initialize the current element as a map key in the GenericContainer.

This function sets the current element of the GenericContainer as a key for a map. If the element is not of the correct type, an error code will be returned.

Returns
Error code: 0 = OK, other values indicate failure.

◆ GC_mem_ptr()

void * GC_mem_ptr ( char const id[])

Get a pointer to the internal memory of the GenericContainer object.

Parameters
[in]idA string identifying the GenericContainer.
Returns
Pointer to the internal memory of the object.

◆ GC_new()

int GC_new ( char const id[])

Create a new GenericContainer object.

Parameters
[in]idA string identifying the new GenericContainer object.
Returns
Error code: 0 = OK.

◆ GC_pop_head()

int GC_pop_head ( )

Move the head pointer up one level in the GenericContainer.

Returns
Error code: 0 = OK.

◆ GC_print_content_types()

int GC_print_content_types ( )

Print the content types of the current GenericContainer.

Returns
Error code: 0 = OK.

◆ GC_push_bool()

int GC_push_bool ( int a)

Append a boolean value to the currently selected vector of booleans in the GenericContainer.

This function pushes a boolean value (stored as an integer) to the end of the vector of booleans in the currently selected element of the GenericContainer. If the element is not of the correct type or is not a vector, an error code will be returned.

Parameters
[in]aBoolean value (stored as an integer) to be appended.
Returns
Error code: 0 = OK, other values indicate failure.

◆ GC_push_complex()

int GC_push_complex ( c_complex_type const * a)

Append a complex number to the currently selected vector of complex numbers in the GenericContainer.

This function pushes a complex number a to the end of the vector of complex numbers in the currently selected element of the GenericContainer. If the element is not of the correct type or is not a vector, an error code will be returned.

Parameters
[in]aPointer to a c_complex_type structure containing the complex number.
Returns
Error code: 0 = OK, other values indicate failure.

◆ GC_push_complex2()

int GC_push_complex2 ( double re,
double im )

Append a complex number to the currently selected vector using real and imaginary parts.

This function pushes a complex number, specified by its real (re) and imaginary (im) parts, to the end of the vector of complex numbers in the currently selected element of the GenericContainer. If the element is not of the correct type or is not a vector, an error code will be returned.

Parameters
[in]reReal part of the complex number.
[in]imImaginary part of the complex number.
Returns
Error code: 0 = OK, other values indicate failure.

◆ GC_push_int()

int GC_push_int ( int a)

Append an integer value to the currently selected vector of integers in the GenericContainer.

This function pushes an integer value a to the end of the vector of integers in the currently selected element of the GenericContainer. If the element is not of the correct type or is not a vector, an error code will be returned.

Parameters
[in]aInteger value to be appended.
Returns
Error code: 0 = OK, other values indicate failure.

◆ GC_push_map_position()

int GC_push_map_position ( char const pos[])

Set the insertion point to the specified key in the current map of the GenericContainer.

This function sets the insertion point to the map element associated with the specified key pos. If the element is not a map or the key does not exist, an error code will be returned.

Parameters
[in]posC-string representing the key.
Returns
Error code: 0 = OK, other values indicate failure.

◆ GC_push_real()

int GC_push_real ( double a)

Append a floating-point value to the currently selected vector of real numbers in the GenericContainer.

This function pushes a real number a (double precision) to the end of the vector of real numbers in the currently selected element of the GenericContainer. If the element is not of the correct type or is not a vector, an error code will be returned.

Parameters
[in]aReal number (double precision) to be appended.
Returns
Error code: 0 = OK, other values indicate failure.

◆ GC_push_string()

int GC_push_string ( char const a[])

Append a string to the currently selected vector of strings in the GenericContainer.

This function pushes a string a to the end of the vector of strings in the currently selected element of the GenericContainer. If the element is not of the correct type or is not a vector, an error code will be returned.

Parameters
[in]aC-string (null-terminated) to be appended.
Returns
Error code: 0 = OK, other values indicate failure.

◆ GC_push_vector_position()

int GC_push_vector_position ( int pos)

Set the insertion point in the current vector of the GenericContainer.

This function sets the insertion point to the element at position pos in the currently selected vector of the GenericContainer. If the element is not a vector or if pos is out of range, an error code will be returned.

Parameters
[in]posIndex position where the insertion point is set.
Returns
Error code: 0 = OK, other values indicate failure.

◆ GC_reset_head()

int GC_reset_head ( )

Reset the head pointer to the first level in the GenericContainer.

Returns
Error code: 0 = OK.

◆ GC_select()

int GC_select ( char const id[])

Select an existing GenericContainer object.

Parameters
[in]idA string identifying the GenericContainer to select.
Returns
Error code: 0 = OK.

◆ GC_set_bool()

int GC_set_bool ( int a)

Set actual pointed element of GenericContainer to bool with value a

Parameters
[in]aboolean to be stored
Returns
error code, 0 = OK

◆ GC_set_complex()

int GC_set_complex ( c_complex_type const * a)

Set the current element of the GenericContainer to a complex number.

This function stores a complex number represented by the structure c_complex_type in the currently selected element of the GenericContainer. If the element is not of the correct type, an error code will be returned.

Parameters
[in]aPointer to a c_complex_type structure containing the real and imaginary parts of the complex number.
Returns
Error code: 0 = OK, other values indicate failure.

◆ GC_set_complex2()

int GC_set_complex2 ( double re,
double im )

Set the current element of the GenericContainer to a complex number using real and imaginary parts.

This function stores a complex number directly using its real (re) and imaginary (im) parts in the currently selected element of the GenericContainer. If the element is not of the correct type, an error code will be returned.

Parameters
[in]reReal part of the complex number.
[in]imImaginary part of the complex number.
Returns
Error code: 0 = OK, other values indicate failure.

◆ GC_set_empty_vector()

int GC_set_empty_vector ( )

Set the current element of the GenericContainer to an empty vector of GenericContainer elements.

This function initializes the currently selected element of the GenericContainer to an empty vector of GenericContainer elements.

Returns
Error code: 0 = OK, other values indicate failure.

◆ GC_set_empty_vector_of_bool()

int GC_set_empty_vector_of_bool ( )

Initialize the current element of the GenericContainer to an empty vector of booleans.

This function sets the currently selected element of the GenericContainer to an empty vector of booleans (size 0).

Returns
Error code: 0 = OK, other values indicate failure.

◆ GC_set_empty_vector_of_complex()

int GC_set_empty_vector_of_complex ( )

Initialize the current element of the GenericContainer to an empty vector of complex numbers.

This function sets the currently selected element of the GenericContainer to an empty vector of complex numbers (size 0).

Returns
Error code: 0 = OK, other values indicate failure.

◆ GC_set_empty_vector_of_int()

int GC_set_empty_vector_of_int ( )

Initialize the current element of the GenericContainer to an empty vector of integers.

This function sets the currently selected element of the GenericContainer to an empty vector of integers (size 0).

Returns
Error code: 0 = OK, other values indicate failure.

◆ GC_set_empty_vector_of_real()

int GC_set_empty_vector_of_real ( )

Initialize the current element of the GenericContainer to an empty vector of real numbers.

This function sets the currently selected element of the GenericContainer to an empty vector of real numbers (size 0).

Returns
Error code: 0 = OK, other values indicate failure.

◆ GC_set_empty_vector_of_string()

int GC_set_empty_vector_of_string ( )

Initialize the current element of the GenericContainer to an empty vector of strings.

This function sets the currently selected element of the GenericContainer to an empty vector of strings (size 0).

Returns
Error code: 0 = OK, other values indicate failure.

◆ GC_set_int()

int GC_set_int ( int a)

Set the current element of the GenericContainer to an integer value.

This function assigns the integer value a to the currently selected element of the GenericContainer. If the element is not of the correct type, an error code will be returned.

Parameters
[in]aInteger value to be stored.
Returns
Error code: 0 = OK, other values indicate failure.

◆ GC_set_map()

int GC_set_map ( )

Initialize the current element of the GenericContainer to a map.

This function sets the currently selected element of the GenericContainer to an empty map. If the element is not of the correct type, an error code will be returned.

Returns
Error code: 0 = OK, other values indicate failure.

◆ GC_set_real()

int GC_set_real ( double a)

Set the current element of the GenericContainer to a real number.

This function assigns the double-precision floating-point value a to the currently selected element of the GenericContainer. If the element is not of the correct type, an error code will be returned.

Parameters
[in]aDouble value (real number) to be stored.
Returns
Error code: 0 = OK, other values indicate failure.

◆ GC_set_string()

int GC_set_string ( char const a[])

Set the current element of the GenericContainer to a string.

This function stores a string a in the currently selected element of the GenericContainer. If the element is not of the correct type, an error code will be returned.

Parameters
[in]aC-string to be stored (null-terminated).
Returns
Error code: 0 = OK, other values indicate failure.

◆ GC_set_vector()

int GC_set_vector ( int nelem)

Set the current element of the GenericContainer to a vector of GenericContainer elements with the specified size.

This function initializes the currently selected element of the GenericContainer to a vector of GenericContainer elements, with nelem elements. The insertion point is set to the first element.

Parameters
[in]nelemNumber of GenericContainer elements to be created.
Returns
Error code: 0 = OK, other values indicate failure.

◆ GC_set_vector_of_bool()

int GC_set_vector_of_bool ( int const * a,
int nelem )

Set the current element of the GenericContainer to a vector of booleans, and copy the provided values.

This function sets the currently selected element of the GenericContainer to a vector of booleans with nelem elements, copying the boolean values from the provided array a.

Parameters
[in]aArray of boolean values (stored as integers) to be copied.
[in]nelemNumber of elements in the array a.
Returns
Error code: 0 = OK, other values indicate failure.

◆ GC_set_vector_of_complex()

int GC_set_vector_of_complex ( double const * re,
double const * im,
int nelem )

Set the current element of the GenericContainer to a vector of complex numbers, and copy the provided values.

This function sets the currently selected element of the GenericContainer to a vector of complex numbers with nelem elements, copying the real and imaginary parts of each complex number from the provided arrays re and im.

Parameters
[in]reArray of real parts of complex numbers to be copied.
[in]imArray of imaginary parts of complex numbers to be copied.
[in]nelemNumber of elements in the arrays re and im.
Returns
Error code: 0 = OK, other values indicate failure.

◆ GC_set_vector_of_int()

int GC_set_vector_of_int ( int const * a,
int nelem )

Set the current element of the GenericContainer to a vector of integers, and copy the provided values.

This function sets the currently selected element of the GenericContainer to a vector of integers with nelem elements, copying the integer values from the provided array a.

Parameters
[in]aArray of integer values to be copied.
[in]nelemNumber of elements in the array a.
Returns
Error code: 0 = OK, other values indicate failure.

◆ GC_set_vector_of_real()

int GC_set_vector_of_real ( double const * a,
int nelem )

Set the current element of the GenericContainer to a vector of real numbers, and copy the provided values.

This function sets the currently selected element of the GenericContainer to a vector of real numbers (double) with nelem elements, copying the values from the provided array a.

Parameters
[in]aArray of floating-point values to be copied.
[in]nelemNumber of elements in the array a.
Returns
Error code: 0 = OK, other values indicate failure.

◆ GC_set_vector_of_string()

int GC_set_vector_of_string ( char const ** a,
int nelem )

Set the current element of the GenericContainer to a vector of strings, and copy the provided values.

This function sets the currently selected element of the GenericContainer to a vector of strings with nelem elements, copying the strings from the provided array a.

Parameters
[in]aArray of C-strings (null-terminated) to be copied.
[in]nelemNumber of elements in the array a.
Returns
Error code: 0 = OK, other values indicate failure.