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

Classes

class  GenericContainer
 The GenericContainer class provides a flexible container for storing heterogeneous data types. More...
 
class  LuaInterpreter
 A class implementing a simple Lua interpreter. More...
 
class  mat_type
 Generic matrix storage type. More...
 

Typedefs

using ostream_type = std::basic_ostream<char>
 Alias for a character-based output stream.
 
using istream_type = std::basic_istream<char>
 Alias for a character-based input stream.
 
using mat_int_type = mat_type<int_type>
 
using mat_long_type = mat_type<long_type>
 
using mat_real_type = mat_type<real_type>
 
using mat_complex_type = mat_type<complex_type>
 
using TypeAllowed
 Enum class representing types allowed for the GenericContainer.
 

Functions

char const * to_string (GC_type s)
 Converts the GC_type enum value to a string representation.
 
string to_string (complex_type const &v)
 
template<typename TYPE >
ostream_typeoperator<< (ostream_type &s, vector< TYPE > const &v)
 Overload of the operator<< for printing a vector of elements of a generic type.
 
template<typename TYPE >
ostream_typeoperator<< (ostream_type &s, mat_type< TYPE > const &mat)
 Overload of the operator<< for printing a matrix of elements of a generic type.
 
void writeTable (vec_string_type const &headers, vector_type const &data, ostream_type &stream, char delimiter='\t')
 
void writeTable (vec_string_type const &headers, mat_real_type const &data, ostream_type &stream, char delimiter='\t')
 
void writeTableFormatted (vec_string_type const &headers, vector_type const &data, ostream_type &stream)
 
void writeTableFormatted (vec_string_type const &headers, mat_real_type const &data, ostream_type &stream)
 
bool file_JSON_to_GC (string const &file_name_JSON, GenericContainer &gc)
 
bool JSON_to_GC (istream_type &file_JSON, GenericContainer &gc)
 
bool JSON_to_GC (string const &JSON, GenericContainer &gc)
 
bool JSON_to_GC (vector< string > const &JSON, GenericContainer &gc)
 
void GC_to_JSON (GenericContainer const &gc, vector< string > &JSON)
 
void GC_to_JSON (GenericContainer const &gc, ostream_type &file_JSON)
 
void Lua_global_to_GC (void *void_L, char const *global_var, GenericContainer &gc)
 Convert a Lua global variable to a GenericContainer.
 
void Lua_GC_to_global (void *void_L, GenericContainer const &gc, char const *global_var)
 Convert a GenericContainer to a Lua global variable.
 
void mxArray_to_GenericContainer (mxArray const *mx, GenericContainer &gc)
 
void mxSparse_to_GenericContainer (mxArray const *mx, GenericContainer &gc)
 
void GenericContainer_to_mxArray (GenericContainer const &gc, mxArray *&mx)
 
void mexPrint (GenericContainer const &gc)
 
void to_mxArray (bool const &val, mxArray *&mx)
 
void to_mxArray (int_type const &val, mxArray *&mx)
 
void to_mxArray (long_type const &val, mxArray *&mx)
 
void to_mxArray (real_type const &val, mxArray *&mx)
 
void to_mxArray (complex_type const &val, mxArray *&mx)
 
void to_mxArray (string_type const &val, mxArray *&mx)
 
void to_mxArray (vec_bool_type const &val, mxArray *&mx)
 
void to_mxArray (vec_int_type const &val, mxArray *&mx)
 
void to_mxArray (vec_long_type const &val, mxArray *&mx)
 
void to_mxArray (vec_real_type const &val, mxArray *&mx)
 
void to_mxArray (vec_complex_type const &val, mxArray *&mx)
 
void to_mxArray (vec_string_type const &val, mxArray *&mx)
 
void to_mxArray (mat_int_type const &val, mxArray *&mx)
 
void to_mxArray (mat_long_type const &val, mxArray *&mx)
 
void to_mxArray (mat_real_type const &val, mxArray *&mx)
 
void to_mxArray (mat_complex_type const &val, mxArray *&mx)
 
bool file_YAML_to_GC (string const &file_name_YAML, GenericContainer &gc)
 
bool YAML_to_GC (istream_type &file_YAML, GenericContainer &gc)
 
bool YAML_to_GC (string const &YAML, GenericContainer &gc)
 
bool YAML_to_GC (vector< string > const &YAML, GenericContainer &gc)
 
void GC_to_YAML (GenericContainer const &gc, vector< string > &YAML)
 
void GC_to_YAML (GenericContainer const &gc, ostream_type &file_YAML)
 

Detailed Description

Namespace for the Generic Container

Typedef Documentation

◆ istream_type

using GC_namespace::istream_type = std::basic_istream<char>

Alias for a character-based input stream.

This alias represents a basic_istream specialized for char types, which is typically used for standard input operations like cin or file input streams.

◆ mat_complex_type

◆ mat_int_type

◆ mat_long_type

◆ mat_real_type

◆ ostream_type

using GC_namespace::ostream_type = std::basic_ostream<char>

Alias for a character-based output stream.

This alias represents a basic_ostream specialized for char types, which is typically used for standard output operations like cout or file output streams.

◆ TypeAllowed

Initial value:
enum class GC_type : int_type {
NOTYPE,
POINTER,
BOOL,
INTEGER,
LONG,
REAL,
COMPLEX,
STRING,
VEC_POINTER,
VEC_BOOL,
VEC_INTEGER,
VEC_LONG,
VEC_REAL,
VEC_COMPLEX,
VEC_STRING,
MAT_INTEGER,
MAT_LONG,
MAT_REAL,
MAT_COMPLEX,
VECTOR,
MAP
}

Enum class representing types allowed for the GenericContainer.

This enum class defines the types that are allowed to be used in the GenericContainer. The types are categorized as simple types, vector types, matrix types, and complex types.

Example

TypeAllowed type = TypeAllowed::INTEGER; // Defines an integer type for GenericContainer
enum class GC_type :int_type { NOTYPE, POINTER, BOOL, INTEGER, LONG, REAL, COMPLEX, STRING, VEC_POINTER, VEC_BOOL, VEC_INTEGER, VEC_LONG, VEC_REAL, VEC_COMPLEX, VEC_STRING, MAT_INTEGER, MAT_LONG, MAT_REAL, MAT_COMPLEX, VECTOR, MAP } TypeAllowed
Enum class representing types allowed for the GenericContainer.
Definition GenericContainer.hh:475

Function Documentation

◆ GenericContainer_to_mxArray()

void GC_namespace::GenericContainer_to_mxArray ( GenericContainer const & gc,
mxArray *& mx )

Convert GenericContainer to an mxArray

◆ mexPrint()

void GC_namespace::mexPrint ( GenericContainer const & gc)

Print the contents of GenericContainer to teh MATLAB console

◆ mxArray_to_GenericContainer()

void GC_namespace::mxArray_to_GenericContainer ( mxArray const * mx,
GenericContainer & gc )

Convert an mxArray to a GenericContainer

◆ mxSparse_to_GenericContainer()

void GC_namespace::mxSparse_to_GenericContainer ( mxArray const * mx,
GenericContainer & gc )

Convert an mxArray containing a sparse matrix to a GenericContainer. The GenericContainer will constain a map with the sparse matrix in compressed column format (https://en.wikipedia.org/wiki/Sparse_matrix)

  • "jc" pointer to the columns
  • "ir" index of the rows
  • "values" vector of real numbers with nonzeros of the matrix

◆ operator<<() [1/2]

template<typename TYPE >
ostream_type & GC_namespace::operator<< ( ostream_type & s,
mat_type< TYPE > const & mat )

Overload of the operator<< for printing a matrix of elements of a generic type.

This function allows the printing of a mat_type object, which represents a matrix containing elements of type TYPE. The matrix is typically printed in a row-by-row format.

Template Parameters
TYPEThe type of the elements contained in the matrix.
Parameters
sThe output stream to write to (e.g., cout or a ostringstream).
matThe mat_type object to print, representing the matrix.
Returns
The modified output stream after writing the matrix elements.

◆ operator<<() [2/2]

template<typename TYPE >
ostream_type & GC_namespace::operator<< ( ostream_type & s,
vector< TYPE > const & v )

Overload of the operator<< for printing a vector of elements of a generic type.

This function allows the printing of a vector containing elements of type TYPE. The elements are typically printed in a comma-separated format inside square brackets.

Template Parameters
TYPEThe type of the elements contained in the vector.
Parameters
sThe output stream to write to (e.g., cout or a ostringstream).
vThe vector object to print.
Returns
The modified output stream after writing the vector elements.

◆ to_mxArray() [1/16]

void GC_namespace::to_mxArray ( bool const & val,
mxArray *& mx )

Convert a boolean to a mxArray

◆ to_mxArray() [2/16]

void GC_namespace::to_mxArray ( complex_type const & val,
mxArray *& mx )

Convert a complex number to a mxArray

◆ to_mxArray() [3/16]

void GC_namespace::to_mxArray ( int_type const & val,
mxArray *& mx )

Convert an integer to a mxArray

◆ to_mxArray() [4/16]

void GC_namespace::to_mxArray ( long_type const & val,
mxArray *& mx )

Convert a long integer to a mxArray

◆ to_mxArray() [5/16]

void GC_namespace::to_mxArray ( mat_complex_type const & val,
mxArray *& mx )

Convert a matrix of complex number to a mxArray

◆ to_mxArray() [6/16]

void GC_namespace::to_mxArray ( mat_int_type const & val,
mxArray *& mx )

Convert a matrix of integer to a mxArray

◆ to_mxArray() [7/16]

void GC_namespace::to_mxArray ( mat_long_type const & val,
mxArray *& mx )

Convert a matrix of long integer to a mxArray

◆ to_mxArray() [8/16]

void GC_namespace::to_mxArray ( mat_real_type const & val,
mxArray *& mx )

Convert a matrix of real number to a mxArray

◆ to_mxArray() [9/16]

void GC_namespace::to_mxArray ( real_type const & val,
mxArray *& mx )

Convert a real number to a mxArray

◆ to_mxArray() [10/16]

void GC_namespace::to_mxArray ( string_type const & val,
mxArray *& mx )

Convert a string integer to a mxArray

◆ to_mxArray() [11/16]

void GC_namespace::to_mxArray ( vec_bool_type const & val,
mxArray *& mx )

Convert a vector of boolean to a mxArray

◆ to_mxArray() [12/16]

void GC_namespace::to_mxArray ( vec_complex_type const & val,
mxArray *& mx )

Convert a vector of complex number to a mxArray

◆ to_mxArray() [13/16]

void GC_namespace::to_mxArray ( vec_int_type const & val,
mxArray *& mx )

Convert a vector of integer to a mxArray

◆ to_mxArray() [14/16]

void GC_namespace::to_mxArray ( vec_long_type const & val,
mxArray *& mx )

Convert a vector of long integer to a mxArray

◆ to_mxArray() [15/16]

void GC_namespace::to_mxArray ( vec_real_type const & val,
mxArray *& mx )

Convert a vector of real number to a mxArray

◆ to_mxArray() [16/16]

void GC_namespace::to_mxArray ( vec_string_type const & val,
mxArray *& mx )

Convert a vector of string to a mxArray. The data will be a cell array.

◆ to_string() [1/2]

string GC_namespace::to_string ( complex_type const & v)

◆ to_string() [2/2]

char const * GC_namespace::to_string ( GC_type s)

Converts the GC_type enum value to a string representation.

This function takes a GC_type enum value and returns a corresponding string representation for easier debugging and logging.

Parameters
sThe GC_type enum value to convert.
Returns
A constant C-string representing the type.

Example

GC_type type = GC_type::INTEGER;
const char* typeStr = to_string(type); // Returns "INTEGER"
cout << "Type: " << typeStr << endl; // Output: Type: INTEGER
char const * to_string(GC_type s)
Converts the GC_type enum value to a string representation.
Definition GenericContainer.cc:269

◆ writeTable() [1/2]

void GC_namespace::writeTable ( vec_string_type const & headers,
mat_real_type const & data,
ostream_type & stream,
char delimiter = '\t' )

Write data as a table

Parameters
[in]headersvector of string with the header of the table
[in]datamatrix of real_type with the columns of the table
[in]streamoutput stream
[in]delimiterdelimiter character between columns

◆ writeTable() [2/2]

void GC_namespace::writeTable ( vec_string_type const & headers,
vector_type const & data,
ostream_type & stream,
char delimiter = '\t' )

Write data as a table

Parameters
[in]headersvector of string with the header of the table
[in]datavector of GenericContainer with the columns of the table
[in]streamoutput stream
[in]delimiterdelimiter character between columns

◆ writeTableFormatted() [1/2]

void GC_namespace::writeTableFormatted ( vec_string_type const & headers,
mat_real_type const & data,
ostream_type & stream )

Write data as a table

Parameters
[in]headersvector of string with the header of the table
[in]datamatrix of real_type with the columns of the table
[in]streamoutput stream

◆ writeTableFormatted() [2/2]

void GC_namespace::writeTableFormatted ( vec_string_type const & headers,
vector_type const & data,
ostream_type & stream )

Write data as a table

Parameters
[in]headersvector of string with the header of the table
[in]datamatrix of real_type with the columns of the table
[in]streamoutput stream