26#ifndef GENERIC_CONTAINER_HH
27#define GENERIC_CONTAINER_HH
30#pragma clang diagnostic push
31#pragma clang diagnostic ignored "-Wpadded"
32#pragma clang diagnostic ignored "-Wc++98-compat"
33#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
34#pragma clang diagnostic ignored "-Wpoison-system-directories"
50#ifndef DOXYGEN_SHOULD_SKIP_THIS
53 #define GC_DO_ERROR(MSG) { \
55 ost << "in GenericContainer: " << MSG << '\n'; \
56 GenericContainer::exception( ost.str().data() ); \
61 #define GC_ASSERT(COND,MSG) if ( !(COND) ) GC_DO_ERROR(MSG)
65 #define GC_WARNING(COND,MSG) \
67 cout << "On line: " << __LINE__ \
68 << " file: " << __FILE__ \
69 << " in GenericContainer\nWARNING: " << MSG << '\n'; \
74 #define GC_NO_RETURN __attribute__ ((noreturn))
90 using std::string_view;
95 using std::istringstream;
96 using std::ostringstream;
97 using std::runtime_error;
120 #ifndef DOXYGEN_SHOULD_SKIP_THIS
122 #if defined(GENERIC_CONTAINER_ON_WINDOWS) && defined(GENERIC_CONTAINER_USE_WINDOWS_TYPES)
133 typedef void* pointer_type;
135 using string = string;
136 using bool_type = bool;
137 using int_type = int32_t;
138 using long_type = int64_t;
139 using uint_type = uint32_t;
140 using ulong_type = uint64_t;
141 using real_type = double;
142 using complex_type = complex<real_type>;
143 using string_type = string;
144 using vec_pointer_type = vector<pointer_type>;
145 using vec_bool_type = vector<bool_type>;
146 using vec_int_type = vector<int_type>;
147 using vec_long_type = vector<long_type>;
148 using vec_real_type = vector<real_type>;
149 using vec_complex_type = vector<complex_type>;
150 using vec_string_type = vector<string_type>;
151 using vector_type = vector<GenericContainer>;
152 using map_type = map<string_type,GenericContainer>;
153 using vec_uint_type = vector<uint_type>;
154 using vec_ulong_type = vector<ulong_type>;
168 template <
typename TYPE>
170 unsigned m_num_rows{0};
171 unsigned m_num_cols{0};
172 typedef typename vector<TYPE>::size_type size_type;
192 { vector<TYPE>::resize(size_type(nr*nc)); }
207 resize(
unsigned const nr,
unsigned const nc ) {
210 vector<TYPE>::resize(size_type(nr*nc));
213 template <
typename T1,
typename T2>
216 static_assert(std::is_integral_v<T1>,
"resize() accepts only integral types!");
217 static_assert(std::is_integral_v<T1>,
"resize() accepts only integral types!");
218 resize(
static_cast<unsigned>(nr),
static_cast<unsigned>(nc) );
236 template <
typename T>
239 static_assert(std::is_integral_v<T>,
"get_column() accepts only integral types as first argument!");
263 void get_row(
unsigned nr, vector<TYPE> & R )
const;
265 template <
typename T>
267 get_row( T
const nr, vector<TYPE> & R )
const {
268 static_assert(std::is_integral_v<T>,
"get_row() accepts only integral types as first argument!");
269 get_row(
static_cast<unsigned>(nr), R );
276 getRow(
unsigned nr, vector<TYPE> & R )
const
294 template <
typename T>
297 static_assert(std::is_integral_v<T>,
"get_column() accepts only integral types as first argument!");
323 template <
typename T>
326 static_assert(std::is_integral_v<T>,
"get_row() accepts only integral types as first argument!");
327 get_row(
static_cast<unsigned>(nr), R );
348 [[nodiscard]]
unsigned num_rows()
const {
return m_num_rows; }
353 [[nodiscard]]
unsigned numRows()
const {
return m_num_rows; }
366 [[nodiscard]]
unsigned num_cols()
const {
return m_num_cols; }
371 [[nodiscard]]
unsigned numCols()
const {
return m_num_cols; }
445 TYPE *
data() {
return &vector<TYPE>::front(); }
458 TYPE
const *
data()
const {
return &vector<TYPE>::front(); }
462 #ifndef GENERIC_CONTAINER_ON_WINDOWS
463 extern template class mat_type<int_type>;
464 extern template class mat_type<long_type>;
465 extern template class mat_type<real_type>;
466 extern template class mat_type<complex_type>;
487 template <
typename TYPE>
501 template <
typename TYPE>
650 using DataStorage =
union {
680 void allocate_string();
683 void allocate_complex();
686 void allocate_vec_pointer(
unsigned sz);
689 void allocate_vec_bool(
unsigned sz);
692 void allocate_vec_int(
unsigned sz);
695 void allocate_vec_long(
unsigned sz);
698 void allocate_vec_real(
unsigned sz);
701 void allocate_vec_complex(
unsigned sz);
704 void allocate_mat_int(
unsigned nr,
unsigned nc);
707 void allocate_mat_long(
unsigned nr,
unsigned nc);
710 void allocate_mat_real(
unsigned nr,
unsigned nc);
713 void allocate_mat_complex(
unsigned nr,
unsigned nc);
716 void allocate_vec_string(
unsigned sz);
719 void allocate_vector(
unsigned sz);
734 #ifdef GENERIC_CONTAINER_ON_WINDOWS
735 bool simple_data()
const;
737 [[nodiscard]]
bool simple_data()
const {
return m_data_type <= GC_type::STRING; }
741 #ifdef GENERIC_CONTAINER_ON_WINDOWS
742 bool simple_vec_data()
const;
744 [[nodiscard]]
bool simple_vec_data()
const {
return m_data_type < GC_type::VEC_STRING; }
817 void erase( string_view name )
const;
842 pointer_type & set_pointer( pointer_type value );
880 void get_keys( vec_string_type & keys )
const;
900 string get_keys()
const;
917 bool_type & set_bool( bool_type value );
934 int_type & set_int( int_type value );
951 long_type & set_long( long_type value );
968 real_type & set_real( real_type value );
986 complex_type & set_complex( complex_type
const & value );
1005 complex_type & set_complex( real_type re, real_type im );
1022 string_type & set_string( string_view value );
1051 vec_pointer_type & set_vec_pointer(
unsigned sz = 0 );
1053 template <
typename T>
1056 static_assert(std::is_integral_v<T>,
"set_vec_pointers() accepts only integral types!");
1074 vec_pointer_type & set_vec_pointer( vec_pointer_type
const & v );
1090 vec_bool_type & set_vec_bool(
unsigned sz = 0 );
1092 template <
typename T>
1095 static_assert(std::is_integral_v<T>,
"set_vec_bool() accepts only integral types!");
1113 vec_bool_type & set_vec_bool( vec_bool_type
const & v );
1129 vec_int_type & set_vec_int(
unsigned sz = 0 );
1131 template <
typename T>
1134 static_assert(std::is_integral_v<T>,
"set_vec_ints() accepts only integral types!");
1152 vec_int_type & set_vec_int( vec_int_type
const & v );
1168 vec_long_type & set_vec_long(
unsigned sz = 0 );
1170 template <
typename T>
1173 static_assert(std::is_integral_v<T>,
"set_vec_long() accepts only integral types!");
1191 vec_long_type & set_vec_long( vec_long_type
const & v );
1207 vec_real_type & set_vec_real(
unsigned sz = 0 );
1209 template <
typename T>
1212 static_assert(std::is_integral_v<T>,
"set_vec_real() accepts only integral types!");
1230 vec_real_type & set_vec_real( vec_real_type
const & v );
1246 vec_complex_type & set_vec_complex(
unsigned sz = 0 );
1248 template <
typename T>
1251 static_assert(std::is_integral_v<T>,
"set_vec_complex() accepts only integral types!");
1269 vec_complex_type & set_vec_complex( vec_complex_type
const & v );
1285 vec_string_type & set_vec_string(
unsigned sz = 0 );
1287 template <
typename T>
1290 static_assert(std::is_integral_v<T>,
"set_vec_string() accepts only integral types!");
1308 vec_string_type & set_vec_string( vec_string_type
const & v );
1325 mat_int_type & set_mat_int(
unsigned nr = 0,
unsigned nc = 0 );
1358 mat_long_type & set_mat_long(
unsigned nr = 0,
unsigned nc = 0 );
1391 mat_real_type & set_mat_real(
unsigned nr = 0,
unsigned nc = 0 );
1448 void push_bool(
bool b )
const;
1456 void push_int( int_type i );
1464 void push_long( long_type l );
1472 void push_real( real_type r );
1480 void push_complex( complex_type & c );
1489 void push_complex( real_type re, real_type im );
1497 void push_string( string_view s );
1523 vector_type & set_vector(
unsigned sz = 0 );
1535 map_type & set_map();
1628 unsigned get_num_elements()
const;
1635 unsigned num_rows()
const;
1646 unsigned num_cols()
const;
1658 real_type get_number( string_view
const where =
"" )
const;
1666 complex_type get_complex_number( string_view
const where =
"" )
const;
1677 void get_complex_number( real_type & re, real_type & im )
const;
1685 void * get_pvoid( string_view
const where =
"" )
const;
1693 void ** get_ppvoid( string_view
const where =
"" )
const;
1698 int_type
const * get_int_pointer()
const;
1705 int_type * get_int_pointer();
1712 long_type
const * get_long_pointer()
const;
1719 long_type * get_long_pointer();
1726 real_type
const * get_real_pointer()
const;
1733 real_type * get_real_pointer();
1740 complex_type
const * get_complex_pointer()
const;
1747 complex_type * get_complex_pointer();
1758 template <
typename T>
1767 #ifdef GENERIC_CONTAINER_ON_WINDOWS
1768 template <
typename T>
1770 { ck(
"get_pointer",GC_type::POINTER);
return *
reinterpret_cast<T*
>(
get_ppvoid()); }
1775 template <
typename T>
1776 T get_pointer()
const
1777 { ck(
"get_pointer",GC_type::POINTER);
return reinterpret_cast<T
>(get_pvoid()); }
1779 template <
typename T>
1781 { ck(
"get_pointer", GC_type::POINTER);
return *
static_cast<T*
>(m_data.p); }
1788 template <
typename T>
1790 { ck(
"get_pointer",GC_type::POINTER);
return reinterpret_cast<T
>(m_data.p); }
1802 bool_type get_map_bool( string_view
const key, string_view
const where =
"" )
const;
1810 bool_type get_map_bool( std::initializer_list<string> args )
const;
1821 bool_type get_map_bool( vec_string_type
const & keys, string_view
const where =
"" )
const;
1832 int_type get_map_int( string_view
const key, string_view
const where =
"" )
const;
1840 int_type get_map_int( std::initializer_list<string> args )
const;
1852 int_type get_map_int( vec_string_type
const & keys, string_view
const where =
"" )
const;
1863 real_type get_map_number( string_view
const key, string_view
const where =
"" )
const;
1871 real_type get_map_number( std::initializer_list<string> args )
const;
1883 real_type get_map_number( vec_string_type
const & keys, string_view
const where =
"" )
const;
1894 string const & get_map_string( string_view
const key, string_view
const where =
"" )
const;
1902 string const & get_map_string( std::initializer_list<string> args )
const;
1914 string const & get_map_string( vec_string_type
const & keys, string_view
const where =
"" )
const;
1925 vec_real_type
const & get_map_vec_real( string_view
const key, string_view
const where =
"" )
const;
1933 vec_real_type
const & get_map_vec_real( std::initializer_list<string> args )
const;
1945 vec_real_type
const & get_map_vec_real( vec_string_type
const & keys, string_view
const where =
"" )
const;
1956 vec_complex_type
const & get_map_vec_complex( string_view
const key, string_view
const where =
"" )
const;
1964 vec_complex_type
const & get_map_vec_complex( std::initializer_list<string> args )
const;
1976 vec_complex_type
const & get_map_vec_complex( vec_string_type
const & keys, string_view
const where =
"" )
const;
1987 vec_string_type
const & get_map_vec_string( string_view
const key, string_view
const where =
"" )
const;
1995 vec_string_type
const & get_map_vec_string( std::initializer_list<string> args )
const;
2007 vec_string_type
const & get_map_vec_string( vec_string_type
const & keys, string_view
const where =
"" )
const;
2017 bool_type & get_bool( string_view
const where =
"" );
2027 bool_type
const & get_bool( string_view
const where =
"" )
const;
2037 int_type & get_int( string_view
const where =
"" );
2047 int_type
const & get_int( string_view
const where =
"" )
const;
2057 long_type & get_long( string_view
const where =
"" );
2067 long_type
const & get_long( string_view
const where =
"" )
const;
2077 int_type get_as_int( string_view
const where =
"" )
const;
2087 uint_type get_as_uint( string_view
const where =
"" )
const;
2097 long_type get_as_long( string_view
const where =
"" )
const;
2107 ulong_type get_as_ulong( string_view
const where =
"" )
const;
2117 real_type & get_real( string_view
const where =
"" );
2127 real_type
const & get_real( string_view
const where =
"" )
const;
2137 complex_type & get_complex( string_view
const where =
"" );
2147 complex_type
const & get_complex( string_view
const where =
"" )
const;
2157 string_type & get_string( string_view
const where =
"" );
2167 string_type
const & get_string( string_view
const where =
"" )
const;
2196 vector_type & get_vector( string_view
const where =
"" );
2210 vector_type
const & get_vector( string_view
const where =
"" )
const;
2224 vec_pointer_type & get_vec_pointer( string_view
const where =
"" );
2238 vec_pointer_type
const & get_vec_pointer( string_view
const where =
"" )
const;
2252 vec_bool_type & get_vec_bool( string_view
const where =
"" );
2266 vec_bool_type
const & get_vec_bool( string_view
const where =
"" )
const;
2280 vec_int_type & get_vec_int( string_view =
"" );
2294 vec_int_type
const & get_vec_int( string_view =
"" )
const;
2308 vec_long_type & get_vec_long( string_view =
"" );
2322 vec_long_type
const & get_vec_long( string_view =
"" )
const;
2336 vec_real_type & get_vec_real( string_view =
"" );
2350 vec_real_type
const & get_vec_real( string_view =
"" )
const;
2364 vec_complex_type & get_vec_complex( string_view =
"" );
2378 vec_complex_type
const & get_vec_complex( string_view =
"" )
const;
2406 mat_int_type const & get_mat_int( string_view =
"" )
const;
2434 mat_long_type const & get_mat_long( string_view =
"" )
const;
2462 mat_real_type const & get_mat_real( string_view =
"" )
const;
2504 vec_string_type & get_vec_string( string_view =
"" );
2518 vec_string_type
const & get_vec_string( string_view =
"" )
const;
2546 void copyto_vec_int( vec_int_type & v, string_view =
"" )
const;
2561 void copyto_vec_uint( vec_uint_type & v, string_view =
"" )
const;
2576 void copyto_vec_long( vec_long_type & v, string_view =
"" )
const;
2591 void copyto_vec_ulong( vec_ulong_type & v, string_view =
"" )
const;
2606 void copyto_vec_real( vec_real_type & v, string_view =
"" )
const;
2621 void copyto_vec_complex( vec_complex_type & v, string_view =
"" )
const;
2636 void copyto_vec_string( vec_string_type & v, string_view =
"" )
const;
2661 void copyto_mat_int(
mat_int_type & m, string_view =
"" )
const;
2676 void copyto_mat_long(
mat_long_type & m, string_view =
"" )
const;
2691 void copyto_mat_real(
mat_real_type & m, string_view =
"" )
const;
2735 real_type get_number_at(
unsigned i, string_view =
"" )
const;
2751 complex_type get_complex_number_at(
unsigned i, string_view =
"" )
const;
2769 void get_complex_number_at(
unsigned i, real_type & re, real_type & im, string_view =
"" )
const;
2783 template <
typename T>
2785 {
return (*
this)[i].get_pointer<T>(); }
2799 template <
typename T>
2801 {
return (*
this)[i].get_pointer<T>(); }
2816 bool_type get_bool_at(
unsigned i );
2818 template <
typename T>
2821 static_assert(std::is_integral_v<T>,
"get_bool_at() accepts only integral types!");
2838 bool_type get_bool_at(
unsigned i, string_view
const where )
const;
2852 int_type & get_int_at(
unsigned i );
2854 template <
typename T>
2857 static_assert(std::is_integral_v<T>,
"get_int_at() accepts only integral types!");
2874 int_type
const & get_int_at(
unsigned i, string_view
const where )
const;
2888 long_type & get_long_at(
unsigned i );
2890 template <
typename T>
2893 static_assert(std::is_integral_v<T>,
"get_long_at() accepts only integral types!");
2910 long_type
const & get_long_at(
unsigned i, string_view
const where )
const;
2924 real_type & get_real_at(
unsigned i );
2926 template <
typename T>
2928 static_assert(std::is_integral_v<T>,
"get_real_at() accepts only integral types!");
2945 real_type
const & get_real_at(
unsigned i, string_view
const where )
const;
2959 complex_type & get_complex_at(
unsigned i );
2961 template <
typename T>
2963 static_assert(std::is_integral_v<T>,
"get_complex_at() accepts only integral types!");
2980 complex_type
const & get_complex_at(
unsigned i, string_view
const where )
const;
2995 int_type & get_int_at(
unsigned i,
unsigned j );
3011 int_type
const & get_int_at(
unsigned i,
unsigned j, string_view
const where )
const;
3026 long_type & get_long_at(
unsigned i,
unsigned j );
3042 long_type
const & get_long_at(
unsigned i,
unsigned j, string_view
const where )
const;
3057 real_type & get_real_at(
unsigned i,
unsigned j );
3073 real_type
const & get_real_at(
unsigned i,
unsigned j, string_view
const where )
const;
3088 complex_type & get_complex_at(
unsigned i,
unsigned j );
3104 complex_type
const & get_complex_at(
unsigned i,
unsigned j, string_view
const where )
const;
3118 string_type & get_string_at(
unsigned i );
3120 template <
typename T>
3123 static_assert(std::is_integral_v<T>,
"get_string_at() accepts only integral types!");
3140 string_type
const & get_string_at(
unsigned i, string_view
const where )
const;
3156 template <
typename T>
3158 static_assert(std::is_integral_v<T>,
"get_gc_at() accepts only integral types!");
3159 return get_gc_at(
static_cast<unsigned>(i));
3175 GenericContainer const & get_gc_at(
unsigned i, string_view
const where )
const;
3209 map_type & get_map( string_view =
"" );
3229 map_type
const & get_map( string_view =
"" )
const;
3332 GenericContainer const & operator () (
unsigned i, string_view =
"" )
const;
3362 GenericContainer const & operator () ( string_view s, string_view =
"" )
const;
3378 GenericContainer & operator () ( vec_string_type
const & vs, string_view =
"" );
3394 GenericContainer const & operator () ( vec_string_type
const & vs, string_view =
"" )
const;
3514 void set( complex<float>
const & a )
3529 void set( complex<double>
const & a )
3593 { this->
set_bool(a);
return *
this; }
3609 { this->
set_int(a);
return *
this; }
3625 { this->
set_long(a);
return *
this; }
3866 : m_data_type(GC_type::NOTYPE) { this->
operator=(a); }
3873 : m_data_type(GC_type::NOTYPE) { *
this = a; }
3880 : m_data_type(GC_type::NOTYPE) { this->
operator=(a); }
3887 : m_data_type(GC_type::NOTYPE) { *
this = a; }
3894 : m_data_type(GC_type::NOTYPE) { this->
operator=(a); }
3901 : m_data_type(GC_type::NOTYPE) { this->
operator=(a); }
3908 : m_data_type(GC_type::NOTYPE) { this->
operator=(a); }
3915 : m_data_type(GC_type::NOTYPE) { this->
operator=(a); }
3922 : m_data_type(GC_type::NOTYPE) { this->
operator=(a); }
3929 : m_data_type(GC_type::NOTYPE) { this->
operator=(a); }
3936 : m_data_type(GC_type::NOTYPE) { this->
operator=(a); }
3943 : m_data_type(GC_type::NOTYPE) { this->
operator=(a); }
3950 : m_data_type(GC_type::NOTYPE) { this->
set_pointer(a); }
3957 : m_data_type(GC_type::NOTYPE) { this->
from_gc(gc); }
3970 bool exists( string_view s )
const;
3977 bool exists( vec_string_type
const & vs )
const;
3985 string must_exists( vec_string_type
const & vs, string_view
const where )
const;
3992 bool get_if_exists( string_view field,
bool & value )
const;
4000 bool get_if_exists( vec_string_type
const & fields,
bool & value )
const;
4007 bool get_if_exists( string_view field, int_type & value )
const;
4014 bool get_if_exists( string_view field, uint_type & value )
const;
4021 bool get_if_exists( string_view field, long_type & value )
const;
4028 bool get_if_exists( string_view field, ulong_type & value )
const;
4035 bool get_if_exists( string_view field, real_type & value )
const;
4042 bool get_if_exists( string_view field, complex_type & value )
const;
4049 bool get_if_exists( string_view field, string_type & value )
const;
4057 template <
typename T>
4060 for ( string_view field : fields ) {
4071 template <
typename T>
4093 print_content_types(
4095 string_view prefix =
"",
4096 string_view indent =
" "
4107 compare_content(
GenericContainer const & gc, string_view from =
"" )
const;
4119 string_view prefix =
"",
4120 string_view indent =
" "
4133 string_view prefix =
"",
4134 string_view indent =
" "
4136 this->
dump( stream, prefix, indent );
4147 string_view prefix =
"",
4148 string_view indent =
" "
4152 this->
print(ostr,prefix,indent);
4184 bool from_file( string_view file_name );
4196 { ostringstream ss; this->
to_yaml( ss, prefix );
return ss.str(); }
4218 { ostringstream ss; this->
to_json( ss, prefix );
return ss.str();}
4241 { ostringstream ss; this->
to_toml( ss );
return ss.str();}
4311 char const commentChars[] =
"#%",
4312 char const delimiters[] =
" \t"
4321 char const commentChars[] =
"#%",
4322 char const delimiters[] =
" \t"
4346 char const commentChars[] =
"#%",
4347 char const delimiters[] =
" \t"
4356 char const commentChars[] =
"#%",
4357 char const delimiters[] =
" \t"
4383 char const commentChars[] =
"#%",
4384 char const delimiters[] =
" \t",
4394 char const commentChars[] =
"#%",
4395 char const delimiters[] =
" \t",
4421 char const commentChars[] =
"#%",
4422 char const delimiters[] =
" \t",
4432 char const commentChars[] =
"#%",
4433 char const delimiters[] =
" \t",
4449 int32_t mem_size()
const;
4459 int32_t serialize( int32_t buffer_dim, uint8_t * buffer )
const;
4478 int32_t
de_serialize( int32_t buffer_dim, uint8_t
const * buffer );
4498 exception( string_view
const where ) GC_NO_RETURN;
4514 vec_string_type
const & headers,
4515 vector_type
const & data,
4517 char delimiter =
'\t'
4526 vec_string_type
const & headers,
4527 vector_type
const & data,
4529 char delimiter =
'\t'
4544 vec_string_type
const & headers,
4547 char delimiter =
'\t'
4556 vec_string_type
const & headers,
4559 char delimiter =
'\t'
4573 vec_string_type
const & headers,
4574 vector_type
const & data,
4584 vec_string_type
const & headers,
4585 vector_type
const & data,
4600 vec_string_type
const & headers,
4611 vec_string_type
const & headers,
4625#ifndef DOXYGEN_SHOULD_SKIP_THIS
4628 #ifndef XlibSpecificationRelease
4638#pragma clang diagnostic pop
GenericContainer & read_formatted_data2(istream_type &stream, char const commentChars[]="#%", char const delimiters[]=" \t", GenericContainer ptr_pars[]=nullptr)
GenericContainer & read_formatted_data(istream_type &stream, char const commentChars[]="#%", char const delimiters[]=" \t")
GenericContainer const & write_formatted_data(ostream_type &stream, char const delimiter='\t') const
The GenericContainer class provides a flexible container for storing heterogeneous data types.
Definition GenericContainer.hh:614
GC_namespace::vec_real_type vec_real_type
Alias for vector of real numbers type.
Definition GenericContainer.hh:632
bool from_toml(string const &data)
Definition GenericContainer.hh:4251
GC_namespace::vec_ulong_type vec_ulong_type
Alias for vector of unsigned long integers type.
Definition GenericContainer.hh:631
bool to_toml(ostream_type &stream) const
real_type & set_real(real_type value)
Set the data type to real_type and assign a floating-point value.
Definition GenericContainer.cc:963
GenericContainer(complex< double > const &a)
Definition GenericContainer.hh:3921
real_type & get_real_at(unsigned i)
Definition GenericContainer.cc:3048
bool get_if_exists(vec_string_type const &fields, T &value) const
Definition GenericContainer.hh:4059
GenericContainer(double const &a)
Definition GenericContainer.hh:3907
GC_namespace::vec_long_type vec_long_type
Alias for vector of long integers type.
Definition GenericContainer.hh:630
static void exception(string_view const where) GC_NO_RETURN
Definition GenericContainer.cc:3908
GC_namespace::uint_type uint_type
Alias for unsigned integer type.
Definition GenericContainer.hh:620
GenericContainer()
Constructs a GenericContainer with an initial empty state.
Definition GenericContainer.hh:761
GC_namespace::map_type map_type
Alias for map of GenericContainer type.
Definition GenericContainer.hh:636
T get_pointer_at(unsigned i) const
Return i-th generic pointer (if fails issue an error).
Definition GenericContainer.hh:2800
bool_type get_bool_at(unsigned i)
Definition GenericContainer.cc:2925
bool_type get_bool_at(T i)
Definition GenericContainer.hh:2820
GC_namespace::vec_bool_type vec_bool_type
Alias for vector of booleans type.
Definition GenericContainer.hh:627
GC_namespace::mat_real_type mat_real_type
Alias for matrix of real numbers type.
Definition GenericContainer.hh:639
void from_gc(GenericContainer const &gc)
Definition GenericContainer.cc:3780
void set(uint_type const &a)
Definition GenericContainer.hh:3435
GC_namespace::bool_type bool_type
Alias for boolean type.
Definition GenericContainer.hh:618
vec_pointer_type & set_vec_pointer(unsigned sz=0)
Set the data to vec_pointer_type, allocate and initialize.
Definition GenericContainer.cc:992
GC_namespace::vector_type vector_type
Alias for vector of GenericContainer type.
Definition GenericContainer.hh:635
GenericContainer const & info(ostream_type &stream) const
Print information about the kind of data stored to a stream.
Definition GenericContainer.cc:3187
GenericContainer & readFormattedData2(istream_type &stream, char const commentChars[]="#%", char const delimiters[]=" \t", GenericContainer ptr_pars[]=nullptr)
Definition GenericContainer.hh:4392
GC_namespace::complex_type complex_type
Alias for complex number type.
Definition GenericContainer.hh:624
bool from_json(istream_type &stream)
GenericContainer(bool const &a)
Definition GenericContainer.hh:3865
int32_t de_serialize(vector< uint8_t > const &buffer)
GC_namespace::ulong_type ulong_type
Alias for unsigned long integer type.
Definition GenericContainer.hh:622
void to_yaml(ostream_type &stream, string_view prefix="") const
GenericContainer(complex< float > const &a)
Definition GenericContainer.hh:3914
vec_bool_type & set_vec_bool(unsigned sz=0)
Set the data to vec_bool_type, allocate and initialize.
Definition GenericContainer.cc:1005
long_type & get_long_at(unsigned i)
Definition GenericContainer.cc:2996
string to_json(string_view prefix="") const
Definition GenericContainer.hh:4217
GenericContainer(pointer_type a)
Definition GenericContainer.hh:3949
void set(double const &a)
Definition GenericContainer.hh:3500
vec_string_type & set_vec_string(T sz)
Definition GenericContainer.hh:1289
GenericContainer & readFormattedData(char const fname[], char const commentChars[]="#%", char const delimiters[]=" \t")
Definition GenericContainer.hh:4354
vec_long_type & set_vec_long(T sz)
Definition GenericContainer.hh:1172
void set(bool const &a)
Definition GenericContainer.hh:3422
void set(complex< double > const &a)
Definition GenericContainer.hh:3529
bool from_json(string const &data)
Definition GenericContainer.hh:4229
void get_value(T &v, string_view const where="") const
Get the stored value.
GenericContainer(long_type const &a)
Definition GenericContainer.hh:3893
int32_t serialize(vector< uint8_t > &buffer) const
vec_complex_type & set_vec_complex(unsigned sz=0)
Set the data to vec_complex_type, allocate and initialize.
Definition GenericContainer.cc:1056
GenericContainer(float const &a)
Definition GenericContainer.hh:3900
vec_long_type & set_vec_long(unsigned sz=0)
Set the data to vec_long_type, allocate and initialize.
Definition GenericContainer.cc:1030
GenericContainer & readFormattedData2(char const fname[], char const commentChars[]="#%", char const delimiters[]=" \t", GenericContainer ptr_pars[]=nullptr)
Definition GenericContainer.hh:4430
void set(string_view a)
Definition GenericContainer.hh:3556
GenericContainer & get_gc_at(T i)
Definition GenericContainer.hh:3157
long_type & set_long(long_type value)
Set the data type to long_type and assign a long integer value.
Definition GenericContainer.cc:956
vec_complex_type & set_vec_complex(T sz)
Definition GenericContainer.hh:1250
GC_namespace::real_type real_type
Alias for real (floating point) type.
Definition GenericContainer.hh:623
string_type & set_string(string_view value)
Set the data type to string_type, allocate memory, and assign a string value.
Definition GenericContainer.cc:986
GenericContainer(GenericContainer const &gc)
Definition GenericContainer.hh:3956
string_type info() const
Print information about the kind of data stored as a string.
Definition GenericContainer.hh:1613
complex_type & get_complex_at(unsigned i)
Definition GenericContainer.cc:3099
string to_toml() const
Definition GenericContainer.hh:4240
vec_int_type & set_vec_int(unsigned sz=0)
Set the data to vec_int_type, allocate and initialize.
Definition GenericContainer.cc:1017
void set(ulong_type const &a)
Definition GenericContainer.hh:3461
int_type & set_int(int_type value)
Set the data type to int_type and assign an integer value.
Definition GenericContainer.cc:949
GenericContainer & get_gc_at(unsigned i)
Definition GenericContainer.cc:3170
T & get_pointer_at(unsigned i)
Definition GenericContainer.hh:2784
~GenericContainer()
Destroys the GenericContainer and releases any allocated resources.
Definition GenericContainer.hh:779
void to_json(ostream_type &stream, string_view prefix="") const
complex_type & get_complex_at(T i)
Definition GenericContainer.hh:2962
GenericContainer(int_type const &a)
Definition GenericContainer.hh:3879
GenericContainer(uint_type const &a)
Definition GenericContainer.hh:3872
unsigned num_rows() const
Return the number of rows in the internally stored matrix.
Definition GenericContainer.cc:674
T get_pointer() const
Get the stored value as a pointer (const version).
Definition GenericContainer.hh:1789
string_type & get_string_at(unsigned i)
Definition GenericContainer.cc:3149
GC_namespace::int_type int_type
Alias for integer type.
Definition GenericContainer.hh:619
GenericContainer(string const &a)
Definition GenericContainer.hh:3935
void dump(ostream_type &stream, string_view prefix="", string_view indent=" ") const
Definition GenericContainer.cc:3429
complex_type & set_complex(complex_type const &value)
Set the data type to complex_type and assign a complex value.
Definition GenericContainer.cc:970
bool_type & set_bool(bool_type value)
Set the data type to bool_type and assign a boolean value.
Definition GenericContainer.cc:942
GC_namespace::mat_long_type mat_long_type
Alias for matrix of long integers type.
Definition GenericContainer.hh:638
string_view get_type_name() const
Return a string representing the type of data stored.
Definition GenericContainer.hh:1591
GC_namespace::vec_uint_type vec_uint_type
Alias for vector of unsigned integers type.
Definition GenericContainer.hh:629
string_type & get_string_at(T i)
Definition GenericContainer.hh:3122
GC_namespace::vec_int_type vec_int_type
Alias for vector of integers type.
Definition GenericContainer.hh:628
GenericContainer & readFormattedData(istream_type &stream, char const commentChars[]="#%", char const delimiters[]=" \t")
Definition GenericContainer.hh:4319
GC_namespace::string_type string_type
Alias for string type.
Definition GenericContainer.hh:625
vec_string_type & set_vec_string(unsigned sz=0)
Set the data to vec_string_type, allocate and initialize.
Definition GenericContainer.cc:1121
GC_namespace::pointer_type pointer_type
Alias for pointer type.
Definition GenericContainer.hh:617
GenericContainer(ulong_type const &a)
Definition GenericContainer.hh:3886
string to_yaml(string_view prefix="") const
Definition GenericContainer.hh:4195
unsigned num_cols() const
Return the number of columns in the internally stored matrix.
Definition GenericContainer.cc:702
void clear()
Clears the content of the GenericContainer, resetting it to an empty state.
Definition GenericContainer.cc:592
vec_real_type & set_vec_real(unsigned sz=0)
Set the data to vec_real_type, allocate and initialize.
Definition GenericContainer.cc:1043
GenericContainer & operator=(bool const &a)
Definition GenericContainer.hh:3592
void print(ostream_type &stream, string_view prefix="", string_view indent=" ") const
Definition GenericContainer.hh:4131
void set(int_type const &a)
Definition GenericContainer.hh:3448
TypeAllowed get_type() const
Return an integer representing the type of data stored.
Definition GenericContainer.hh:1580
T & get_pointer()
Get the stored value as a pointer.
Definition GenericContainer.hh:1780
vec_real_type & set_vec_real(T sz)
Definition GenericContainer.hh:1211
void set(pointer_type a)
Definition GenericContainer.hh:3570
real_type & get_real_at(T i)
Definition GenericContainer.hh:2927
GenericContainer(char const *a)
Definition GenericContainer.hh:3928
void set(long_type const &a)
Definition GenericContainer.hh:3474
GenericContainer(string_view a)
Definition GenericContainer.hh:3942
GC_namespace::vec_pointer_type vec_pointer_type
Alias for vector of pointers type.
Definition GenericContainer.hh:626
bool from_json2(istream_type &stream)
void set(complex< float > const &a)
Definition GenericContainer.hh:3514
GC_namespace::vec_string_type vec_string_type
Alias for vector of strings type.
Definition GenericContainer.hh:634
bool from_yaml(istream_type &stream)
bool get_if_exists(char const field[], T &value) const
Definition GenericContainer.hh:4073
int32_t de_serialize(int32_t buffer_dim, uint8_t const *buffer)
Definition GenericContainerSerialize.cc:380
int_type & get_int_at(T i)
Definition GenericContainer.hh:2856
int_type & get_int_at(unsigned i)
Definition GenericContainer.cc:2947
GC_namespace::long_type long_type
Alias for long integer type.
Definition GenericContainer.hh:621
GenericContainer const & writeFormattedData(ostream_type &stream, char const delimiter='\t') const
Definition GenericContainer.hh:4287
bool from_yaml(string const &data)
Definition GenericContainer.hh:4206
vec_pointer_type & set_vec_pointer(T sz)
Definition GenericContainer.hh:1055
void ** get_ppvoid(string_view const where="") const
Return the stored data as a double pointer.
Definition GenericContainer.cc:1266
GC_namespace::mat_int_type mat_int_type
Alias for matrix of integers type.
Definition GenericContainer.hh:637
bool get_if_exists(string_view field, bool &value) const
Definition GenericContainer.cc:2584
bool from_toml(istream_type &stream)
string_type print(string_view prefix="", string_view indent=" ") const
Definition GenericContainer.hh:4146
unsigned get_numRows() const
Definition GenericContainer.hh:1639
void set(float const &a)
Definition GenericContainer.hh:3487
vec_int_type & set_vec_int(T sz)
Definition GenericContainer.hh:1133
GC_namespace::mat_complex_type mat_complex_type
Alias for matrix of complex numbers type.
Definition GenericContainer.hh:640
void load(GenericContainer const &a)
Definition GenericContainer.hh:3774
long_type & get_long_at(T i)
Definition GenericContainer.hh:2892
vec_bool_type & set_vec_bool(T sz)
Definition GenericContainer.hh:1094
GC_namespace::vec_complex_type vec_complex_type
Alias for vector of complex numbers type.
Definition GenericContainer.hh:633
unsigned get_numCols() const
Definition GenericContainer.hh:1650
void set(char const *a)
Definition GenericContainer.hh:3543
pointer_type & set_pointer(pointer_type value)
Set the data type to pointer_type and assign a value.
Definition GenericContainer.cc:935
Generic matrix storage type.
Definition GenericContainer.hh:169
unsigned numRows() const
Definition GenericContainer.hh:353
void get_column(T const nc, TYPE *C) const
Definition GenericContainer.hh:296
void getColumn(unsigned nc, vector< TYPE > &C) const
Definition GenericContainer.hh:247
void get_column(T const nc, vector< TYPE > &C) const
Definition GenericContainer.hh:238
void resize(unsigned const nr, unsigned const nc)
Definition GenericContainer.hh:207
void getRow(unsigned nr, TYPE *R) const
Definition GenericContainer.hh:334
void get_row(unsigned nr, TYPE *R) const
Definition GenericContainer.cc:201
void info(ostream_type &stream) const
Definition GenericContainer.cc:212
void get_row(T const nr, TYPE *R) const
Definition GenericContainer.hh:325
void get_row(unsigned nr, vector< TYPE > &R) const
unsigned num_cols() const
Definition GenericContainer.hh:366
TYPE * data()
Definition GenericContainer.hh:445
mat_type(unsigned nr, unsigned nc)
Definition GenericContainer.hh:189
void getColumn(unsigned nc, TYPE *C) const
Definition GenericContainer.hh:305
void get_column(unsigned nc, TYPE *C) const
Definition GenericContainer.cc:177
void resize(T1 const nr, T2 const nc)
Definition GenericContainer.hh:215
void get_column(unsigned nc, vector< TYPE > &C) const
void get_row(T const nr, vector< TYPE > &R) const
Definition GenericContainer.hh:267
mat_type()=default
Default constructor that creates an empty matrix.
string_type info() const
Definition GenericContainer.hh:428
unsigned num_rows() const
Definition GenericContainer.hh:348
void getRow(unsigned nr, vector< TYPE > &R) const
Definition GenericContainer.hh:276
unsigned numCols() const
Definition GenericContainer.hh:371
TYPE const * data() const
Definition GenericContainer.hh:458
TYPE const & operator()(unsigned i, unsigned j) const
Definition GenericContainer.cc:140
Definition GenericContainer.cc:68
mat_type< int_type > mat_int_type
Definition GenericContainer.hh:469
mat_type< long_type > mat_long_type
Definition GenericContainer.hh:470
mat_type< real_type > mat_real_type
Definition GenericContainer.hh:471
string_view to_string(GC_type const s)
Converts the GC_type enum value to a string representation.
Definition GenericContainer.cc:285
void string_escape(ostream_type &stream, string const &s)
unsigned stream_number_precision
Definition GenericContainer.cc:73
void writeTable(vec_string_type const &headers, vector_type const &data, ostream_type &stream, char delimiter='\t')
Definition GenericContainer.hh:4525
mat_type< complex_type > mat_complex_type
Definition GenericContainer.hh:472
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:517
std::basic_ostream< char > ostream_type
Alias for a character-based output stream.
Definition GenericContainer.hh:109
void writeTableFormatted(vec_string_type const &headers, vector_type const &data, ostream_type &stream)
Definition GenericContainer.hh:4583
void write_table(vec_string_type const &headers, vector_type const &data, ostream_type &stream, char delimiter='\t')
ostream_type & operator<<(ostream_type &s, vector< TYPE > const &v)
Overload of the operator<< for printing a vector of elements of a generic type.
void write_table_formatted(vec_string_type const &headers, vector_type const &data, ostream_type &stream)
std::basic_istream< char > istream_type
Alias for a character-based input stream.
Definition GenericContainer.hh:118