GenericContainer
GenericContaine a tool for C++ programming
Loading...
Searching...
No Matches
GC_namespace::GenericContainer Class Reference

The GenericContainer class provides a flexible container for storing heterogeneous data types. More...

#include <GenericContainer.hh>

Public Types

using pointer_type = GC_namespace::pointer_type
 Alias for pointer type.
 
using bool_type = GC_namespace::bool_type
 Alias for boolean type.
 
using int_type = GC_namespace::int_type
 Alias for integer type.
 
using uint_type = GC_namespace::uint_type
 Alias for unsigned integer type.
 
using long_type = GC_namespace::long_type
 Alias for long integer type.
 
using ulong_type = GC_namespace::ulong_type
 Alias for unsigned long integer type.
 
using real_type = GC_namespace::real_type
 Alias for real (floating point) type.
 
using complex_type = GC_namespace::complex_type
 Alias for complex number type.
 
using string_type = GC_namespace::string_type
 Alias for string type.
 
using vec_pointer_type = GC_namespace::vec_pointer_type
 Alias for vector of pointers type.
 
using vec_bool_type = GC_namespace::vec_bool_type
 Alias for vector of booleans type.
 
using vec_int_type = GC_namespace::vec_int_type
 Alias for vector of integers type.
 
using vec_uint_type = GC_namespace::vec_uint_type
 Alias for vector of unsigned integers type.
 
using vec_long_type = GC_namespace::vec_long_type
 Alias for vector of long integers type.
 
using vec_ulong_type = GC_namespace::vec_ulong_type
 Alias for vector of unsigned long integers type.
 
using vec_real_type = GC_namespace::vec_real_type
 Alias for vector of real numbers type.
 
using vec_complex_type = GC_namespace::vec_complex_type
 Alias for vector of complex numbers type.
 
using vec_string_type = GC_namespace::vec_string_type
 Alias for vector of strings type.
 
using vector_type = GC_namespace::vector_type
 Alias for vector of GenericContainer type.
 
using map_type = GC_namespace::map_type
 Alias for map of GenericContainer type.
 
using mat_int_type = GC_namespace::mat_int_type
 Alias for matrix of integers type.
 
using mat_long_type = GC_namespace::mat_long_type
 Alias for matrix of long integers type.
 
using mat_real_type = GC_namespace::mat_real_type
 Alias for matrix of real numbers type.
 
using mat_complex_type = GC_namespace::mat_complex_type
 Alias for matrix of complex numbers type.
 

Public Member Functions

 GenericContainer ()
 Constructs a GenericContainer with an initial empty state.
 
 ~GenericContainer ()
 Destroys the GenericContainer and releases any allocated resources.
 
void clear ()
 Clears the content of the GenericContainer, resetting it to an empty state.
 
void erase (char const name[])
 Removes an item from the map stored in the GenericContainer by its key.
 
Methods for Initializing Simple Data Types

This group of methods allows setting simple data types (e.g., pointer, boolean, integer, etc.) within a GenericContainer. Each method initializes the container to the specified type, sets the value, and returns a reference to the stored data.

pointer_typeset_pointer (pointer_type value)
 Set the data type to pointer_type and assign a value.
 
GenericContainerfree_pointer ()
 Free the pointer and reset the container to an empty state.
 
void get_keys (vec_string_type &keys) const
 Extracts the keys of the map stored in the GenericContainer into a vector of strings.
 
string get_keys () const
 Extracts the keys of the map stored in the GenericContainer as a comma-separated string.
 
bool_typeset_bool (bool_type value)
 Set the data type to bool_type and assign a boolean value.
 
int_typeset_int (int_type value)
 Set the data type to int_type and assign an integer value.
 
long_typeset_long (long_type value)
 Set the data type to long_type and assign a long integer value.
 
real_typeset_real (real_type value)
 Set the data type to real_type and assign a floating-point value.
 
complex_typeset_complex (complex_type const &value)
 Set the data type to complex_type and assign a complex value.
 
complex_typeset_complex (real_type r, real_type i)
 Set the data type to complex_type and assign a complex value from real and imaginary parts.
 
string_typeset_string (string_type const &value)
 Set the data type to string_type, allocate memory, and assign a string value.
 
Methods for Initializing Vector and Matrix Data

This section includes methods for setting, allocating, and initializing vector and matrix data types within a GenericContainer. Each method allows for the creation of vectors or matrices, either by specifying the size or by copying from an existing vector or matrix.

vec_pointer_typeset_vec_pointer (unsigned sz=0)
 Set the data to vec_pointer_type, allocate and initialize.
 
vec_pointer_typeset_vec_pointer (vec_pointer_type const &v)
 Set the data to vec_pointer_type by copying from another vector.
 
vec_bool_typeset_vec_bool (unsigned sz=0)
 Set the data to vec_bool_type, allocate and initialize.
 
vec_bool_typeset_vec_bool (vec_bool_type const &v)
 Set the data to vec_bool_type by copying from another vector.
 
vec_int_typeset_vec_int (unsigned sz=0)
 Set the data to vec_int_type, allocate and initialize.
 
vec_int_typeset_vec_int (vec_int_type const &v)
 Set the data to vec_int_type by copying from another vector.
 
vec_long_typeset_vec_long (unsigned sz=0)
 Set the data to vec_long_type, allocate and initialize.
 
vec_long_typeset_vec_long (vec_long_type const &v)
 Set the data to vec_long_type by copying from another vector.
 
vec_real_typeset_vec_real (unsigned sz=0)
 Set the data to vec_real_type, allocate and initialize.
 
vec_real_typeset_vec_real (vec_real_type const &v)
 Set the data to vec_real_type by copying from another vector.
 
vec_complex_typeset_vec_complex (unsigned sz=0)
 Set the data to vec_complex_type, allocate and initialize.
 
vec_complex_typeset_vec_complex (vec_complex_type const &v)
 Set the data to vec_complex_type by copying from another vector.
 
vec_string_typeset_vec_string (unsigned sz=0)
 Set the data to vec_string_type, allocate and initialize.
 
vec_string_typeset_vec_string (vec_string_type const &v)
 Set the data to vec_string_type by copying from another vector.
 
mat_int_typeset_mat_int (unsigned nr=0, unsigned nc=0)
 Set the data to mat_int_type, allocate and initialize.
 
mat_int_typeset_mat_int (mat_int_type const &m)
 Set the data to mat_int_type by copying from another matrix.
 
mat_long_typeset_mat_long (unsigned nr=0, unsigned nc=0)
 Set the data to mat_long_type, allocate and initialize.
 
mat_long_typeset_mat_long (mat_long_type const &m)
 Set the data to mat_long_type by copying from another matrix.
 
mat_real_typeset_mat_real (unsigned nr=0, unsigned nc=0)
 Set the data to mat_real_type, allocate and initialize.
 
mat_real_typeset_mat_real (mat_real_type const &m)
 Set the data to mat_real_type by copying from another matrix.
 
mat_complex_typeset_mat_complex (unsigned nr=0, unsigned nc=0)
 Set the data to mat_complex_type, allocate and initialize.
 
mat_complex_typeset_mat_complex (mat_complex_type const &m)
 Set the data to mat_complex_type by copying from another matrix.
 
void push_bool (bool b)
 Push a boolean value into the vector or matrix.
 
void push_int (int_type i)
 Push an integer value into the vector or matrix.
 
void push_long (long_type l)
 Push a long integer value into the vector or matrix.
 
void push_real (real_type r)
 Push a real number into the vector or matrix.
 
void push_complex (complex_type &c)
 Push a complex number into the vector or matrix using an existing complex object.
 
void push_complex (real_type re, real_type im)
 Push a complex number into the vector or matrix using real and imaginary parts.
 
void push_string (string_type const &s)
 Push a string value into the vector or matrix.
 
Initialize generic data.
vector_typeset_vector (unsigned sz=0)
 Initializes a generic vector.
 
map_typeset_map ()
 Initializes a generic map.
 
Access to a single element.
TypeAllowed get_type () const
 Return an integer representing the type of data stored.
 
char const * get_type_name () const
 Return a string representing the type of data stored.
 
GenericContainer const & info (ostream_type &stream) const
 Print information about the kind of data stored to a stream.
 
string_type info () const
 Print information about the kind of data stored as a string.
 
unsigned get_num_elements () const
 Return the number of elements in the first level of the generic container.
 
unsigned num_rows () const
 Return the number of rows in the internally stored matrix.
 
unsigned get_numRows () const
 
unsigned num_cols () const
 Return the number of columns in the internally stored matrix.
 
unsigned get_numCols () const
 
real_type get_number (char const where[]="") const
 Get a stored numeric value if the data is boolean, integer, or real type.
 
complex_type get_complex_number (char const where[]="") const
 Get a stored complex number if the data is boolean, integer, real, or complex type.
 
void get_complex_number (real_type &re, real_type &im) const
 Get the real and imaginary parts of a stored complex number.
 
void * get_pvoid (char const where[]="") const
 Return the stored data as a generic pointer.
 
void ** get_ppvoid (char const where[]="") const
 Return the stored data as a double pointer.
 
int_type const * get_int_pointer () const
 
int_typeget_int_pointer ()
 Return the stored data as a pointer to const integer.
 
long_type const * get_long_pointer () const
 Return the stored data as a pointer to const long.
 
long_typeget_long_pointer ()
 Return the stored data as a pointer to long.
 
real_type const * get_real_pointer () const
 Return the stored data as a pointer to const real_type.
 
real_typeget_real_pointer ()
 Return the stored data as a pointer to real_type.
 
complex_type const * get_complex_pointer () const
 Return the stored data as a pointer to const complex_type.
 
complex_typeget_complex_pointer ()
 Return the stored data as a pointer to complex_type.
 
template<typename T >
void get_value (T &v, char const where[]="") const
 Get the stored value.
 
template<typename T >
T & get_pointer ()
 Get the stored value as a pointer.
 
template<typename T >
get_pointer () const
 Get the stored value as a pointer (const version).
 
bool_type get_map_bool (char const key[], char const where[]="") const
 Get the stored value in the map as boolean.
 
bool_type get_map_bool (vec_string_type const &keys, char const where[]="") const
 
int_type get_map_int (char const key[], char const where[]="") const
 Get the stored value in the map as an integer.
 
int_type get_map_int (vec_string_type const &keys, char const where[]="") const
 Get the stored value in the map as an integer from a list of keys.
 
real_type get_map_number (char const key[], char const where[]="") const
 Get the stored value in the map as a real number.
 
real_type get_map_number (vec_string_type const &keys, char const where[]="") const
 Get the stored value in the map as a real number from a list of keys.
 
string_type const & get_map_string (char const key[], char const where[]="") const
 Get the stored value in the map as a string.
 
string_type const & get_map_string (vec_string_type const &keys, char const where[]="") const
 Get the stored value in the map as a string from a list of keys.
 
vec_real_type const & get_map_vec_real (char const key[], char const where[]="") const
 Get the stored value in the map as a vector of real numbers.
 
vec_real_type const & get_map_vec_real (vec_string_type const &keys, char const where[]="") const
 Get the stored value in the map as a vector of real numbers from a list of keys.
 
vec_complex_type const & get_map_vec_complex (char const key[], char const where[]="") const
 Get the stored value in the map as a vector of complex numbers.
 
vec_complex_type const & get_map_vec_complex (vec_string_type const &keys, char const where[]="") const
 Get the stored value in the map as a vector of complex numbers from a list of keys.
 
vec_string_type const & get_map_vec_string (char const key[], char const where[]="") const
 Get the stored value in the map as a vector of strings.
 
vec_string_type const & get_map_vec_string (vec_string_type const &keys, char const where[]="") const
 Get the stored value in the map as a vector of strings from a list of keys.
 
bool_typeget_bool (char const where[]="")
 Get the stored value as a boolean.
 
bool_type const & get_bool (char const where[]="") const
 Get the stored value as a const boolean.
 
int_typeget_int (char const where[]="")
 Get the stored value as an integer.
 
int_type const & get_int (char const where[]="") const
 Get the stored value as a const integer.
 
long_typeget_long (char const where[]="")
 Get the stored value as a long integer.
 
long_type const & get_long (char const where[]="") const
 Get the stored value as a const long integer.
 
int_type get_as_int (char const where[]="") const
 Get the stored value as an integer.
 
uint_type get_as_uint (char const where[]="") const
 Get the stored value as an unsigned integer.
 
long_type get_as_long (char const where[]="") const
 Get the stored value as a long integer.
 
ulong_type get_as_ulong (char const where[]="") const
 Get the stored value as an unsigned long integer.
 
real_typeget_real (char const where[]="")
 Get the stored value as a real number.
 
real_type const & get_real (char const where[]="") const
 Get the stored value as a const real number.
 
complex_typeget_complex (char const where[]="")
 Get the stored value as a complex number.
 
complex_type const & get_complex (char const where[]="") const
 Get the stored value as a const complex number.
 
string_typeget_string (char const where[]="")
 Get the stored value as a string.
 
string_type const & get_string (char const where[]="") const
 Get the stored value as a const string.
 
Access to vector type data.
vector_typeget_vector (char const where[]="")
 
vector_type const & get_vector (char const where[]="") const
 
vec_pointer_typeget_vec_pointer (char const where[]="")
 
vec_pointer_type const & get_vec_pointer (char const where[]="") const
 
vec_bool_typeget_vec_bool (char const where[]="")
 
vec_bool_type const & get_vec_bool (char const where[]="") const
 
vec_int_typeget_vec_int (char const where[]="")
 
vec_int_type const & get_vec_int (char const where[]="") const
 
vec_long_typeget_vec_long (char const where[]="")
 
vec_long_type const & get_vec_long (char const where[]="") const
 
vec_real_typeget_vec_real (char const where[]="")
 
vec_real_type const & get_vec_real (char const where[]="") const
 
vec_complex_typeget_vec_complex (char const where[]="")
 
vec_complex_type const & get_vec_complex (char const where[]="") const
 
mat_int_typeget_mat_int (char const where[]="")
 
mat_int_type const & get_mat_int (char const where[]="") const
 
mat_long_typeget_mat_long (char const where[]="")
 
mat_long_type const & get_mat_long (char const where[]="") const
 
mat_real_typeget_mat_real (char const where[]="")
 
mat_real_type const & get_mat_real (char const where[]="") const
 
mat_complex_typeget_mat_complex (char const where[]="")
 
mat_complex_type const & get_mat_complex (char const where[]="") const
 
vec_string_typeget_vec_string (char const where[]="")
 
vec_string_type const & get_vec_string (char const where[]="") const
 
Access to vector type data and convert.
void copyto_vec_int (vec_int_type &v, char const where[]="") const
 
void copyto_vec_uint (vec_uint_type &v, char const where[]="") const
 
void copyto_vec_long (vec_long_type &v, char const where[]="") const
 
void copyto_vec_ulong (vec_ulong_type &v, char const where[]="") const
 
void copyto_vec_real (vec_real_type &v, char const where[]="") const
 
void copyto_vec_complex (vec_complex_type &v, char const where[]="") const
 
void copyto_vec_string (vec_string_type &v, char const where[]="") const
 
Access to element of vector type data
real_type get_number_at (unsigned i, char const where[]="") const
 
complex_type get_complex_number_at (unsigned i, char const where[]="") const
 
void get_complex_number_at (unsigned i, real_type &re, real_type &im, char const where[]="") const
 
template<typename T >
T & get_pointer_at (unsigned i)
 
template<typename T >
get_pointer_at (unsigned i) const
 Return i-th generic pointer (if fails issue an error).
 
bool_type get_bool_at (unsigned i)
 
bool_type get_bool_at (unsigned i, char const where[]) const
 
int_typeget_int_at (unsigned i)
 
int_type const & get_int_at (unsigned i, char const where[]) const
 
long_typeget_long_at (unsigned i)
 
long_type const & get_long_at (unsigned i, char const where[]) const
 
real_typeget_real_at (unsigned i)
 
real_type const & get_real_at (unsigned i, char const where[]) const
 
complex_typeget_complex_at (unsigned i)
 
complex_type const & get_complex_at (unsigned i, char const where[]) const
 
int_typeget_int_at (unsigned i, unsigned j)
 
int_type const & get_int_at (unsigned i, unsigned j, char const where[]) const
 
long_typeget_long_at (unsigned i, unsigned j)
 
long_type const & get_long_at (unsigned i, unsigned j, char const where[]) const
 
real_typeget_real_at (unsigned i, unsigned j)
 
real_type const & get_real_at (unsigned i, unsigned j, char const where[]) const
 
complex_typeget_complex_at (unsigned i, unsigned j)
 
complex_type const & get_complex_at (unsigned i, unsigned j, char const where[]) const
 
string_typeget_string_at (unsigned i)
 
string_type const & get_string_at (unsigned i, char const where[]) const
 
GenericContainerget_gc_at (unsigned i)
 
GenericContainer const & get_gc_at (unsigned i, char const where[]) const
 
Access to map type element.
map_typeget_map (char const where[]="")
 
map_type const & get_map (char const where[]="") const
 
Access using operators.
GenericContaineroperator[] (unsigned i)
 
GenericContainer const & operator[] (unsigned i) const
 
GenericContaineroperator[] (string_type const &s)
 
GenericContainer const & operator[] (string_type const &s) const
 
GenericContaineroperator() (unsigned i, char const where[]="")
 
GenericContainer const & operator() (unsigned i, char const where[]="") const
 
GenericContaineroperator() (string_type const &s, char const where[]="")
 
GenericContainer const & operator() (string_type const &s, char const where[]="") const
 
GenericContaineroperator() (vec_string_type const &vs, char const where[]="")
 
GenericContainer const & operator() (vec_string_type const &vs, char const where[]="") const
 
Initialize data using set command.
void set (bool const &a)
 
void set (uint_type const &a)
 
void set (int_type const &a)
 
void set (ulong_type const &a)
 
void set (long_type const &a)
 
void set (float const &a)
 
void set (double const &a)
 
void set (complex< float > const &a)
 
void set (complex< double > const &a)
 
void set (char const *a)
 
void set (string_type const &a)
 
void set (pointer_type a)
 
Initialize data using operators.

The = operator is overloaded to initialize the GenericContainer on its left side.

GenericContaineroperator= (bool const &a)
 
GenericContaineroperator= (uint_type const &a)
 
GenericContaineroperator= (int_type const &a)
 
GenericContaineroperator= (ulong_type const &a)
 
GenericContaineroperator= (long_type const &a)
 
GenericContaineroperator= (float const &a)
 
GenericContaineroperator= (double const &a)
 
GenericContaineroperator= (complex< float > const &a)
 
GenericContaineroperator= (complex< double > const &a)
 
GenericContaineroperator= (vec_bool_type const &a)
 
GenericContaineroperator= (vec_int_type const &a)
 
GenericContaineroperator= (vec_long_type const &a)
 
GenericContaineroperator= (vec_real_type const &a)
 
GenericContaineroperator= (vec_complex_type const &a)
 
GenericContaineroperator= (vec_string_type const &a)
 
GenericContaineroperator= (mat_int_type const &a)
 
GenericContaineroperator= (mat_long_type const &a)
 
GenericContaineroperator= (mat_real_type const &a)
 
GenericContaineroperator= (mat_complex_type const &a)
 
GenericContaineroperator= (char const *a)
 
GenericContaineroperator= (string_type const &a)
 
GenericContaineroperator= (pointer_type a)
 
GenericContainer const & operator= (GenericContainer const &a)
 
void load (GenericContainer const &a)
 
Promotion to a <tt>bigger</tt> data.
GenericContainer const & promote_to_int ()
 
GenericContainer const & promote_to_long ()
 
GenericContainer const & promote_to_real ()
 
GenericContainer const & promote_to_complex ()
 
GenericContainer const & promote_to_vec_int ()
 
GenericContainer const & promote_to_vec_long ()
 
GenericContainer const & promote_to_vec_real ()
 
GenericContainer const & promote_to_vec_complex ()
 
GenericContainer const & promote_to_mat_int ()
 
GenericContainer const & promote_to_mat_long ()
 
GenericContainer const & promote_to_mat_real ()
 
GenericContainer const & promote_to_mat_complex ()
 
GenericContainer const & promote_to_vector ()
 
Initialize data by overloading constructor.
 GenericContainer (bool const &a)
 
 GenericContainer (uint_type const &a)
 
 GenericContainer (int_type const &a)
 
 GenericContainer (ulong_type const &a)
 
 GenericContainer (long_type const &a)
 
 GenericContainer (float const &a)
 
 GenericContainer (double const &a)
 
 GenericContainer (complex< float > const &a)
 
 GenericContainer (complex< double > const &a)
 
 GenericContainer (char const *a)
 
 GenericContainer (string_type const &a)
 
 GenericContainer (pointer_type a)
 
 GenericContainer (GenericContainer const &gc)
 
Utilities methods.
bool exists (string_type const &s) const
 
bool exists (vec_string_type const &vs) const
 
string must_exists (vec_string_type const &vs, char const where[]) const
 
bool get_if_exists (string_type const &field, bool &value) const
 
bool get_if_exists (vec_string_type const &fields, bool &value) const
 
bool get_if_exists (string_type const &field, int_type &value) const
 
bool get_if_exists (string_type const &field, uint_type &value) const
 
bool get_if_exists (string_type const &field, long_type &value) const
 
bool get_if_exists (string_type const &field, ulong_type &value) const
 
bool get_if_exists (string_type const &field, real_type &value) const
 
bool get_if_exists (string_type const &field, complex_type &value) const
 
bool get_if_exists (string_type const &field, string_type &value) const
 
template<typename T >
bool get_if_exists (vec_string_type const &fields, T &value) const
 
template<typename T >
bool get_if_exists (char const field[], T &value) const
 
I/O for GenericContainer objects.
void print_content_types (ostream_type &stream, string_type const &prefix="", string_type const &indent=" ") const
 
void dump (ostream_type &stream, string_type const &prefix="", string_type const &indent=" ") const
 
void print (ostream_type &stream, string_type const &prefix="", string_type const &indent=" ") const
 
string_type print (string_type const &prefix="", string_type const &indent=" ") const
 
void to_gc (GenericContainer &gc) const
 
void from_gc (GenericContainer const &gc)
 
void merge (GenericContainer const &gc, char const where[])
 
void to_yaml (ostream_type &stream, string_type const &prefix="") const
 
string to_yaml (string_type const &prefix="") const
 
void to_json (ostream_type &stream, string_type const &prefix="") const
 
string to_json (string_type const &prefix="") const
 
void collapse ()
 
GenericContainer const & writeFormattedData (ostream_type &stream, char const delimiter='\t') const
 
GenericContainerreadFormattedData (istream_type &stream, char const commentChars[]="#%", char const delimiters[]=" \t")
 
GenericContainerreadFormattedData (char const fname[], char const commentChars[]="#%", char const delimiters[]=" \t")
 
GenericContainerreadFormattedData2 (istream_type &stream, char const commentChars[]="#%", char const delimiters[]=" \t", GenericContainer ptr_pars[]=nullptr)
 
GenericContainerreadFormattedData2 (char const fname[], char const commentChars[]="#%", char const delimiters[]=" \t", GenericContainer ptr_pars[]=nullptr)
 
Serialization.
int32_t mem_size () const
 
int32_t serialize (int32_t buffer_dim, uint8_t *buffer) const
 
int32_t serialize (vector< uint8_t > &buffer) const
 
int32_t de_serialize (int32_t buffer_dim, uint8_t const *buffer)
 
int32_t de_serialize (vector< uint8_t > const &buffer)
 

Static Public Member Functions

static void exception (char const where[]) GC_NO_RETURN
 

Detailed Description

The GenericContainer class provides a flexible container for storing heterogeneous data types.

This class allows storage of various data types, including primitive types (e.g., integer, floating-point), complex types, and containers like vectors and maps. It supports recursive structures where elements of the container can themselves be other GenericContainer objects.

Supported Data Types:

  • Primitive types:
    • Pointer
    • Boolean
    • Integer
    • Long integer
    • Floating point (real numbers)
    • Complex floating point
    • String
  • Vector types:
    • Vector of pointers
    • Vector of booleans
    • Vector of integers
    • Vector of long integers
    • Vector of floating-point numbers
    • Vector of complex numbers
    • Vector of strings
  • Matrix types:
    • Matrix of integers
    • Matrix of long integers
    • Matrix of floating-point numbers
    • Matrix of complex numbers
  • Complex container types:

These capabilities make GenericContainer a highly versatile container for managing mixed-type data in C++.

Example:

gc.set_integer(42); // Store an integer
gc.set_string("Hello, World!"); // Store a string
vec_gc.set_vector(3); // Store a vector of GenericContainers
vec_gc[0].set_real(3.14); // Set first element as a floating-point number
The GenericContainer class provides a flexible container for storing heterogeneous data types.
Definition GenericContainer.hh:572
real_type & set_real(real_type value)
Set the data type to real_type and assign a floating-point value.
Definition GenericContainer.cc:764
string_type & set_string(string_type const &value)
Set the data type to string_type, allocate memory, and assign a string value.
Definition GenericContainer.cc:787
vector_type & set_vector(unsigned sz=0)
Initializes a generic vector.
Definition GenericContainer.cc:935

Member Typedef Documentation

◆ bool_type

using GC_namespace::GenericContainer::bool_type = GC_namespace::bool_type

Alias for boolean type.

◆ complex_type

using GC_namespace::GenericContainer::complex_type = GC_namespace::complex_type

Alias for complex number type.

◆ int_type

using GC_namespace::GenericContainer::int_type = GC_namespace::int_type

Alias for integer type.

◆ long_type

using GC_namespace::GenericContainer::long_type = GC_namespace::long_type

Alias for long integer type.

◆ map_type

using GC_namespace::GenericContainer::map_type = GC_namespace::map_type

Alias for map of GenericContainer type.

◆ mat_complex_type

Alias for matrix of complex numbers type.

◆ mat_int_type

◆ mat_long_type

Alias for matrix of long integers type.

◆ mat_real_type

Alias for matrix of real numbers type.

◆ pointer_type

using GC_namespace::GenericContainer::pointer_type = GC_namespace::pointer_type

Alias for pointer type.

◆ real_type

using GC_namespace::GenericContainer::real_type = GC_namespace::real_type

Alias for real (floating point) type.

◆ string_type

using GC_namespace::GenericContainer::string_type = GC_namespace::string_type

Alias for string type.

◆ uint_type

using GC_namespace::GenericContainer::uint_type = GC_namespace::uint_type

Alias for unsigned integer type.

◆ ulong_type

using GC_namespace::GenericContainer::ulong_type = GC_namespace::ulong_type

Alias for unsigned long integer type.

◆ vec_bool_type

using GC_namespace::GenericContainer::vec_bool_type = GC_namespace::vec_bool_type

Alias for vector of booleans type.

◆ vec_complex_type

using GC_namespace::GenericContainer::vec_complex_type = GC_namespace::vec_complex_type

Alias for vector of complex numbers type.

◆ vec_int_type

using GC_namespace::GenericContainer::vec_int_type = GC_namespace::vec_int_type

Alias for vector of integers type.

◆ vec_long_type

using GC_namespace::GenericContainer::vec_long_type = GC_namespace::vec_long_type

Alias for vector of long integers type.

◆ vec_pointer_type

using GC_namespace::GenericContainer::vec_pointer_type = GC_namespace::vec_pointer_type

Alias for vector of pointers type.

◆ vec_real_type

using GC_namespace::GenericContainer::vec_real_type = GC_namespace::vec_real_type

Alias for vector of real numbers type.

◆ vec_string_type

using GC_namespace::GenericContainer::vec_string_type = GC_namespace::vec_string_type

Alias for vector of strings type.

◆ vec_uint_type

using GC_namespace::GenericContainer::vec_uint_type = GC_namespace::vec_uint_type

Alias for vector of unsigned integers type.

◆ vec_ulong_type

using GC_namespace::GenericContainer::vec_ulong_type = GC_namespace::vec_ulong_type

Alias for vector of unsigned long integers type.

◆ vector_type

using GC_namespace::GenericContainer::vector_type = GC_namespace::vector_type

Alias for vector of GenericContainer type.

Constructor & Destructor Documentation

◆ GenericContainer() [1/14]

GC_namespace::GenericContainer::GenericContainer ( )
inline

Constructs a GenericContainer with an initial empty state.

This constructor initializes a GenericContainer object with no data. The internal data type is set to NOTYPE, indicating that no data is currently stored in the container.

Example:

// gc is now an empty container with no type assigned

◆ ~GenericContainer()

GC_namespace::GenericContainer::~GenericContainer ( )
inline

Destroys the GenericContainer and releases any allocated resources.

This destructor ensures that any dynamically allocated memory or resources associated with the data stored in the GenericContainer are properly freed. It automatically calls the clear() method to ensure the object is fully cleaned up before destruction.

Example:

{
// Perform operations with gc...
}
// When gc goes out of scope, the destructor is called automatically, freeing resources

◆ GenericContainer() [2/14]

GC_namespace::GenericContainer::GenericContainer ( bool const & a)
inline

Construct a generic container storing a boolean

Parameters
[in]ainitializer data

◆ GenericContainer() [3/14]

GC_namespace::GenericContainer::GenericContainer ( uint_type const & a)
inline

Construct a generic container storing an integer

Parameters
[in]ainitializer data

◆ GenericContainer() [4/14]

GC_namespace::GenericContainer::GenericContainer ( int_type const & a)
inline

Construct a generic container storing an integer

Parameters
[in]ainitializer data

◆ GenericContainer() [5/14]

GC_namespace::GenericContainer::GenericContainer ( ulong_type const & a)
inline

Construct a generic container storing an integer

Parameters
[in]ainitializer data

◆ GenericContainer() [6/14]

GC_namespace::GenericContainer::GenericContainer ( long_type const & a)
inline

Construct a generic container storing an integer

Parameters
[in]ainitializer data

◆ GenericContainer() [7/14]

GC_namespace::GenericContainer::GenericContainer ( float const & a)
inline

Construct a generic container storing a floating point number

Parameters
[in]ainitializer data

◆ GenericContainer() [8/14]

GC_namespace::GenericContainer::GenericContainer ( double const & a)
inline

Construct a generic container storing a floating point number

Parameters
[in]ainitializer data

◆ GenericContainer() [9/14]

GC_namespace::GenericContainer::GenericContainer ( complex< float > const & a)
inline

Construct a generic container storing a complex floating point number

Parameters
[in]ainitializer data

◆ GenericContainer() [10/14]

GC_namespace::GenericContainer::GenericContainer ( complex< double > const & a)
inline

Construct a generic container storing a complex floating point number

Parameters
[in]ainitializer data

◆ GenericContainer() [11/14]

GC_namespace::GenericContainer::GenericContainer ( char const * a)
inline

Construct a generic container storing a string

Parameters
[in]ainitializer data

◆ GenericContainer() [12/14]

GC_namespace::GenericContainer::GenericContainer ( string_type const & a)
inline

Construct a generic container storing a string

Parameters
[in]ainitializer data

◆ GenericContainer() [13/14]

GC_namespace::GenericContainer::GenericContainer ( pointer_type a)
inline

Construct a generic container storing a pointer

Parameters
[in]ainitializer data

◆ GenericContainer() [14/14]

GC_namespace::GenericContainer::GenericContainer ( GenericContainer const & gc)
inline

Construct a generic container copying container gc

Parameters
[in]gcinitializer data

Member Function Documentation

◆ clear()

void GC_namespace::GenericContainer::clear ( )

Clears the content of the GenericContainer, resetting it to an empty state.

This method frees any memory or resources associated with the data currently stored in the container. After calling clear(), the container's data type is set back to NOTYPE.

This function is particularly useful when the container is no longer needed or when you want to reuse the same GenericContainer object for different data.

Example:

gc.set_integer(42); // Store an integer
gc.clear(); // Clear the container, now it is empty

◆ collapse()

void GC_namespace::GenericContainer::collapse ( )

Collapse heterogeneous vectors into a unified type. Attempts to collapse nested vectors into a matrix when possible.

◆ copyto_vec_complex()

void GC_namespace::GenericContainer::copyto_vec_complex ( vec_complex_type & v,
char const where[] = "" ) const

Copy internal data to a vector of complex_type

Parameters
[out]vVector to store the data
[in]wherePosition added to the error message
vec_complex_type complex_vector;
GenericoContainer container;
container.copyto_vec_complex(complex_vector, "In function example_call");
// Use complex_vector...
GC_namespace::vec_complex_type vec_complex_type
Alias for vector of complex numbers type.
Definition GenericContainer.hh:591

◆ copyto_vec_int()

void GC_namespace::GenericContainer::copyto_vec_int ( vec_int_type & v,
char const where[] = "" ) const

Copy internal data to a vector of integers

Parameters
[out]vVector to store the data
[in]wherePosition added to the error message
vec_int_type int_vector;
GenericoContainer container;
container.copyto_vec_int(int_vector, "In function example_call");
// Use int_vector...
GC_namespace::vec_int_type vec_int_type
Alias for vector of integers type.
Definition GenericContainer.hh:586

◆ copyto_vec_long()

void GC_namespace::GenericContainer::copyto_vec_long ( vec_long_type & v,
char const where[] = "" ) const

Copy internal data to a vector of long integers

Parameters
[out]vVector to store the data
[in]wherePosition added to the error message
vec_long_type long_vector;
GenericoContainer container;
container.copyto_vec_long(long_vector, "In function example_call");
// Use long_vector...
GC_namespace::vec_long_type vec_long_type
Alias for vector of long integers type.
Definition GenericContainer.hh:588

◆ copyto_vec_real()

void GC_namespace::GenericContainer::copyto_vec_real ( vec_real_type & v,
char const where[] = "" ) const

Copy internal data to a vector of real_type

Parameters
[out]vVector to store the data
[in]wherePosition added to the error message
vec_real_type real_vector;
GenericoContainer container;
container.copyto_vec_real(real_vector, "In function example_call");
// Use real_vector...
GC_namespace::vec_real_type vec_real_type
Alias for vector of real numbers type.
Definition GenericContainer.hh:590

◆ copyto_vec_string()

void GC_namespace::GenericContainer::copyto_vec_string ( vec_string_type & v,
char const where[] = "" ) const

Copy internal data to a vector of strings

Parameters
[out]vVector to store the data
[in]wherePosition added to the error message
vec_string_type string_vector;
GenericoContainer container;
container.copyto_vec_string(string_vector, "In function example_call");
// Use string_vector...
GC_namespace::vec_string_type vec_string_type
Alias for vector of strings type.
Definition GenericContainer.hh:592

◆ copyto_vec_uint()

void GC_namespace::GenericContainer::copyto_vec_uint ( vec_uint_type & v,
char const where[] = "" ) const

Copy internal data to a vector of unsigned integers

Parameters
[out]vVector to store the data
[in]wherePosition added to the error message
vec_uint_type uint_vector;
GenericoContainer container;
container.copyto_vec_uint(uint_vector, "In function example_call");
// Use uint_vector...
GC_namespace::vec_uint_type vec_uint_type
Alias for vector of unsigned integers type.
Definition GenericContainer.hh:587

◆ copyto_vec_ulong()

void GC_namespace::GenericContainer::copyto_vec_ulong ( vec_ulong_type & v,
char const where[] = "" ) const

Copy internal data to a vector of unsigned long integers

Parameters
[out]vVector to store the data
[in]wherePosition added to the error message
vec_ulong_type ulong_vector;
GenericoContainer container;
container.copyto_vec_ulong(ulong_vector, "In function example_call");
// Use ulong_vector...
GC_namespace::vec_ulong_type vec_ulong_type
Alias for vector of unsigned long integers type.
Definition GenericContainer.hh:589

◆ de_serialize() [1/2]

int32_t GC_namespace::GenericContainer::de_serialize ( int32_t buffer_dim,
uint8_t const * buffer )

Build the generic container from the serialized version of the GenericContainer conrined in buffer.

◆ de_serialize() [2/2]

int32_t GC_namespace::GenericContainer::de_serialize ( vector< uint8_t > const & buffer)

Build the generic container from the serialized version of the GenericContainer conrined in buffer.

◆ dump()

void GC_namespace::GenericContainer::dump ( ostream_type & stream,
string_type const & prefix = "",
string_type const & indent = "    " ) const

Dump the contents of the object in a human readable way

Parameters
[in]streamoutput stream
[in]prefixstrig to be prepended to any field of the GenericContainer
[in]indentindentation

◆ erase()

void GC_namespace::GenericContainer::erase ( char const name[])

Removes an item from the map stored in the GenericContainer by its key.

This method deletes an entry in the map contained within the GenericContainer, identified by the provided key name. The GenericContainer must currently store a map (MAP data type), otherwise, an error is thrown.

Parameters
nameThe key of the element to be removed from the map.
Exceptions
runtime_errorIf the current data type is not MAP.

Example:

gc.set_map(); // Initialize as a map
gc["key1"].set_integer(10); // Add an entry with key "key1"
gc.erase("key1"); // Remove the entry with key "key1"
map_type & set_map()
Initializes a generic map.
Definition GenericContainer.cc:941
void erase(char const name[])
Removes an item from the map stored in the GenericContainer by its key.
Definition GenericContainer.cc:433

◆ exception()

void GC_namespace::GenericContainer::exception ( char const where[])
static

Do an exception

Parameters
[in]whereposition added to the error message

◆ exists() [1/2]

bool GC_namespace::GenericContainer::exists ( string_type const & s) const

Check if string s is a key of the stored map (if fails issue an error).

Parameters
[in]skey to be checked

◆ exists() [2/2]

bool GC_namespace::GenericContainer::exists ( vec_string_type const & vs) const

Check if any string in vs is a key of the stored map (if fails issue an error).

Parameters
[in]vsvector of string with the keys to be checked

◆ free_pointer()

GenericContainer & GC_namespace::GenericContainer::free_pointer ( )

Free the pointer and reset the container to an empty state.

This method deallocates any memory or resources associated with the current pointer, resets the container's type to NOTYPE, and returns a reference to the GenericContainer instance itself.

Returns
A reference to the GenericContainer after the pointer has been freed.

Example:

gc.set_pointer(malloc(100)); // Allocate memory and store the pointer
gc.free_pointer(); // Free the allocated memory and reset container
GenericContainer & free_pointer()
Free the pointer and reset the container to an empty state.
Definition GenericContainer.cc:591
pointer_type & set_pointer(pointer_type value)
Set the data type to pointer_type and assign a value.
Definition GenericContainer.cc:736

◆ from_gc()

void GC_namespace::GenericContainer::from_gc ( GenericContainer const & gc)

Copy the contents of the object into another object

Parameters
[in]gcinput GenericContainer

◆ get_as_int()

int_type GC_namespace::GenericContainer::get_as_int ( char const where[] = "") const

Get the stored value as an integer.

This function retrieves the data stored in the container as an integer.

Parameters
[in]whereOptional context for error messages, indicating the position of the call.
Returns
The data stored in the container as an integer.

◆ get_as_long()

long_type GC_namespace::GenericContainer::get_as_long ( char const where[] = "") const

Get the stored value as a long integer.

This function retrieves the data stored in the container as a long integer.

Parameters
[in]whereOptional context for error messages, indicating the position of the call.
Returns
The data stored in the container as a long integer.

◆ get_as_uint()

uint_type GC_namespace::GenericContainer::get_as_uint ( char const where[] = "") const

Get the stored value as an unsigned integer.

This function retrieves the data stored in the container as an unsigned integer.

Parameters
[in]whereOptional context for error messages, indicating the position of the call.
Returns
The data stored in the container as an unsigned integer.

◆ get_as_ulong()

ulong_type GC_namespace::GenericContainer::get_as_ulong ( char const where[] = "") const

Get the stored value as an unsigned long integer.

This function retrieves the data stored in the container as an unsigned long integer.

Parameters
[in]whereOptional context for error messages, indicating the position of the call.
Returns
The data stored in the container as an unsigned long integer.

◆ get_bool() [1/2]

bool_type & GC_namespace::GenericContainer::get_bool ( char const where[] = "")

Get the stored value as a boolean.

This function retrieves a boolean value from the container.

Parameters
[in]whereOptional context for error messages, indicating the position of the call.
Returns
A reference to the boolean stored in the container.

◆ get_bool() [2/2]

bool_type const & GC_namespace::GenericContainer::get_bool ( char const where[] = "") const

Get the stored value as a const boolean.

This function retrieves a const boolean value from the container.

Parameters
[in]whereOptional context for error messages, indicating the position of the call.
Returns
A reference to the const boolean stored in the container.

◆ get_bool_at() [1/2]

bool_type GC_namespace::GenericContainer::get_bool_at ( unsigned i)

Get the i-th boolean of the stored data.

Parameters
[in]iThe position of the element in the vector
Returns
The stored value
unsigned index = 3;
bool_type value = container.get_bool_at(index);
// Use value...
GC_namespace::bool_type bool_type
Alias for boolean type.
Definition GenericContainer.hh:576

◆ get_bool_at() [2/2]

bool_type GC_namespace::GenericContainer::get_bool_at ( unsigned i,
char const where[] ) const

Get the i-th boolean of the stored data.

Parameters
[in]iThe position of the element in the vector
[in]wherePosition added to the error message
Returns
The stored value
unsigned index = 3;
bool_type value = container.get_bool_at(index, "In function example_call");
// Use value...

◆ get_complex() [1/2]

complex_type & GC_namespace::GenericContainer::get_complex ( char const where[] = "")

Get the stored value as a complex number.

This function retrieves a complex number from the container.

Parameters
[in]whereOptional context for error messages, indicating the position of the call.
Returns
A reference to the complex number stored in the container.

◆ get_complex() [2/2]

complex_type const & GC_namespace::GenericContainer::get_complex ( char const where[] = "") const

Get the stored value as a const complex number.

This function retrieves a const complex number from the container.

Parameters
[in]whereOptional context for error messages, indicating the position of the call.
Returns
A reference to the const complex number stored in the container.

◆ get_complex_at() [1/4]

complex_type & GC_namespace::GenericContainer::get_complex_at ( unsigned i)

Get the i-th complex_type of the stored data.

Parameters
[in]iThe position of the element in the vector
Returns
The stored value
unsigned index = 7;
complex_type &value = container.get_complex_at(index);
// Use value...
GC_namespace::complex_type complex_type
Alias for complex number type.
Definition GenericContainer.hh:582

◆ get_complex_at() [2/4]

complex_type const & GC_namespace::GenericContainer::get_complex_at ( unsigned i,
char const where[] ) const

Get the i-th const complex_type of the stored data.

Parameters
[in]iThe position of the element in the vector
[in]wherePosition added to the error message
Returns
The stored value
unsigned index = 7;
complex_type const &value = container.get_complex_at(index, "In function example_call");
// Use value...

◆ get_complex_at() [3/4]

complex_type & GC_namespace::GenericContainer::get_complex_at ( unsigned i,
unsigned j )

Get the i-th complex_type of the stored data in a matrix.

Parameters
[in]iRow position of the element in the matrix
[in]jColumn position of the element in the matrix
Returns
The stored value
unsigned row = 1, col = 2;
complex_type &value = container.get_complex_at(row, col);
// Use value...

◆ get_complex_at() [4/4]

complex_type const & GC_namespace::GenericContainer::get_complex_at ( unsigned i,
unsigned j,
char const where[] ) const

Get the i-th const complex_type of the stored data in a matrix.

Parameters
[in]iRow position of the element in the matrix
[in]jColumn position of the element in the matrix
[in]wherePosition added to the error message
Returns
The stored value
unsigned row = 1, col = 2;
complex_type const &value = container.get_complex_at(row, col, "In function example_call");
// Use value...

◆ get_complex_number() [1/2]

complex_type GC_namespace::GenericContainer::get_complex_number ( char const where[] = "") const

Get a stored complex number if the data is boolean, integer, real, or complex type.

Parameters
[in]whereOptional parameter to provide context for error messages.
Returns
The complex number, or 0 if the data is of an unsupported type.

◆ get_complex_number() [2/2]

void GC_namespace::GenericContainer::get_complex_number ( real_type & re,
real_type & im ) const

Get the real and imaginary parts of a stored complex number.

This function extracts the real and imaginary parts of the complex number and stores them in the provided references.

Parameters
[out]reReference to store the real part of the complex number.
[out]imReference to store the imaginary part of the complex number.

◆ get_complex_number_at() [1/2]

complex_type GC_namespace::GenericContainer::get_complex_number_at ( unsigned i,
char const where[] = "" ) const

If the i-th element of the vector is convertible to complex, return the number; otherwise return 0.

Parameters
[in]iThe position of the element in the vector
[in]wherePosition added to the error message
Returns
The value as complex_type
unsigned index = 2;
complex_type value = container.get_complex_number_at(index, "In function example_call");
// Use value...

◆ get_complex_number_at() [2/2]

void GC_namespace::GenericContainer::get_complex_number_at ( unsigned i,
real_type & re,
real_type & im,
char const where[] = "" ) const

If the i-th element of the vector is convertible to complex, return the number; otherwise return 0.

Parameters
[in]iThe position of the element in the vector
[out]reReal part of the number
[out]imImaginary part of the number
[in]wherePosition added to the error message
unsigned index = 2;
real_type realPart, imagPart;
container.get_complex_number_at(index, realPart, imagPart, "In function example_call");
// Use realPart and imagPart...
GC_namespace::real_type real_type
Alias for real (floating point) type.
Definition GenericContainer.hh:581

◆ get_complex_pointer() [1/2]

complex_type * GC_namespace::GenericContainer::get_complex_pointer ( )

Return the stored data as a pointer to complex_type.

Returns
A pointer to complex_type data.

◆ get_complex_pointer() [2/2]

complex_type const * GC_namespace::GenericContainer::get_complex_pointer ( ) const

Return the stored data as a pointer to const complex_type.

Returns
A pointer to const complex_type data.

◆ get_gc_at() [1/2]

GenericContainer & GC_namespace::GenericContainer::get_gc_at ( unsigned i)

Get the i-th const GenericContainer of the stored data.

Parameters
[in]iPosition of the element in the vector
Returns
The stored value
unsigned index = 0;
GenericContainer &value = container.get_gc_at(index);
// Use value...
GenericContainer & get_gc_at(unsigned i)
Definition GenericContainer.cc:3577

◆ get_gc_at() [2/2]

GenericContainer const & GC_namespace::GenericContainer::get_gc_at ( unsigned i,
char const where[] ) const

Get the i-th const GenericContainer of the stored data.

Parameters
[in]iPosition of the element in the vector
[in]wherePosition added to the error message
Returns
The stored value
unsigned index = 0;
GenericContainer const &value = container.get_gc_at(index, "In function example_call");
// Use value...

◆ get_if_exists() [1/11]

template<typename T >
bool GC_namespace::GenericContainer::get_if_exists ( char const field[],
T & value ) const
inline

Check if string field is a key of the stored map and extract value if exists

Parameters
[in]fieldkey to be checked
[in]valuevalue to be extracted

◆ get_if_exists() [2/11]

bool GC_namespace::GenericContainer::get_if_exists ( string_type const & field,
bool & value ) const

Check if string field is a key of the stored map and extract value if exists

Parameters
[in]fieldkey to be checked
[in]valuevalue to be extracted

◆ get_if_exists() [3/11]

bool GC_namespace::GenericContainer::get_if_exists ( string_type const & field,
complex_type & value ) const

Check if string field is a key of the stored map and extract value if exists

Parameters
[in]fieldkey to be checked
[in]valuevalue to be extracted

◆ get_if_exists() [4/11]

bool GC_namespace::GenericContainer::get_if_exists ( string_type const & field,
int_type & value ) const

Check if string field is a key of the stored map and extract value if exists

Parameters
[in]fieldkey to be checked
[in]valuevalue to be extracted

◆ get_if_exists() [5/11]

bool GC_namespace::GenericContainer::get_if_exists ( string_type const & field,
long_type & value ) const

Check if string field is a key of the stored map and extract value if exists

Parameters
[in]fieldkey to be checked
[in]valuevalue to be extracted

◆ get_if_exists() [6/11]

bool GC_namespace::GenericContainer::get_if_exists ( string_type const & field,
real_type & value ) const

Check if string field is a key of the stored map and extract value if exists

Parameters
[in]fieldkey to be checked
[in]valuevalue to be extracted

◆ get_if_exists() [7/11]

bool GC_namespace::GenericContainer::get_if_exists ( string_type const & field,
string_type & value ) const

Check if string field is a key of the stored map and extract value if exists

Parameters
[in]fieldkey to be checked
[in]valuevalue to be extracted

◆ get_if_exists() [8/11]

bool GC_namespace::GenericContainer::get_if_exists ( string_type const & field,
uint_type & value ) const

Check if string field is a key of the stored map and extract value if exists

Parameters
[in]fieldkey to be checked
[in]valuevalue to be extracted

◆ get_if_exists() [9/11]

bool GC_namespace::GenericContainer::get_if_exists ( string_type const & field,
ulong_type & value ) const

Check if string field is a key of the stored map and extract value if exists

Parameters
[in]fieldkey to be checked
[in]valuevalue to be extracted

◆ get_if_exists() [10/11]

bool GC_namespace::GenericContainer::get_if_exists ( vec_string_type const & fields,
bool & value ) const

Check if vector of strings fields is a key of the stored map and extract value if exists

Parameters
[in]fieldskeys to be checked
[in]valuevalue to be extracted

◆ get_if_exists() [11/11]

template<typename T >
bool GC_namespace::GenericContainer::get_if_exists ( vec_string_type const & fields,
T & value ) const
inline

Check if vector of strings fields is a key of the stored map and extract value if exists

Parameters
[in]fieldskeys to be checked
[in]valuevalue to be extracted

◆ get_int() [1/2]

int_type & GC_namespace::GenericContainer::get_int ( char const where[] = "")

Get the stored value as an integer.

This function retrieves an integer value from the container.

Parameters
[in]whereOptional context for error messages, indicating the position of the call.
Returns
A reference to the integer stored in the container.

◆ get_int() [2/2]

int_type const & GC_namespace::GenericContainer::get_int ( char const where[] = "") const

Get the stored value as a const integer.

This function retrieves a const integer value from the container.

Parameters
[in]whereOptional context for error messages, indicating the position of the call.
Returns
A reference to the const integer stored in the container.

◆ get_int_at() [1/4]

int_type & GC_namespace::GenericContainer::get_int_at ( unsigned i)

Get the i-th integer of the stored data.

Parameters
[in]iThe position of the element in the vector
Returns
The stored value
unsigned index = 4;
int_type &value = container.get_int_at(index);
// Use value...
GC_namespace::int_type int_type
Alias for integer type.
Definition GenericContainer.hh:577

◆ get_int_at() [2/4]

int_type const & GC_namespace::GenericContainer::get_int_at ( unsigned i,
char const where[] ) const

Get the i-th const integer of the stored data.

Parameters
[in]iThe position of the element in the vector
[in]wherePosition added to the error message
Returns
The stored value
unsigned index = 4;
int_type const &value = container.get_int_at(index, "In function example_call");
// Use value...

◆ get_int_at() [3/4]

int_type & GC_namespace::GenericContainer::get_int_at ( unsigned i,
unsigned j )

Get the i-th integer of the stored data in a matrix.

Parameters
[in]iRow position of the element in the matrix
[in]jColumn position of the element in the matrix
Returns
The stored value
unsigned row = 0, col = 1;
int_type &value = container.get_int_at(row, col);
// Use value...

◆ get_int_at() [4/4]

int_type const & GC_namespace::GenericContainer::get_int_at ( unsigned i,
unsigned j,
char const where[] ) const

Get the i-th const integer of the stored data in a matrix.

Parameters
[in]iRow position of the element in the matrix
[in]jColumn position of the element in the matrix
[in]wherePosition added to the error message
Returns
The stored value
unsigned row = 0, col = 1;
int_type const &value = container.get_int_at(row, col, "In function example_call");
// Use value...

◆ get_int_pointer() [1/2]

int_type * GC_namespace::GenericContainer::get_int_pointer ( )

Return the stored data as a pointer to const integer.

Returns
A pointer to const integer data.

◆ get_int_pointer() [2/2]

int_type const * GC_namespace::GenericContainer::get_int_pointer ( ) const

Return the stored data as a pointer to const integer

◆ get_keys() [1/2]

string GC_namespace::GenericContainer::get_keys ( ) const

Extracts the keys of the map stored in the GenericContainer as a comma-separated string.

If the container holds a map (MAP type), this method returns the map's keys as a single string, where each key is separated by a comma. If the container is not a map, an exception is thrown.

Returns
A string containing the keys of the map, separated by ", ".
Exceptions
runtime_errorif the container does not hold a map.

Example:

gc.set_map();
gc["key1"].set_int(1);
gc["key2"].set_real(3.14);
string keys = gc.get_keys(); // "key1, key2"
void get_keys(vec_string_type &keys) const
Extracts the keys of the map stored in the GenericContainer into a vector of strings.
Definition GenericContainer.cc:308
int_type & set_int(int_type value)
Set the data type to int_type and assign an integer value.
Definition GenericContainer.cc:750

◆ get_keys() [2/2]

void GC_namespace::GenericContainer::get_keys ( vec_string_type & keys) const

Extracts the keys of the map stored in the GenericContainer into a vector of strings.

If the container holds a map (MAP type), this method populates the provided keys vector with the keys from the map. If the container is not a map, the method throws an exception.

Parameters
[out]keysA vector of strings that will be filled with the map's keys.
Exceptions
runtime_errorif the container does not hold a map.

Example:

gc.set_map();
gc["key1"].set_int(1);
gc["key2"].set_real(3.14);
vector<string> keys;
gc.get_keys(keys); // keys will contain "key1" and "key2"

◆ get_long() [1/2]

long_type & GC_namespace::GenericContainer::get_long ( char const where[] = "")

Get the stored value as a long integer.

This function retrieves a long integer value from the container.

Parameters
[in]whereOptional context for error messages, indicating the position of the call.
Returns
A reference to the long integer stored in the container.

◆ get_long() [2/2]

long_type const & GC_namespace::GenericContainer::get_long ( char const where[] = "") const

Get the stored value as a const long integer.

This function retrieves a const long integer value from the container.

Parameters
[in]whereOptional context for error messages, indicating the position of the call.
Returns
A reference to the const long integer stored in the container.

◆ get_long_at() [1/4]

long_type & GC_namespace::GenericContainer::get_long_at ( unsigned i)

Get the i-th long integer of the stored data.

Parameters
[in]iThe position of the element in the vector
Returns
The stored value
unsigned index = 5;
long_type &value = container.get_long_at(index);
// Use value...
GC_namespace::long_type long_type
Alias for long integer type.
Definition GenericContainer.hh:579

◆ get_long_at() [2/4]

long_type const & GC_namespace::GenericContainer::get_long_at ( unsigned i,
char const where[] ) const

Get the i-th const long integer of the stored data.

Parameters
[in]iThe position of the element in the vector
[in]wherePosition added to the error message
Returns
The stored value
unsigned index = 5;
long_type const &value = container.get_long_at(index, "In function example_call");
// Use value...

◆ get_long_at() [3/4]

long_type & GC_namespace::GenericContainer::get_long_at ( unsigned i,
unsigned j )

Get the i-th long integer of the stored data in a matrix.

Parameters
[in]iRow position of the element in the matrix
[in]jColumn position of the element in the matrix
Returns
The stored value
unsigned row = 0, col = 2;
long_type &value = container.get_long_at(row, col);
// Use value...

◆ get_long_at() [4/4]

long_type const & GC_namespace::GenericContainer::get_long_at ( unsigned i,
unsigned j,
char const where[] ) const

Get the i-th const long integer of the stored data in a matrix.

Parameters
[in]iRow position of the element in the matrix
[in]jColumn position of the element in the matrix
[in]wherePosition added to the error message
Returns
The stored value
unsigned row = 0, col = 2;
long_type const &value = container.get_long_at(row, col, "In function example_call");
// Use value...

◆ get_long_pointer() [1/2]

long_type * GC_namespace::GenericContainer::get_long_pointer ( )

Return the stored data as a pointer to long.

Returns
A pointer to long data.

◆ get_long_pointer() [2/2]

long_type const * GC_namespace::GenericContainer::get_long_pointer ( ) const

Return the stored data as a pointer to const long.

Returns
A pointer to const long data.

◆ get_map() [1/2]

map_type & GC_namespace::GenericContainer::get_map ( char const where[] = "")

Get the stored data as a map of GenericContainer.

Parameters
[in]wherePosition added to the error message
Returns
The stored value
// Example usage of get_map()
try {
auto &myMap = container.get_map("In function example_call");
// Access elements in the map
auto value = myMap["key1"];
// Use value...
} catch (const exception &e) {
cerr << "Error accessing map: " << e.what() << endl;
}

◆ get_map() [2/2]

map_type const & GC_namespace::GenericContainer::get_map ( char const where[] = "") const

Get the stored data as a const map of GenericContainer.

Parameters
[in]wherePosition added to the error message
Returns
The stored value
// Example usage of get_map() with const
try {
const auto &myMap = container.get_map("In function example_call");
// Access elements in the const map
auto const value = myMap.at("key2");
// Use value...
} catch (const exception &e) {
cerr << "Error accessing const map: " << e.what() << endl;
}

◆ get_map_bool() [1/2]

bool_type GC_namespace::GenericContainer::get_map_bool ( char const key[],
char const where[] = "" ) const

Get the stored value in the map as boolean.

This function retrieves a boolean value from the map using the specified key.

Parameters
[in]keyThe key of the map to be selected.
[in]whereOptional parameter to provide context for error messages.
Returns
The boolean value stored in the container.

◆ get_map_bool() [2/2]

bool_type GC_namespace::GenericContainer::get_map_bool ( vec_string_type const & keys,
char const where[] = "" ) const

Get the stored value in the map as boolean. The key is searched between the strings in keys the first one found return the boolena value.

Parameters
[in]keyskeys of the map to be selected
[in]whereposition added to the error message
Returns
the boolean stored in the container

◆ get_map_int() [1/2]

int_type GC_namespace::GenericContainer::get_map_int ( char const key[],
char const where[] = "" ) const

Get the stored value in the map as an integer.

This function retrieves an integer value from the map using the specified key.

Parameters
[in]keyThe key of the map to be selected.
[in]whereOptional context for error messages, indicating the position of the call.
Returns
The integer value stored in the container.

◆ get_map_int() [2/2]

int_type GC_namespace::GenericContainer::get_map_int ( vec_string_type const & keys,
char const where[] = "" ) const

Get the stored value in the map as an integer from a list of keys.

This function searches for the first matching key among the provided strings in keys and returns the corresponding integer value.

Parameters
[in]keysThe list of keys to search in the map.
[in]whereOptional context for error messages, indicating the position of the call.
Returns
The integer value stored in the container for the first found key.

◆ get_map_number() [1/2]

real_type GC_namespace::GenericContainer::get_map_number ( char const key[],
char const where[] = "" ) const

Get the stored value in the map as a real number.

This function retrieves a real number from the map using the specified key.

Parameters
[in]keyThe key of the map to be selected.
[in]whereOptional context for error messages, indicating the position of the call.
Returns
The real number stored in the container.

◆ get_map_number() [2/2]

real_type GC_namespace::GenericContainer::get_map_number ( vec_string_type const & keys,
char const where[] = "" ) const

Get the stored value in the map as a real number from a list of keys.

This function searches for the first matching key among the provided strings in keys and returns the corresponding real number value.

Parameters
[in]keysThe list of keys to search in the map.
[in]whereOptional context for error messages, indicating the position of the call.
Returns
The real number stored in the container for the first found key.

◆ get_map_string() [1/2]

string_type const & GC_namespace::GenericContainer::get_map_string ( char const key[],
char const where[] = "" ) const

Get the stored value in the map as a string.

This function retrieves a string from the map using the specified key.

Parameters
[in]keyThe key of the map to be selected.
[in]whereOptional context for error messages, indicating the position of the call.
Returns
A reference to the string stored in the container.

◆ get_map_string() [2/2]

string_type const & GC_namespace::GenericContainer::get_map_string ( vec_string_type const & keys,
char const where[] = "" ) const

Get the stored value in the map as a string from a list of keys.

This function searches for the first matching key among the provided strings in keys and returns the corresponding string value.

Parameters
[in]keysThe list of keys to search in the map.
[in]whereOptional context for error messages, indicating the position of the call.
Returns
A reference to the string stored in the container for the first found key.

◆ get_map_vec_complex() [1/2]

vec_complex_type const & GC_namespace::GenericContainer::get_map_vec_complex ( char const key[],
char const where[] = "" ) const

Get the stored value in the map as a vector of complex numbers.

This function retrieves a vector of complex numbers from the map using the specified key.

Parameters
[in]keyThe key of the map to be selected.
[in]whereOptional context for error messages, indicating the position of the call.
Returns
A reference to the vector of complex numbers stored in the container.

◆ get_map_vec_complex() [2/2]

vec_complex_type const & GC_namespace::GenericContainer::get_map_vec_complex ( vec_string_type const & keys,
char const where[] = "" ) const

Get the stored value in the map as a vector of complex numbers from a list of keys.

This function searches for the first matching key among the provided strings in keys and returns the corresponding vector of complex numbers.

Parameters
[in]keysThe list of keys to search in the map.
[in]whereOptional context for error messages, indicating the position of the call.
Returns
A reference to the vector of complex numbers stored in the container for the first found key.

◆ get_map_vec_real() [1/2]

vec_real_type const & GC_namespace::GenericContainer::get_map_vec_real ( char const key[],
char const where[] = "" ) const

Get the stored value in the map as a vector of real numbers.

This function retrieves a vector of real numbers from the map using the specified key.

Parameters
[in]keyThe key of the map to be selected.
[in]whereOptional context for error messages, indicating the position of the call.
Returns
A reference to the vector of real numbers stored in the container.

◆ get_map_vec_real() [2/2]

vec_real_type const & GC_namespace::GenericContainer::get_map_vec_real ( vec_string_type const & keys,
char const where[] = "" ) const

Get the stored value in the map as a vector of real numbers from a list of keys.

This function searches for the first matching key among the provided strings in keys and returns the corresponding vector of real numbers.

Parameters
[in]keysThe list of keys to search in the map.
[in]whereOptional context for error messages, indicating the position of the call.
Returns
A reference to the vector of real numbers stored in the container for the first found key.

◆ get_map_vec_string() [1/2]

vec_string_type const & GC_namespace::GenericContainer::get_map_vec_string ( char const key[],
char const where[] = "" ) const

Get the stored value in the map as a vector of strings.

This function retrieves a vector of strings from the map using the specified key.

Parameters
[in]keyThe key of the map to be selected.
[in]whereOptional context for error messages, indicating the position of the call.
Returns
A reference to the vector of strings stored in the container.

◆ get_map_vec_string() [2/2]

vec_string_type const & GC_namespace::GenericContainer::get_map_vec_string ( vec_string_type const & keys,
char const where[] = "" ) const

Get the stored value in the map as a vector of strings from a list of keys.

This function searches for the first matching key among the provided strings in keys and returns the corresponding vector of strings.

Parameters
[in]keysThe list of keys to search in the map.
[in]whereOptional context for error messages, indicating the position of the call.
Returns
A reference to the vector of strings stored in the container for the first found key.

◆ get_mat_complex() [1/2]

mat_complex_type & GC_namespace::GenericContainer::get_mat_complex ( char const where[] = "")

Get the stored value as a matrix of complex_type

Parameters
[in]wherePosition added to the error message
Returns
The data stored in the container as a matrix of complex_type
GenericoContainer container;
mat_complex_type &complex_matrix = container.get_mat_complex("In function get_mat_complex");
// Use complex_matrix...
Generic matrix storage type.
Definition GenericContainer.hh:163

◆ get_mat_complex() [2/2]

mat_complex_type const & GC_namespace::GenericContainer::get_mat_complex ( char const where[] = "") const

Get the stored value as a const matrix of complex_type

Parameters
[in]wherePosition added to the error message
Returns
The data stored in the container as a const matrix of complex_type
const GenericoContainer container;
mat_complex_type const &complex_matrix = container.get_mat_complex("In function get_mat_complex");
// Use complex_matrix...

◆ get_mat_int() [1/2]

mat_int_type & GC_namespace::GenericContainer::get_mat_int ( char const where[] = "")

Get the stored value as a matrix of integers

Parameters
[in]wherePosition added to the error message
Returns
The data stored in the container as a matrix of integers
GenericoContainer container;
mat_int_type &int_matrix = container.get_mat_int("In function get_mat_int");
// Use int_matrix...

◆ get_mat_int() [2/2]

mat_int_type const & GC_namespace::GenericContainer::get_mat_int ( char const where[] = "") const

Get the stored value as a const matrix of integers

Parameters
[in]wherePosition added to the error message
Returns
The data stored in the container as a const matrix of integers
const GenericoContainer container;
mat_int_type const &int_matrix = container.get_mat_int("In function get_mat_int");
// Use int_matrix...

◆ get_mat_long() [1/2]

mat_long_type & GC_namespace::GenericContainer::get_mat_long ( char const where[] = "")

Get the stored value as a matrix of long integers

Parameters
[in]wherePosition added to the error message
Returns
The data stored in the container as a matrix of long integers
GenericoContainer container;
mat_long_type &long_matrix = container.get_mat_long("In function get_mat_long");
// Use long_matrix...

◆ get_mat_long() [2/2]

mat_long_type const & GC_namespace::GenericContainer::get_mat_long ( char const where[] = "") const

Get the stored value as a const matrix of long integers

Parameters
[in]wherePosition added to the error message
Returns
The data stored in the container as a const matrix of long integers
const GenericoContainer container;
mat_long_type const &long_matrix = container.get_mat_long("In function get_mat_long");
// Use long_matrix...

◆ get_mat_real() [1/2]

mat_real_type & GC_namespace::GenericContainer::get_mat_real ( char const where[] = "")

Get the stored value as a matrix of real_type

Parameters
[in]wherePosition added to the error message
Returns
The data stored in the container as a matrix of real_type
GenericoContainer container;
mat_real_type &real_matrix = container.get_mat_real("In function get_mat_real");
// Use real_matrix...

◆ get_mat_real() [2/2]

mat_real_type const & GC_namespace::GenericContainer::get_mat_real ( char const where[] = "") const

Get the stored value as a const matrix of real_type

Parameters
[in]wherePosition added to the error message
Returns
The data stored in the container as a const matrix of real_type
const GenericoContainer container;
mat_real_type const &real_matrix = container.get_mat_real("In function get_mat_real");
// Use real_matrix...

◆ get_num_elements()

unsigned GC_namespace::GenericContainer::get_num_elements ( ) const

Return the number of elements in the first level of the generic container.

  • For scalar elements (e.g., boolean, integer, double), it returns 1.
  • For vector types, it returns the size of the vector.
  • For maps, it returns the number of keys.
Returns
The number of elements in the first level of the container.

◆ get_number()

real_type GC_namespace::GenericContainer::get_number ( char const where[] = "") const

Get a stored numeric value if the data is boolean, integer, or real type.

Parameters
[in]whereOptional parameter to provide context for error messages.
Returns
The numeric value, or 0 if the data is of an unsupported type.

◆ get_number_at()

real_type GC_namespace::GenericContainer::get_number_at ( unsigned i,
char const where[] = "" ) const

If the i-th element of the vector is boolean, integer, or floating point then return the number, otherwise return 0.

Parameters
[in]iThe position of the element in the vector
[in]wherePosition added to the error message
Returns
The value as real_type
unsigned index = 2;
real_type value = container.get_number_at(index, "In function example_call");
// Use value...

◆ get_numCols()

unsigned GC_namespace::GenericContainer::get_numCols ( ) const
inline

◆ get_numRows()

unsigned GC_namespace::GenericContainer::get_numRows ( ) const
inline

◆ get_pointer() [1/2]

template<typename T >
T & GC_namespace::GenericContainer::get_pointer ( )
inline

Get the stored value as a pointer.

This function retrieves the stored pointer value.

◆ get_pointer() [2/2]

template<typename T >
T GC_namespace::GenericContainer::get_pointer ( ) const
inline

Get the stored value as a pointer (const version).

This function retrieves the stored pointer value as a const.

◆ get_pointer_at() [1/2]

template<typename T >
T & GC_namespace::GenericContainer::get_pointer_at ( unsigned i)
inline

Get the i-th pointer of the vector of pointers.

Parameters
[in]iThe position of the element in the vector
Returns
Reference to the pointer
unsigned index = 1;
auto& pointer = container.get_pointer_at<MyType>(index);
// Use pointer...

◆ get_pointer_at() [2/2]

template<typename T >
T GC_namespace::GenericContainer::get_pointer_at ( unsigned i) const
inline

Return i-th generic pointer (if fails issue an error).

Get the i-th pointer of the vector of pointers.

Parameters
[in]iThe position of the element in the vector
Returns
The stored pointer
unsigned index = 1;
MyType pointer = container.get_pointer_at<MyType>(index);
// Use pointer...

◆ get_ppvoid()

void ** GC_namespace::GenericContainer::get_ppvoid ( char const where[] = "") const

Return the stored data as a double pointer.

Parameters
[in]whereOptional parameter to provide context for error messages.
Returns
A double pointer to the stored data.

◆ get_pvoid()

void * GC_namespace::GenericContainer::get_pvoid ( char const where[] = "") const

Return the stored data as a generic pointer.

Parameters
[in]whereOptional parameter to provide context for error messages.
Returns
A void pointer to the stored data.

◆ get_real() [1/2]

real_type & GC_namespace::GenericContainer::get_real ( char const where[] = "")

Get the stored value as a real number.

This function retrieves a real number from the container.

Parameters
[in]whereOptional context for error messages, indicating the position of the call.
Returns
A reference to the real number stored in the container.

◆ get_real() [2/2]

real_type const & GC_namespace::GenericContainer::get_real ( char const where[] = "") const

Get the stored value as a const real number.

This function retrieves a const real number from the container.

Parameters
[in]whereOptional context for error messages, indicating the position of the call.
Returns
A reference to the const real number stored in the container.

◆ get_real_at() [1/4]

real_type & GC_namespace::GenericContainer::get_real_at ( unsigned i)

Get the i-th real_type of the stored data.

Parameters
[in]iThe position of the element in the vector
Returns
The stored value
unsigned index = 6;
real_type &value = container.get_real_at(index);
// Use value...

◆ get_real_at() [2/4]

real_type const & GC_namespace::GenericContainer::get_real_at ( unsigned i,
char const where[] ) const

Get the i-th const real_type of the stored data.

Parameters
[in]iThe position of the element in the vector
[in]wherePosition added to the error message
Returns
The stored value
unsigned index = 6;
real_type const &value = container.get_real_at(index, "In function example_call");
// Use value...

◆ get_real_at() [3/4]

real_type & GC_namespace::GenericContainer::get_real_at ( unsigned i,
unsigned j )

Get the i-th real_type of the stored data in a matrix.

Parameters
[in]iRow position of the element in the matrix
[in]jColumn position of the element in the matrix
Returns
The stored value
unsigned row = 1, col = 1;
real_type &value = container.get_real_at(row, col);
// Use value...

◆ get_real_at() [4/4]

real_type const & GC_namespace::GenericContainer::get_real_at ( unsigned i,
unsigned j,
char const where[] ) const

Get the i-th const real_type of the stored data in a matrix.

Parameters
[in]iRow position of the element in the matrix
[in]jColumn position of the element in the matrix
[in]wherePosition added to the error message
Returns
The stored value
unsigned row = 1, col = 1;
real_type const &value = container.get_real_at(row, col, "In function example_call");
// Use value...

◆ get_real_pointer() [1/2]

real_type * GC_namespace::GenericContainer::get_real_pointer ( )

Return the stored data as a pointer to real_type.

Returns
A pointer to real_type data.

◆ get_real_pointer() [2/2]

real_type const * GC_namespace::GenericContainer::get_real_pointer ( ) const

Return the stored data as a pointer to const real_type.

Returns
A pointer to const real_type data.

◆ get_string() [1/2]

string_type & GC_namespace::GenericContainer::get_string ( char const where[] = "")

Get the stored value as a string.

This function retrieves a string from the container.

Parameters
[in]whereOptional context for error messages, indicating the position of the call.
Returns
A reference to the string stored in the container.

◆ get_string() [2/2]

string_type const & GC_namespace::GenericContainer::get_string ( char const where[] = "") const

Get the stored value as a const string.

This function retrieves a const string from the container.

Parameters
[in]whereOptional context for error messages, indicating the position of the call.
Returns
A reference to the const string stored in the container.

◆ get_string_at() [1/2]

string_type & GC_namespace::GenericContainer::get_string_at ( unsigned i)

Get the i-th string of the stored data.

Parameters
[in]iPosition of the element in the vector
Returns
The stored value
unsigned index = 0;
string_type &value = container.get_string_at(index);
// Use value...
GC_namespace::string_type string_type
Alias for string type.
Definition GenericContainer.hh:583

◆ get_string_at() [2/2]

string_type const & GC_namespace::GenericContainer::get_string_at ( unsigned i,
char const where[] ) const

Get the i-th const string of the stored data.

Parameters
[in]iPosition of the element in the vector
[in]wherePosition added to the error message
Returns
The stored value
unsigned index = 0;
string_type const &value = container.get_string_at(index, "In function example_call");
// Use value...

◆ get_type()

TypeAllowed GC_namespace::GenericContainer::get_type ( ) const
inline

Return an integer representing the type of data stored.

This function returns an integer corresponding to the type of data that is currently stored in the container. The integer is mapped to specific data types as follows:

  • 0: No data stored
  • 1: pointer_type
  • 2: bool_type
  • 3: int_type
  • 4: long_type
  • 5: real_type
  • 6: complex_type
  • 7: string_data
  • 8: vec_pointer_type
  • 9: vec_bool_type
  • 10: vec_int_type
  • 11: vec_long_type
  • 12: vec_real_type
  • 13: vec_complex_type
  • 14: vec_string_type
  • 15: mat_int_type
  • 16: mat_long_type
  • 17: mat_real_type
  • 18: mat_complex_type
  • 19: vector_type
  • 20: map_type
Returns
The type of the internally stored data as an integer.

◆ get_type_name()

char const * GC_namespace::GenericContainer::get_type_name ( ) const
inline

Return a string representing the type of data stored.

This function returns a pointer to a string that describes the type of data currently held by the container. This is helpful for debugging and logging purposes.

Returns
A pointer to a string representation of the data type.

◆ get_value()

template<typename T >
void GC_namespace::GenericContainer::get_value ( T & v,
char const where[] = "" ) const

Get the stored value.

This template function retrieves the stored value and assigns it to the provided reference variable.

Parameters
[out]vThe reference to store the copied value.
[in]whereOptional parameter to provide context for error messages.

◆ get_vec_bool() [1/2]

vec_bool_type & GC_namespace::GenericContainer::get_vec_bool ( char const where[] = "")

Get the stored value as a vector of booleans

Parameters
[in]wherePosition added to the error message
Returns
The data stored in the container as a vector of booleans
GenericoContainer container;
vec_bool_type &bool_data = container.get_vec_bool("In function get_vec_bool");
// Use bool_data...
GC_namespace::vec_bool_type vec_bool_type
Alias for vector of booleans type.
Definition GenericContainer.hh:585

◆ get_vec_bool() [2/2]

vec_bool_type const & GC_namespace::GenericContainer::get_vec_bool ( char const where[] = "") const

Get the stored value as a const vector of booleans

Parameters
[in]wherePosition added to the error message
Returns
The data stored in the container as a const vector of booleans
const GenericoContainer container;
vec_bool_type const &bool_data = container.get_vec_bool("In function get_vec_bool");
// Use bool_data...

◆ get_vec_complex() [1/2]

vec_complex_type & GC_namespace::GenericContainer::get_vec_complex ( char const where[] = "")

Get the stored value as a vector of complex_type

Parameters
[in]wherePosition added to the error message
Returns
The data stored in the container as a vector of complex_type
GenericoContainer container;
vec_complex_type &complex_data = container.get_vec_complex("In function get_vec_complex");
// Use complex_data...

◆ get_vec_complex() [2/2]

vec_complex_type const & GC_namespace::GenericContainer::get_vec_complex ( char const where[] = "") const

Get the stored value as a const vector of complex_type

Parameters
[in]wherePosition added to the error message
Returns
The data stored in the container as a const vector of complex_type
const GenericoContainer container;
vec_complex_type const &complex_data = container.get_vec_complex("In function get_vec_complex");
// Use complex_data...

◆ get_vec_int() [1/2]

vec_int_type & GC_namespace::GenericContainer::get_vec_int ( char const where[] = "")

Get the stored value as a vector of integers

Parameters
[in]wherePosition added to the error message
Returns
The data stored in the container as a vector of integers
GenericoContainer container;
vec_int_type &int_data = container.get_vec_int("In function get_vec_int");
// Use int_data...

◆ get_vec_int() [2/2]

vec_int_type const & GC_namespace::GenericContainer::get_vec_int ( char const where[] = "") const

Get the stored value as a const vector of integers

Parameters
[in]wherePosition added to the error message
Returns
The data stored in the container as a const vector of integers
const GenericoContainer container;
vec_int_type const &int_data = container.get_vec_int("In function get_vec_int");
// Use int_data...

◆ get_vec_long() [1/2]

vec_long_type & GC_namespace::GenericContainer::get_vec_long ( char const where[] = "")

Get the stored value as a vector of long integers

Parameters
[in]wherePosition added to the error message
Returns
The data stored in the container as a vector of long integers
GenericoContainer container;
vec_long_type &long_data = container.get_vec_long("In function get_vec_long");
// Use long_data...

◆ get_vec_long() [2/2]

vec_long_type const & GC_namespace::GenericContainer::get_vec_long ( char const where[] = "") const

Get the stored value as a const vector of long integers

Parameters
[in]wherePosition added to the error message
Returns
The data stored in the container as a const vector of long integers
const GenericoContainer container;
vec_long_type const &long_data = container.get_vec_long("In function get_vec_long");
// Use long_data...

◆ get_vec_pointer() [1/2]

vec_pointer_type & GC_namespace::GenericContainer::get_vec_pointer ( char const where[] = "")

Get the stored value as a vector of pointers

Parameters
[in]wherePosition added to the error message
Returns
The data stored in the container as a vector of pointers
GenericoContainer container;
vec_pointer_type &ptr_data = container.get_vec_pointer("In function get_vec_pointer");
// Use ptr_data...
GC_namespace::vec_pointer_type vec_pointer_type
Alias for vector of pointers type.
Definition GenericContainer.hh:584

◆ get_vec_pointer() [2/2]

vec_pointer_type const & GC_namespace::GenericContainer::get_vec_pointer ( char const where[] = "") const

Get the stored value as a const vector of pointers

Parameters
[in]wherePosition added to the error message
Returns
The data stored in the container as a const vector of pointers
const GenericoContainer container;
vec_pointer_type const &ptr_data = container.get_vec_pointer("In function get_vec_pointer");
// Use ptr_data...

◆ get_vec_real() [1/2]

vec_real_type & GC_namespace::GenericContainer::get_vec_real ( char const where[] = "")

Get the stored value as a vector of real_type

Parameters
[in]wherePosition added to the error message
Returns
The data stored in the container as a vector of real_type
GenericoContainer container;
vec_real_type &real_data = container.get_vec_real("In function get_vec_real");
// Use real_data...

◆ get_vec_real() [2/2]

vec_real_type const & GC_namespace::GenericContainer::get_vec_real ( char const where[] = "") const

Get the stored value as a const vector of real_type

Parameters
[in]wherePosition added to the error message
Returns
The data stored in the container as a const vector of real_type
const GenericoContainer container;
vec_real_type const &real_data = container.get_vec_real("In function get_vec_real");
// Use real_data...

◆ get_vec_string() [1/2]

vec_string_type & GC_namespace::GenericContainer::get_vec_string ( char const where[] = "")

Get the stored value as a vector of strings

Parameters
[in]wherePosition added to the error message
Returns
The data stored in the container as a vector of strings
GenericoContainer container;
vec_string_type &string_data = container.get_vec_string("In function get_vec_string");
// Use string_data...

◆ get_vec_string() [2/2]

vec_string_type const & GC_namespace::GenericContainer::get_vec_string ( char const where[] = "") const

Get the stored value as a const vector of strings

Parameters
[in]wherePosition added to the error message
Returns
The data stored in the container as a const vector of strings
const GenericoContainer container;
vec_string_type const &string_data = container.get_vec_string("In function get_vec_string");
// Use string_data...

◆ get_vector() [1/2]

vector_type & GC_namespace::GenericContainer::get_vector ( char const where[] = "")

Get the stored value as a vector of GenericoContainer

Parameters
[in]wherePosition added to the error message
Returns
The data stored in the container as a vector of GenericoContainer
GenericoContainer container;
vector_type &data = container.get_vector("In function get_vector");
// Use data...
GC_namespace::vector_type vector_type
Alias for vector of GenericContainer type.
Definition GenericContainer.hh:593

◆ get_vector() [2/2]

vector_type const & GC_namespace::GenericContainer::get_vector ( char const where[] = "") const

Get the stored value as a const vector of GenericoContainer

Parameters
[in]wherePosition added to the error message
Returns
The data stored in the container as a const vector of GenericoContainer
const GenericoContainer container;
vector_type const &data = container.get_vector("In function get_vector");
// Use data...

◆ info() [1/2]

string_type GC_namespace::GenericContainer::info ( ) const
inline

Print information about the kind of data stored as a string.

This method returns a string containing information about the data type and its properties.

Returns
A string representation of the data information.

◆ info() [2/2]

GenericContainer const & GC_namespace::GenericContainer::info ( ostream_type & stream) const

Print information about the kind of data stored to a stream.

This method outputs information about the data type and its properties to the provided output stream.

Parameters
[out]streamThe output stream to write the information to.
Returns
A reference to the current GenericContainer object.

◆ load()

void GC_namespace::GenericContainer::load ( GenericContainer const & a)
inline

Load a GenericContainer to the generic container (deep copy).

Parameters
[in]aGenericContainer to be stored

◆ mem_size()

int32_t GC_namespace::GenericContainer::mem_size ( ) const

Dimension in byte of the serialized generic container.

◆ merge()

void GC_namespace::GenericContainer::merge ( GenericContainer const & gc,
char const where[] )

Merge two generic container

Parameters
[in]gcinput GenericContainer
[in]whereposition added to the error message

◆ must_exists()

string GC_namespace::GenericContainer::must_exists ( vec_string_type const & vs,
char const where[] ) const

The data stored musty be a map. Search the

Parameters
[in]`vs`vector of string with the keys to be searched
[in]whereposition added to the error message

◆ num_cols()

unsigned GC_namespace::GenericContainer::num_cols ( ) const

Return the number of columns in the internally stored matrix.

Returns
The number of columns in the matrix.

◆ num_rows()

unsigned GC_namespace::GenericContainer::num_rows ( ) const

Return the number of rows in the internally stored matrix.

Returns
The number of rows in the matrix.

◆ operator()() [1/6]

GenericContainer & GC_namespace::GenericContainer::operator() ( string_type const & s,
char const where[] = "" )

Get a GenericContainer in the stored data using a string key with error message.

Parameters
[in]sKey string of the element in the map
[in]wherePosition added to the error message
Returns
The stored value
// Example usage of operator() with string key
GenericContainer &item = container("myKey", "Accessing item with key 'myKey'");
// Use item...

◆ operator()() [2/6]

GenericContainer const & GC_namespace::GenericContainer::operator() ( string_type const & s,
char const where[] = "" ) const

Get a const GenericContainer in the stored data using a string key with error message.

Parameters
[in]sKey string of the element in the map
[in]wherePosition added to the error message
Returns
The stored value
// Example usage of operator() with string key for const
const GenericContainer &constItem = container("myKey", "Accessing const item with key 'myKey'");
// Use constItem...

◆ operator()() [3/6]

GenericContainer & GC_namespace::GenericContainer::operator() ( unsigned i,
char const where[] = "" )

Get the i-th GenericContainer of the stored data with error message.

Parameters
[in]iPosition of the element in the vector
[in]wherePosition added to the error message
Returns
The stored value
// Example usage of operator() with error message
try {
GenericContainer &item = container(i, "Accessing item at index 3");
// Use item...
} catch (const exception &e) {
cerr << e.what() << endl;
}

◆ operator()() [4/6]

GenericContainer const & GC_namespace::GenericContainer::operator() ( unsigned i,
char const where[] = "" ) const

Get the i-th const GenericContainer of the stored data with error message.

Parameters
[in]iPosition of the element in the vector
[in]wherePosition added to the error message
Returns
The stored value
// Example usage of operator() with error message for const
try {
const GenericContainer &constItem = container(i, "Accessing item at index 3");
// Use constItem...
} catch (const exception &e) {
cerr << e.what() << endl;
}

◆ operator()() [5/6]

GenericContainer & GC_namespace::GenericContainer::operator() ( vec_string_type const & vs,
char const where[] = "" )

Get a GenericContainer in the stored data by searching for a matching key from a vector of keys.

Parameters
[in]vsVector of keys strings
[in]wherePosition added to the error message
Returns
The stored value of the first match
// Example usage of operator() with vector of keys
vec_string_type keys = {"key1", "key2", "key3"};
GenericContainer &matchedItem = container(keys, "Searching for matching key");
// Use matchedItem...

◆ operator()() [6/6]

GenericContainer const & GC_namespace::GenericContainer::operator() ( vec_string_type const & vs,
char const where[] = "" ) const

Get a const GenericContainer in the stored data by searching for a matching key from a vector of keys.

Parameters
[in]vsVector of keys string
[in]wherePosition added to the error message
Returns
The stored value of the first match
// Example usage of operator() with vector of keys for const
const vec_string_type keys = {"key1", "key2", "key3"};
const GenericContainer &constMatchedItem = container(keys, "Searching for matching key");
// Use constMatchedItem...

◆ operator=() [1/23]

GenericContainer & GC_namespace::GenericContainer::operator= ( bool const & a)
inline

Assign a boolean to the generic container.

Parameters
[in]aboolean to be stored

◆ operator=() [2/23]

GenericContainer & GC_namespace::GenericContainer::operator= ( char const * a)
inline

Assign a string to the generic container.

Parameters
[in]astring to be stored

◆ operator=() [3/23]

GenericContainer & GC_namespace::GenericContainer::operator= ( complex< double > const & a)
inline

Assign a complex of double to the generic container.

Parameters
[in]acomplex of double to be stored

◆ operator=() [4/23]

GenericContainer & GC_namespace::GenericContainer::operator= ( complex< float > const & a)
inline

Assign a complex of float to the generic container.

Parameters
[in]acomplex of float to be stored

◆ operator=() [5/23]

GenericContainer & GC_namespace::GenericContainer::operator= ( double const & a)
inline

Assign a double to the generic container.

Parameters
[in]adouble to be stored

◆ operator=() [6/23]

GenericContainer & GC_namespace::GenericContainer::operator= ( float const & a)
inline

Assign a float to the generic container.

Parameters
[in]afloat to be stored

◆ operator=() [7/23]

GenericContainer const & GC_namespace::GenericContainer::operator= ( GenericContainer const & a)
inline

Assign a GenericContainer to the generic container (deep copy).

Parameters
[in]aGenericContainer to be stored

◆ operator=() [8/23]

GenericContainer & GC_namespace::GenericContainer::operator= ( int_type const & a)
inline

Assign an integer to the generic container.

Parameters
[in]ainteger to be stored

◆ operator=() [9/23]

GenericContainer & GC_namespace::GenericContainer::operator= ( long_type const & a)
inline

Assign a long integer to the generic container.

Parameters
[in]along integer to be stored

◆ operator=() [10/23]

GenericContainer & GC_namespace::GenericContainer::operator= ( mat_complex_type const & a)

Assign a matrix of complex_type to the generic container.

Parameters
[in]amatrix of complex_type to be stored

◆ operator=() [11/23]

GenericContainer & GC_namespace::GenericContainer::operator= ( mat_int_type const & a)

Assign a matrix of integer to the generic container.

Parameters
[in]amatrix of integer to be stored

◆ operator=() [12/23]

GenericContainer & GC_namespace::GenericContainer::operator= ( mat_long_type const & a)

Assign a matrix of long integer to the generic container.

Parameters
[in]amatrix of long integer to be stored

◆ operator=() [13/23]

GenericContainer & GC_namespace::GenericContainer::operator= ( mat_real_type const & a)

Assign a matrix of real_type to the generic container.

Parameters
[in]amatrix of real_type to be stored

◆ operator=() [14/23]

GenericContainer & GC_namespace::GenericContainer::operator= ( pointer_type a)
inline

Assign a pointer to the generic container.

Parameters
[in]apointer to be stored

◆ operator=() [15/23]

GenericContainer & GC_namespace::GenericContainer::operator= ( string_type const & a)
inline

Assign a string to the generic container.

Parameters
[in]astring to be stored

◆ operator=() [16/23]

GenericContainer & GC_namespace::GenericContainer::operator= ( uint_type const & a)
inline

Assign an integer to the generic container.

Parameters
[in]ainteger to be stored

◆ operator=() [17/23]

GenericContainer & GC_namespace::GenericContainer::operator= ( ulong_type const & a)
inline

Assign an unsigned long to the generic container.

Parameters
[in]aunsigned long to be stored

◆ operator=() [18/23]

GenericContainer & GC_namespace::GenericContainer::operator= ( vec_bool_type const & a)

Assign a vector of bool to the generic container.

Parameters
[in]avector of bool to be stored

◆ operator=() [19/23]

GenericContainer & GC_namespace::GenericContainer::operator= ( vec_complex_type const & a)

Assign a vector of complex_type to the generic container.

Parameters
[in]avector of complex_type to be stored

◆ operator=() [20/23]

GenericContainer & GC_namespace::GenericContainer::operator= ( vec_int_type const & a)

Assign a vector of integer to the generic container.

Parameters
[in]avector of integer to be stored

◆ operator=() [21/23]

GenericContainer & GC_namespace::GenericContainer::operator= ( vec_long_type const & a)

Assign a vector of long integer to the generic container.

Parameters
[in]avector of long integer to be stored

◆ operator=() [22/23]

GenericContainer & GC_namespace::GenericContainer::operator= ( vec_real_type const & a)

Assign a vector of real_type to the generic container.

Parameters
[in]avector of real_type to be stored

◆ operator=() [23/23]

GenericContainer & GC_namespace::GenericContainer::operator= ( vec_string_type const & a)

Assign a vector of string to the generic container.

Parameters
[in]avector of string to be stored

◆ operator[]() [1/4]

GenericContainer & GC_namespace::GenericContainer::operator[] ( string_type const & s)

Get the i-th GenericContainer of the stored data using a string key.

Parameters
[in]sKey string of the element in the map
Returns
The stored value
// Example usage of operator[] with string key
GenericContainer &mapItem = container["myKey"];
// Use mapItem...

◆ operator[]() [2/4]

GenericContainer const & GC_namespace::GenericContainer::operator[] ( string_type const & s) const

Get the i-th const GenericContainer of the stored data using a string key.

Parameters
[in]sKey string of the element in the map
Returns
The stored value
// Example usage of operator[] with string key for const
const GenericContainer &constMapItem = container["myKey"];
// Use constMapItem...

◆ operator[]() [3/4]

GenericContainer & GC_namespace::GenericContainer::operator[] ( unsigned i)

Get the i-th GenericContainer of the stored data.

Parameters
[in]iPosition of the element in the vector
Returns
The stored value
// Example usage of operator[] for non-const
GenericContainer &containerItem = container[2];
// Use containerItem...

◆ operator[]() [4/4]

GenericContainer const & GC_namespace::GenericContainer::operator[] ( unsigned i) const

Get the i-th const GenericContainer of the stored data.

Parameters
[in]iPosition of the element in the vector
Returns
The stored value
// Example usage of operator[] for const
const GenericContainer &constContainerItem = container[2];
// Use constContainerItem...

◆ print() [1/2]

void GC_namespace::GenericContainer::print ( ostream_type & stream,
string_type const & prefix = "",
string_type const & indent = "    " ) const
inline

Dump the contents of the object in a human readable way (aliad of dump)

Parameters
[in]streamoutput stream
[in]prefixstrig to be prepended to any field of the GenericContainer
[in]indentindentation

◆ print() [2/2]

string_type GC_namespace::GenericContainer::print ( string_type const & prefix = "",
string_type const & indent = "    " ) const
inline

Dump the contents of the object in a human readable way (aliad of dump)

Parameters
[in]prefixstrig to be prepended to any field of the GenericContainer
[in]indentindentation

◆ print_content_types()

void GC_namespace::GenericContainer::print_content_types ( ostream_type & stream,
string_type const & prefix = "",
string_type const & indent = "    " ) const

Print the contents of the object in a human readable way (without data)

Parameters
[in]streamoutput stream
[in]prefixstrig to be prepended to any field of the GenericContainer
[in]indentindentation

◆ promote_to_complex()

GenericContainer const & GC_namespace::GenericContainer::promote_to_complex ( )

If data contains a boolean or an integer or floating point it is promoted to a complex floating point.

◆ promote_to_int()

GenericContainer const & GC_namespace::GenericContainer::promote_to_int ( )

If data contains a boolean it is promoted to an integer.

◆ promote_to_long()

GenericContainer const & GC_namespace::GenericContainer::promote_to_long ( )

If data contains a boolean it is promoted to an integer.

◆ promote_to_mat_complex()

GenericContainer const & GC_namespace::GenericContainer::promote_to_mat_complex ( )

If data contains vector of booleans, integer or real or complex or matrix of real it is promoted to a matrix of complex.

◆ promote_to_mat_int()

GenericContainer const & GC_namespace::GenericContainer::promote_to_mat_int ( )

If data contains vector of booleans, integer or real it is promoted to a matrix of integer.

◆ promote_to_mat_long()

GenericContainer const & GC_namespace::GenericContainer::promote_to_mat_long ( )

If data contains vector of booleans, integer or real it is promoted to a matrix of long integer.

◆ promote_to_mat_real()

GenericContainer const & GC_namespace::GenericContainer::promote_to_mat_real ( )

If data contains vector of booleans, integer or real it is promoted to a matrix of real.

◆ promote_to_real()

GenericContainer const & GC_namespace::GenericContainer::promote_to_real ( )

If data contains a boolean or an integer it is promoted to a real.

◆ promote_to_vec_complex()

GenericContainer const & GC_namespace::GenericContainer::promote_to_vec_complex ( )

If data contains vector of booleans or integer or real it is promoted to a vector of complex.

◆ promote_to_vec_int()

GenericContainer const & GC_namespace::GenericContainer::promote_to_vec_int ( )

If data contains vector of booleans it is promoted to a vector of integer.

◆ promote_to_vec_long()

GenericContainer const & GC_namespace::GenericContainer::promote_to_vec_long ( )

If data contains vector of booleans it is promoted to a vector of integer.

◆ promote_to_vec_real()

GenericContainer const & GC_namespace::GenericContainer::promote_to_vec_real ( )

If data contains vector of booleans or integer it is promoted to a vector of real.

◆ promote_to_vector()

GenericContainer const & GC_namespace::GenericContainer::promote_to_vector ( )

If data contains vector of someting it is promoted to a vector of GenericContainer.

◆ push_bool()

void GC_namespace::GenericContainer::push_bool ( bool b)

Push a boolean value into the vector or matrix.

This method adds a boolean value to vec_bool_type or a general vector_type.

Parameters
[in]bvalue The boolean value to push.

◆ push_complex() [1/2]

void GC_namespace::GenericContainer::push_complex ( complex_type & c)

Push a complex number into the vector or matrix using an existing complex object.

This method adds a complex number to vec_complex_type or a general vector_type.

Parameters
[in]cvalue The complex number to push.

◆ push_complex() [2/2]

void GC_namespace::GenericContainer::push_complex ( real_type re,
real_type im )

Push a complex number into the vector or matrix using real and imaginary parts.

This method adds a complex number to vec_complex_type or a general vector_type.

Parameters
[in]reThe real part of the complex number.
[in]imThe imaginary part of the complex number.

◆ push_int()

void GC_namespace::GenericContainer::push_int ( int_type i)

Push an integer value into the vector or matrix.

This method adds an integer value to vec_int_type or a general vector_type.

Parameters
[in]ivalue The integer value to push.

◆ push_long()

void GC_namespace::GenericContainer::push_long ( long_type l)

Push a long integer value into the vector or matrix.

This method adds a long integer value to vec_long_type or a general vector_type.

Parameters
[in]lvalue The long integer value to push.

◆ push_real()

void GC_namespace::GenericContainer::push_real ( real_type r)

Push a real number into the vector or matrix.

This method adds a real number to vec_real_type or a general vector_type.

Parameters
[in]rvalue The real number to push.

◆ push_string()

void GC_namespace::GenericContainer::push_string ( string_type const & s)

Push a string value into the vector or matrix.

This method adds a string to vec_string_type or a general vector_type.

Parameters
[in]svalue The string value to push.

◆ readFormattedData() [1/2]

GenericContainer & GC_namespace::GenericContainer::readFormattedData ( char const fname[],
char const commentChars[] = "#%",
char const delimiters[] = " \t" )

Read regular formatted data from file fname to GenericContainer.

After successful read GenericContainer will be a map which contains the fields:

  • "headers" a vec_string_type which contains the strings of the headers of the columns of the data
  • "data" a vector_type which contains the vectors which are the columns of the data red of type vec_real_type.
Parameters
fnamefile name to be read
commentCharslines beginning with one of this chars are treated as comments. Default are # and %
delimiterscharacters used as delimiter for headers

◆ readFormattedData() [2/2]

GenericContainer & GC_namespace::GenericContainer::readFormattedData ( istream_type & stream,
char const commentChars[] = "#%",
char const delimiters[] = " \t" )

Read regular formatted data from stream to GenericContainer.

After successful read GenericContainer will be a map which contains the fields:

  • "headers" a vec_string_type which contains the strings of the headers of the columns of the data
  • "data" a vector_type which contains the vectors which are the columns of the data red of type vec_real_type.
Parameters
streamstream to write the output
commentCharslines beginning with one of this chars are treated as comments. Default are # and %
delimiterscharacters used as delimiter for headers

◆ readFormattedData2() [1/2]

GenericContainer & GC_namespace::GenericContainer::readFormattedData2 ( char const fname[],
char const commentChars[] = "#%",
char const delimiters[] = " \t",
GenericContainer ptr_pars[] = nullptr )

Read regular formatted data from file fname to GenericContainer.

After successful read GenericContainer will be a map which contains the fields:

  • "headers" a vec_string_type which contains the strings of the headers of the columns of the data
  • "data" a map_type which contains the vectors which are the columns of the data red of type vec_real_type.
Parameters
fnamefile name to be read
commentCharslines beginning with one of this chars are treated as comments. Default are # and %
delimiterscharacters used as delimiter for headers
ptr_parspointer to a GenericContainer which store poarameter parsed in the comment part of the file

◆ readFormattedData2() [2/2]

GenericContainer & GC_namespace::GenericContainer::readFormattedData2 ( istream_type & stream,
char const commentChars[] = "#%",
char const delimiters[] = " \t",
GenericContainer ptr_pars[] = nullptr )

Read regular formatted data from stream to GenericContainer.

After successful read GenericContainer will be a map which contains the fields:

  • "headers" a vec_string_type which contains the strings of the headers of the columns of the data
  • "data" a map_type which contains the vectors which are the columns of the data red of type vec_real_type.
Parameters
streamstream to write the output
commentCharslines beginning with one of this chars are treated as comments. Default are # and %
delimiterscharacters used as delimiter for headers
ptr_parspointer to a GenericContainer which store poarameter parsed in the comment part of the file

◆ serialize() [1/2]

int32_t GC_namespace::GenericContainer::serialize ( int32_t buffer_dim,
uint8_t * buffer ) const

Fill the buffer with the serialized version of the GenericContainer.

◆ serialize() [2/2]

int32_t GC_namespace::GenericContainer::serialize ( vector< uint8_t > & buffer) const

Fill the buffer with the serialized version of the GenericContainer.

◆ set() [1/12]

void GC_namespace::GenericContainer::set ( bool const & a)
inline

Assign a boolean to the generic container.

Parameters
[in]aBoolean to be stored
// Example usage of setting a boolean
GenericContainer container;
container.set(true); // Store true in the container
void set(bool const &a)
Definition GenericContainer.hh:3160

◆ set() [2/12]

void GC_namespace::GenericContainer::set ( char const * a)
inline

Assign a string to the generic container.

Parameters
[in]aString to be stored
// Example usage of setting a C-style string
GenericContainer container;
container.set("Hello, World!"); // Store "Hello, World!" in the container

◆ set() [3/12]

void GC_namespace::GenericContainer::set ( complex< double > const & a)
inline

Assign a complex double to the generic container.

Parameters
[in]aComplex double to be stored
// Example usage of setting a complex double
GenericContainer container;
complex<double> complexDouble(3.0, 4.0);
container.set(complexDouble); // Store complex number (3.0, 4.0) in the container

◆ set() [4/12]

void GC_namespace::GenericContainer::set ( complex< float > const & a)
inline

Assign a complex float to the generic container.

Parameters
[in]aComplex float to be stored
// Example usage of setting a complex float
GenericContainer container;
complex<float> complexFloat(1.0f, 2.0f);
container.set(complexFloat); // Store complex number (1.0, 2.0) in the container

◆ set() [5/12]

void GC_namespace::GenericContainer::set ( double const & a)
inline

Assign a double to the generic container.

Parameters
[in]aDouble to be stored
// Example usage of setting a double
GenericContainer container;
container.set(2.7182818284); // Store 2.7182818284 as a double in the container

◆ set() [6/12]

void GC_namespace::GenericContainer::set ( float const & a)
inline

Assign a float to the generic container.

Parameters
[in]aFloat to be stored
// Example usage of setting a float
GenericContainer container;
container.set(3.14f); // Store 3.14 as a float in the container

◆ set() [7/12]

void GC_namespace::GenericContainer::set ( int_type const & a)
inline

Assign an integer to the generic container.

Parameters
[in]aInteger to be stored
// Example usage of setting an integer
GenericContainer container;
container.set(-7); // Store -7 in the container

◆ set() [8/12]

void GC_namespace::GenericContainer::set ( long_type const & a)
inline

Assign a long integer to the generic container.

Parameters
[in]aLong integer to be stored
// Example usage of setting a long integer
GenericContainer container;
container.set(123456789L); // Store 123456789 as a long integer in the container

◆ set() [9/12]

void GC_namespace::GenericContainer::set ( pointer_type a)
inline

Assign a pointer to the generic container.

Parameters
[in]aPointer to be stored
// Example usage of setting a pointer
GenericContainer container;
int value = 42;
container.set(&value); // Store the address of value in the container

◆ set() [10/12]

void GC_namespace::GenericContainer::set ( string_type const & a)
inline

Assign a string to the generic container.

Parameters
[in]aString to be stored
// Example usage of setting a string
GenericContainer container;
container.set(string("Hello, C++!")); // Store "Hello, C++!" in the container

◆ set() [11/12]

void GC_namespace::GenericContainer::set ( uint_type const & a)
inline

Assign an integer to the generic container.

Parameters
[in]aInteger to be stored
// Example usage of setting an unsigned integer
GenericContainer container;
container.set(42u); // Store 42 as an unsigned integer in the container

◆ set() [12/12]

void GC_namespace::GenericContainer::set ( ulong_type const & a)
inline

Assign an unsigned integer to the generic container.

Parameters
[in]aUnsigned integer to be stored
// Example usage of setting an unsigned long integer
GenericContainer container;
container.set(100000ul); // Store 100000 as an unsigned long integer in the container

◆ set_bool()

bool_type & GC_namespace::GenericContainer::set_bool ( bool_type value)

Set the data type to bool_type and assign a boolean value.

This method initializes the GenericContainer to hold a boolean value, stores the provided value, and returns a reference to the stored boolean.

Parameters
valueThe boolean value to store.
Returns
A reference to the stored boolean value.

Example:

gc.set_bool(true); // Store a boolean value
bool_type & set_bool(bool_type value)
Set the data type to bool_type and assign a boolean value.
Definition GenericContainer.cc:743

◆ set_complex() [1/2]

complex_type & GC_namespace::GenericContainer::set_complex ( complex_type const & value)

Set the data type to complex_type and assign a complex value.

This method initializes the GenericContainer to hold a complex number, stores the provided value, and returns a reference to the stored complex value.

Parameters
valueThe complex number to store.
Returns
A reference to the stored complex value.

Example:

complex<double> c(1.0, 2.0);
gc.set_complex(c); // Store a complex number
complex_type & set_complex(complex_type const &value)
Set the data type to complex_type and assign a complex value.
Definition GenericContainer.cc:771

◆ set_complex() [2/2]

complex_type & GC_namespace::GenericContainer::set_complex ( real_type r,
real_type i )

Set the data type to complex_type and assign a complex value from real and imaginary parts.

This method initializes the GenericContainer to hold a complex number. It takes two real numbers (representing the real and imaginary components), stores the complex number, and returns a reference to the stored complex value.

Parameters
rThe real part of the complex number.
iThe imaginary part of the complex number.
Returns
A reference to the stored complex value.

Example:

gc.set_complex(1.0, 2.0); // Store a complex number (1.0 + 2.0i)

◆ set_int()

int_type & GC_namespace::GenericContainer::set_int ( int_type value)

Set the data type to int_type and assign an integer value.

This method initializes the GenericContainer to hold an integer value, stores the provided value, and returns a reference to the stored integer.

Parameters
valueThe integer value to store.
Returns
A reference to the stored integer value.

Example:

gc.set_int(42); // Store an integer value

◆ set_long()

long_type & GC_namespace::GenericContainer::set_long ( long_type value)

Set the data type to long_type and assign a long integer value.

This method initializes the GenericContainer to hold a long integer value, stores the provided value, and returns a reference to the stored long integer.

Parameters
valueThe long integer value to store.
Returns
A reference to the stored long integer value.

Example:

gc.set_long(123456789L); // Store a long integer value
long_type & set_long(long_type value)
Set the data type to long_type and assign a long integer value.
Definition GenericContainer.cc:757

◆ set_map()

map_type & GC_namespace::GenericContainer::set_map ( )

Initializes a generic map.

This function sets the data type to map_type, allocates an empty map, and returns a reference to it.

Returns
A reference to the initialized map.
GenericContainer container;
auto & my_map = container.set_map(); // Initializes a map

◆ set_mat_complex() [1/2]

mat_complex_type & GC_namespace::GenericContainer::set_mat_complex ( mat_complex_type const & m)

Set the data to mat_complex_type by copying from another matrix.

This method initializes the matrix of complex numbers by copying data from the provided matrix m.

Parameters
[in]mThe matrix of complex numbers used for initialization.
Returns
A reference to the internally allocated matrix of complex numbers.

Example:

mat_complex_type m = {{{1.0, 2.0}, {3.0, 4.0}}, {{5.0, 6.0}, {7.0, 8.0}}};
gc.set_mat_complex(m); // Copies data from matrix m
GenericContainer()
Constructs a GenericContainer with an initial empty state.
Definition GenericContainer.hh:720

◆ set_mat_complex() [2/2]

mat_complex_type & GC_namespace::GenericContainer::set_mat_complex ( unsigned nr = 0,
unsigned nc = 0 )

Set the data to mat_complex_type, allocate and initialize.

Allocates memory for a matrix of complex_type numbers. If the specified number of rows nr and columns nc are greater than zero, the matrix will be allocated with size nr x nc.

Parameters
[in]nrThe number of rows in the matrix (default is 0).
[in]ncThe number of columns in the matrix (default is 0).
Returns
A reference to the internally allocated matrix of complex numbers.

Example:

gc.set_mat_complex(3, 4); // Allocates a 3x4 matrix of complex numbers
mat_complex_type & set_mat_complex(unsigned nr=0, unsigned nc=0)
Set the data to mat_complex_type, allocate and initialize.
Definition GenericContainer.cc:909

◆ set_mat_int() [1/2]

mat_int_type & GC_namespace::GenericContainer::set_mat_int ( mat_int_type const & m)

Set the data to mat_int_type by copying from another matrix.

This method initializes the matrix of integers by copying data from the provided matrix m.

Parameters
[in]mThe matrix of integers used for initialization.
Returns
A reference to the internally allocated matrix of integers.

Example:

mat_int_type m{{1, 2}, {3, 4}};
gc.set_mat_int(m); // Copies data from matrix m

◆ set_mat_int() [2/2]

mat_int_type & GC_namespace::GenericContainer::set_mat_int ( unsigned nr = 0,
unsigned nc = 0 )

Set the data to mat_int_type, allocate and initialize.

Allocates memory for a matrix of integers. If the specified number of rows nr and columns nc are greater than zero, the matrix will be allocated with size nr x nc.

Parameters
[in]nrThe number of rows in the matrix (default is 0).
[in]ncThe number of columns in the matrix (default is 0).
Returns
A reference to the internally allocated matrix of integers.

Example:

gc.set_mat_int(3, 4); // Allocates a 3x4 matrix of integers
mat_int_type & set_mat_int(unsigned nr=0, unsigned nc=0)
Set the data to mat_int_type, allocate and initialize.
Definition GenericContainer.cc:870

◆ set_mat_long() [1/2]

mat_long_type & GC_namespace::GenericContainer::set_mat_long ( mat_long_type const & m)

Set the data to mat_long_type by copying from another matrix.

This method initializes the matrix of long integers by copying data from the provided matrix m.

Parameters
[in]mThe matrix of long integers used for initialization.
Returns
A reference to the internally allocated matrix of long integers.

Example:

mat_long_type m = {{100000L, 200000L}, {300000L, 400000L}};
gc.set_mat_long(m); // Copies data from matrix m

◆ set_mat_long() [2/2]

mat_long_type & GC_namespace::GenericContainer::set_mat_long ( unsigned nr = 0,
unsigned nc = 0 )

Set the data to mat_long_type, allocate and initialize.

Allocates memory for a matrix of long integers. If the specified number of rows nr and columns nc are greater than zero, the matrix will be allocated with size nr x nc.

Parameters
[in]nrThe number of rows in the matrix (default is 0).
[in]ncThe number of columns in the matrix (default is 0).
Returns
A reference to the internally allocated matrix of long integers.

Example:

gc.set_mat_long(3, 4); // Allocates a 3x4 matrix of long integers
mat_long_type & set_mat_long(unsigned nr=0, unsigned nc=0)
Set the data to mat_long_type, allocate and initialize.
Definition GenericContainer.cc:883

◆ set_mat_real() [1/2]

mat_real_type & GC_namespace::GenericContainer::set_mat_real ( mat_real_type const & m)

Set the data to mat_real_type by copying from another matrix.

This method initializes the matrix of real_type numbers by copying data from the provided matrix m.

Parameters
[in]mThe matrix of real_type numbers used for initialization.
Returns
A reference to the internally allocated matrix of real_type numbers.

Example:

mat_real_type m = {{1.1, 2.2}, {3.3, 4.4}};
gc.set_mat_real(m); // Copies data from matrix m

◆ set_mat_real() [2/2]

mat_real_type & GC_namespace::GenericContainer::set_mat_real ( unsigned nr = 0,
unsigned nc = 0 )

Set the data to mat_real_type, allocate and initialize.

Allocates memory for a matrix of real_type numbers. If the specified number of rows nr and columns nc are greater than zero, the matrix will be allocated with size nr x nc.

Parameters
[in]nrThe number of rows in the matrix (default is 0).
[in]ncThe number of columns in the matrix (default is 0).
Returns
A reference to the internally allocated matrix of real_type numbers.

Example:

gc.set_mat_real(3, 4); // Allocates a 3x4 matrix of real numbers
mat_real_type & set_mat_real(unsigned nr=0, unsigned nc=0)
Set the data to mat_real_type, allocate and initialize.
Definition GenericContainer.cc:896

◆ set_pointer()

pointer_type & GC_namespace::GenericContainer::set_pointer ( pointer_type value)

Set the data type to pointer_type and assign a value.

This method initializes the GenericContainer to hold a pointer, stores the provided value, and returns a reference to the internal pointer storage.

Parameters
valueThe pointer value to store in the container.
Returns
A reference to the stored pointer value.

Example:

int x = 42;
gc.set_pointer(&x); // Store the pointer to x

◆ set_real()

real_type & GC_namespace::GenericContainer::set_real ( real_type value)

Set the data type to real_type and assign a floating-point value.

This method initializes the GenericContainer to hold a floating-point value, stores the provided value, and returns a reference to the stored real value.

Parameters
valueThe floating-point value to store.
Returns
A reference to the stored floating-point value.

Example:

gc.set_real(3.14); // Store a floating-point value

◆ set_string()

string_type & GC_namespace::GenericContainer::set_string ( string_type const & value)

Set the data type to string_type, allocate memory, and assign a string value.

This method initializes the GenericContainer to hold a string, allocates the necessary memory, stores the provided string value, and returns a reference to the stored string.

Parameters
valueThe string to store.
Returns
A reference to the stored string.

Example:

gc.set_string("Hello, World!"); // Store a string

◆ set_vec_bool() [1/2]

vec_bool_type & GC_namespace::GenericContainer::set_vec_bool ( unsigned sz = 0)

Set the data to vec_bool_type, allocate and initialize.

Allocates memory for a vector of boolean values. If the specified size sz is greater than zero, the vector will be allocated with that size.

Parameters
[in]szThe size of the vector of booleans to allocate (default is 0).
Returns
A reference to the internally allocated vector of booleans.

Example:

gc.set_vec_bool(5); // Allocates a vector of 5 booleans
vec_bool_type & set_vec_bool(unsigned sz=0)
Set the data to vec_bool_type, allocate and initialize.
Definition GenericContainer.cc:806

◆ set_vec_bool() [2/2]

vec_bool_type & GC_namespace::GenericContainer::set_vec_bool ( vec_bool_type const & v)

Set the data to vec_bool_type by copying from another vector.

This method initializes the vector of booleans by copying data from the provided vector v.

Parameters
[in]vThe vector of booleans used for initialization.
Returns
A reference to the internally allocated vector of booleans.

Example:

vec_bool_type v = {true, false, true};
gc.set_vec_bool(v); // Copies data from vector v

◆ set_vec_complex() [1/2]

vec_complex_type & GC_namespace::GenericContainer::set_vec_complex ( unsigned sz = 0)

Set the data to vec_complex_type, allocate and initialize.

Allocates memory for a vector of complex numbers. If the specified size sz is greater than zero, the vector will be allocated with that size.

Parameters
[in]szThe size of the vector of complex numbers to allocate (default is 0).
Returns
A reference to the internally allocated vector of complex numbers.

Example:

gc.set_vec_complex(10); // Allocates a vector of 10 complex numbers
vec_complex_type & set_vec_complex(unsigned sz=0)
Set the data to vec_complex_type, allocate and initialize.
Definition GenericContainer.cc:857

◆ set_vec_complex() [2/2]

vec_complex_type & GC_namespace::GenericContainer::set_vec_complex ( vec_complex_type const & v)

Set the data to vec_complex_type by copying from another vector.

This method initializes the vector of complex numbers by copying data from the provided vector v.

Parameters
[in]vThe vector of complex numbers used for initialization.
Returns
A reference to the internally allocated vector of complex numbers.

Example:

vec_complex_type v{ {1.0, 2.0}, {3.0, 4.0} };
gc.set_vec_complex(v); // Copies data from vector v

◆ set_vec_int() [1/2]

vec_int_type & GC_namespace::GenericContainer::set_vec_int ( unsigned sz = 0)

Set the data to vec_int_type, allocate and initialize.

Allocates memory for a vector of integers. If the specified size sz is greater than zero, the vector will be allocated with that size.

Parameters
[in]szThe size of the vector of integers to allocate (default is 0).
Returns
A reference to the internally allocated vector of integers.

Example:

gc.set_vec_int(10); // Allocates a vector of 10 integers
vec_int_type & set_vec_int(unsigned sz=0)
Set the data to vec_int_type, allocate and initialize.
Definition GenericContainer.cc:818

◆ set_vec_int() [2/2]

vec_int_type & GC_namespace::GenericContainer::set_vec_int ( vec_int_type const & v)

Set the data to vec_int_type by copying from another vector.

This method initializes the vector of integers by copying data from the provided vector v.

Parameters
[in]vThe vector of integers used for initialization.
Returns
A reference to the internally allocated vector of integers.

Example:

vec_int_type v{1, 2, 3};
gc.set_vec_int(v); // Copies data from vector v

◆ set_vec_long() [1/2]

vec_long_type & GC_namespace::GenericContainer::set_vec_long ( unsigned sz = 0)

Set the data to vec_long_type, allocate and initialize.

Allocates memory for a vector of long integers. If the specified size sz is greater than zero, the vector will be allocated with that size.

Parameters
[in]szThe size of the vector of long integers to allocate (default is 0).
Returns
A reference to the internally allocated vector of long integers.

Example:

gc.set_vec_long(10); // Allocates a vector of 10 long integers
vec_long_type & set_vec_long(unsigned sz=0)
Set the data to vec_long_type, allocate and initialize.
Definition GenericContainer.cc:831

◆ set_vec_long() [2/2]

vec_long_type & GC_namespace::GenericContainer::set_vec_long ( vec_long_type const & v)

Set the data to vec_long_type by copying from another vector.

This method initializes the vector of long integers by copying data from the provided vector v.

Parameters
[in]vThe vector of long integers used for initialization.
Returns
A reference to the internally allocated vector of long integers.

Example:

vec_long_type v{100000L, 200000L};
gc.set_vec_long(v); // Copies data from vector v

◆ set_vec_pointer() [1/2]

vec_pointer_type & GC_namespace::GenericContainer::set_vec_pointer ( unsigned sz = 0)

Set the data to vec_pointer_type, allocate and initialize.

This method allocates memory for a vector of pointers. If the specified size sz is greater than zero, the vector will be allocated with that size.

Parameters
[in]szThe size of the vector of pointers to allocate (default is 0).
Returns
A reference to the internally allocated vector of pointers.

Example:

gc.set_vec_pointer(10); // Allocates a vector of 10 pointers
vec_pointer_type & set_vec_pointer(unsigned sz=0)
Set the data to vec_pointer_type, allocate and initialize.
Definition GenericContainer.cc:793

◆ set_vec_pointer() [2/2]

vec_pointer_type & GC_namespace::GenericContainer::set_vec_pointer ( vec_pointer_type const & v)

Set the data to vec_pointer_type by copying from another vector.

This method initializes the vector of pointers by copying data from the provided vector v.

Parameters
[in]vThe vector of pointers used for initialization.
Returns
A reference to the internally allocated vector of pointers.

Example:

vec_pointer_type v = {ptr1, ptr2, ptr3};
gc.set_vec_pointer(v); // Copies data from vector v

◆ set_vec_real() [1/2]

vec_real_type & GC_namespace::GenericContainer::set_vec_real ( unsigned sz = 0)

Set the data to vec_real_type, allocate and initialize.

Allocates memory for a vector of real_type numbers. If the specified size sz is greater than zero, the vector will be allocated with that size.

Parameters
[in]szThe size of the vector of real numbers to allocate (default is 0).
Returns
A reference to the internally allocated vector of real numbers.

Example:

gc.set_vec_real(5); // Allocates a vector of 5 real numbers
vec_real_type & set_vec_real(unsigned sz=0)
Set the data to vec_real_type, allocate and initialize.
Definition GenericContainer.cc:844

◆ set_vec_real() [2/2]

vec_real_type & GC_namespace::GenericContainer::set_vec_real ( vec_real_type const & v)

Set the data to vec_real_type by copying from another vector.

This method initializes the vector of real_type numbers by copying data from the provided vector v.

Parameters
[in]vThe vector of real_type numbers used for initialization.
Returns
A reference to the internally allocated vector of real_type numbers.

Example:

vec_real_type v = {1.5, 2.5, 3.5};
gc.set_vec_real(v); // Copies data from vector v

◆ set_vec_string() [1/2]

vec_string_type & GC_namespace::GenericContainer::set_vec_string ( unsigned sz = 0)

Set the data to vec_string_type, allocate and initialize.

Allocates memory for a vector of strings. If the specified size sz is greater than zero, the vector will be allocated with that size.

Parameters
[in]szThe size of the vector of strings to allocate (default is 0).
Returns
A reference to the internally allocated vector of strings.

Example:

gc.set_vec_string(5); // Allocates a vector of 5 strings
vec_string_type & set_vec_string(unsigned sz=0)
Set the data to vec_string_type, allocate and initialize.
Definition GenericContainer.cc:922

◆ set_vec_string() [2/2]

vec_string_type & GC_namespace::GenericContainer::set_vec_string ( vec_string_type const & v)

Set the data to vec_string_type by copying from another vector.

This method initializes the vector of strings by copying data from the provided vector v.

Parameters
[in]vThe vector of strings used for initialization.
Returns
A reference to the internally allocated vector of strings.

Example:

vec_string_type v{"Hello", "World"};
gc.set_vec_string(v); // Copies data from vector v

◆ set_vector()

vector_type & GC_namespace::GenericContainer::set_vector ( unsigned sz = 0)

Initializes a generic vector.

This function sets the data type to vector_type, allocates an empty vector, and returns a reference to it. If the specified size sz is greater than 0, the vector is allocated with that size.

Parameters
[in]szThe size of the allocated vector (default is 0).
Returns
A reference to the initialized vector.
GenericContainer container;
auto & vec = container.set_vector(5); // Initializes a vector of size 5

◆ to_gc()

void GC_namespace::GenericContainer::to_gc ( GenericContainer & gc) const

Copy the contents of the object into another object

Parameters
[out]gcoutput GenericContainer

◆ to_json() [1/2]

void GC_namespace::GenericContainer::to_json ( ostream_type & stream,
string_type const & prefix = "" ) const

Print the contents of the object in JSON syntax

Parameters
[in]streamoutput stream
[in]prefixstrig to be prepended to any field of the GenericContainer

◆ to_json() [2/2]

string GC_namespace::GenericContainer::to_json ( string_type const & prefix = "") const
inline

◆ to_yaml() [1/2]

void GC_namespace::GenericContainer::to_yaml ( ostream_type & stream,
string_type const & prefix = "" ) const

Print the contents of the object in YAML syntax

Parameters
[in]streamoutput stream
[in]prefixstrig to be prepended to any field of the GenericContainer

◆ to_yaml() [2/2]

string GC_namespace::GenericContainer::to_yaml ( string_type const & prefix = "") const
inline

◆ writeFormattedData()

GenericContainer const & GC_namespace::GenericContainer::writeFormattedData ( ostream_type & stream,
char const delimiter = '\t' ) const

Write GenericContainer as regular formatted data to stream.

GenericContainer must be a map which contains the fields:

  • "headers" this element must be a vec_string_type which contains the strings of the headers of the columns of the data
  • "data" this element must be a vector_type which contais the vectors which are the columns of the data to be saved. Each column can be of type

    1. vec_bool_type
    2. vec_int_type
    3. vec_real_type

    all the vector must have the same size.

Parameters
streamstream to write the output
delimiterdesired delimiter (optional). Default is tab.

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