ARB
aw_scalar.cxx
Go to the documentation of this file.
1 // ============================================================ //
2 // //
3 // File : aw_scalar.cxx //
4 // Purpose : Scalar variables (similar to perl scalars) //
5 // //
6 // Coded by Ralf Westram (coder@reallysoft.de) in June 2011 //
7 // Institute of Microbiology (Technical University Munich) //
8 // http://www.arb-home.de/ //
9 // //
10 // ============================================================ //
11 
12 #include "aw_scalar.hxx"
13 #include "aw_awar.hxx"
14 #include <arb_msg.h>
15 
16 const char * const AW_scalar::type_name[SCALAR_TYPES] = { "int", "float", "string", "pointer" };
17 const AW_VARIABLE_TYPE AW_scalar::vtype[SCALAR_TYPES] = { AW_INT, AW_FLOAT, AW_STRING, AW_POINTER };
18 
20  switch (awar->get_type()) {
21  case AW_INT: type = INT; value.i = awar->read_int(); break;
22  case AW_FLOAT: type = FLOAT; value.f = awar->read_float(); break;
23  case AW_STRING: type = STR; value.s = awar->read_string(); break;
24  case AW_POINTER: type = PNTR; value.p = awar->read_pointer(); break;
25  default : GBK_terminatef("AWAR type %i unhandled", awar->get_type()); break;
26  }
27 }
28 
29 GB_ERROR AW_scalar::write_to(class AW_awar *awar) const {
31  switch (awar->get_type()) {
32  case AW_INT: error = awar->write_int(get_int()); break;
33  case AW_FLOAT: error = awar->write_float(get_float()); break;
34  case AW_STRING: error = awar->write_string(get_string()); break;
35  case AW_POINTER: error = awar->write_pointer(get_pointer()); break;
36  default : GBK_terminatef("AWAR type %i unhandled", awar->get_type()); break;
37  }
38  return error;
39 }
40 
GBDATA * get_pointer() const
Definition: aw_scalar.hxx:73
GBDATA * read_pointer() const
Definition: AW_awar.cxx:194
GB_ERROR write_pointer(GBDATA *aw_pointer)
long read_int() const
Definition: AW_awar.cxx:187
GB_ERROR write_to(class AW_awar *awar) const
Definition: aw_scalar.cxx:29
void GBK_terminatef(const char *templat,...)
Definition: arb_msg.cxx:477
AW_VARIABLE_TYPE get_type() const
Definition: AW_awar.cxx:265
const char * get_string() const
Definition: aw_scalar.hxx:72
AW_VARIABLE_TYPE
Definition: aw_base.hxx:53
static void error(const char *msg)
Definition: mkptypes.cxx:96
char * read_string() const
Definition: AW_awar.cxx:201
float read_float() const
Definition: AW_awar.cxx:180
AW_scalar(int32_t I)
Definition: aw_scalar.hxx:54
float get_float() const
Definition: aw_scalar.hxx:71
#define NULp
Definition: cxxforward.h:97
GB_ERROR write_string(const char *aw_string)
GB_ERROR write_float(float aw_float)
GB_ERROR write_int(long aw_int)
int32_t get_int() const
Definition: aw_scalar.hxx:70