Ice Sheet System Model  4.18
Code documentation
StringParam.cpp
Go to the documentation of this file.
1 
5 /*header files: */
6 /*{{{*/
7 #ifdef HAVE_CONFIG_H
8  #include <config.h>
9 #else
10 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
11 #endif
12 
13 #include "../classes.h"
14 #include "../../shared/shared.h"
15 /*}}}*/
16 
17 /*StringParam constructors and destructor*/
19  return;
20 }
21 /*}}}*/
22 StringParam::StringParam(int in_enum_type,char* in_value){/*{{{*/
23 
24  enum_type=in_enum_type;
25  value=xNew<char>(strlen(in_value)+1);
26  xMemCpy<char>(value,in_value,(strlen(in_value)+1));
27 
28 }
29 /*}}}*/
31  xDelete<char>(value);
32 }
33 /*}}}*/
34 
35 /*Object virtual functions definitions:*/
37 
38  return new StringParam(this->enum_type,this->value);
39 
40 }
41 /*}}}*/
42 void StringParam::DeepEcho(void){/*{{{*/
43  _printf_(setw(22)<<" StringParam "<<setw(35)<<left<<EnumToStringx(this->enum_type)<<" "<<this->value<<"\n");
44 }
45 /*}}}*/
46 void StringParam::Echo(void){/*{{{*/
47  this->DeepEcho();
48 }
49 /*}}}*/
50 int StringParam::Id(void){ return -1; }/*{{{*/
51 /*}}}*/
52 void StringParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
53 
54  int size = 0;
55 
56  if(marshall_direction==MARSHALLING_FORWARD || marshall_direction == MARSHALLING_SIZE)size=strlen(value)+1;
57 
60  MARSHALLING(size);
61  MARSHALLING_DYNAMIC(value,char,size);
62 
63 }
64 /*}}}*/
65 int StringParam::ObjectEnum(void){/*{{{*/
66 
67  return StringParamEnum;
68 
69 }
70 /*}}}*/
71 
72 /*StringParam virtual functions definitions: */
73 void StringParam::GetParameterValue(char** pstring){/*{{{*/
74 
75  char* outstring=NULL;
76  int stringsize;
77 
78  stringsize=strlen(this->value)+1;
79 
80  outstring=xNew<char>(stringsize);
81  xMemCpy<char>(outstring,this->value,stringsize);
82 
83  *pstring=outstring;
84 
85 }
86 /*}}}*/
87 void StringParam::SetValue(char* string){/*{{{*/
88 
89  int stringsize;
90 
91  /*avoid leak: */
92  xDelete<char>(this->value);
93 
94  /*copy: */
95  stringsize=strlen(string)+1;
96  this->value=xNew<char>(stringsize);
97  xMemCpy<char>(this->value,string,stringsize);
98 
99 }
100 /*}}}*/
StringParam::copy
Param * copy()
Definition: StringParam.cpp:36
Param
Definition: Param.h:21
StringParamEnum
@ StringParamEnum
Definition: EnumDefinitions.h:1292
_printf_
#define _printf_(StreamArgs)
Definition: Print.h:22
MARSHALLING_ENUM
#define MARSHALLING_ENUM(EN)
Definition: Marshalling.h:14
MARSHALLING_SIZE
@ MARSHALLING_SIZE
Definition: Marshalling.h:11
StringParam::ObjectEnum
int ObjectEnum()
Definition: StringParam.cpp:65
StringParam::StringParam
StringParam()
Definition: StringParam.cpp:18
MARSHALLING_DYNAMIC
#define MARSHALLING_DYNAMIC(FIELD, TYPE, SIZE)
Definition: Marshalling.h:61
StringParam::enum_type
int enum_type
Definition: StringParam.h:24
StringParam::Echo
void Echo()
Definition: StringParam.cpp:46
EnumToStringx
const char * EnumToStringx(int enum_in)
Definition: EnumToStringx.cpp:15
StringParam::Marshall
void Marshall(char **pmarshalled_data, int *pmarshalled_data_size, int marshall_direction)
Definition: StringParam.cpp:52
MARSHALLING
#define MARSHALLING(FIELD)
Definition: Marshalling.h:29
StringParam::SetValue
void SetValue(bool boolean)
Definition: StringParam.h:60
StringParam::value
char * value
Definition: StringParam.h:25
StringParam::DeepEcho
void DeepEcho()
Definition: StringParam.cpp:42
StringParam::~StringParam
~StringParam()
Definition: StringParam.cpp:30
MARSHALLING_FORWARD
@ MARSHALLING_FORWARD
Definition: Marshalling.h:9
StringParam::Id
int Id()
Definition: StringParam.cpp:50
StringParam::GetParameterValue
void GetParameterValue(bool *pbool)
Definition: StringParam.h:42