Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MarshaledG4String.h
Go to the documentation of this file.
1 // This file was generated automatically by marshalgen.
2 
3 #ifndef MarshaledG4String_H
4 #define MarshaledG4String_H
5 
6 
7 #include <G4String.hh>
8 
9 
10 #include <stdio.h>
11 #include <string.h>
12 
13 #include "MarshaledObj.h"
14 
15  class MarshaledG4String;
16 
17  class ShadowedMarshaledG4String : public G4String{
18  friend class MarshaledG4String;
19 };
20 
21  class MarshaledG4String : public MarshaledObj {
22 public:
23  G4String* param;
25 public:
26 
27 
28 // Function implementations
29 
31  msh_isUnmarshalDone = false;
32  this->param = objptr;
34  if (objptr == NULL)
35  return;
36 
37  marshal1();
38 }
39 
40 MarshaledG4String(void *buf, char chIsUnmarshaling = 'u')
41 : MarshaledObj(buf, chIsUnmarshaling) {
42  msh_isUnmarshalDone = false;
43 }
44 
46  //if(msh_isUnmarshalDone && this->param != NULL) {
47  //delete this->param;
48  //}
49 }
50 
52  //We don't want to unmarshal the buffer is empty.
53  if(msh_size <= MSH_HEADER_SIZE) {
54  //This is buggy, we can't always assume that
55  //obj == NULL <==> List is empty.
56  return NULL;
57  } else {
58  {
59  param = new G4String();
60  }
62  this->msh_isUnmarshalDone = true;
63  unmarshal1();
64  return this->param;
65  }
66 }
67 
68 void unmarshalTo(G4String* obj) {
69  //We don't want to unmarshal the buffer is empty.
70  if(msh_size <= MSH_HEADER_SIZE) {
71  //This is buggy, we can't always assume that
72  //obj == NULL <==> List is empty.
73  return;
74  } else {
75  this->param = obj;
77  this->msh_isUnmarshalDone = true;
78  unmarshal1();
79  }
80 }
81 
82 void marshal1() {
83  //declare field_size to be the size of this field
84  int msh_currentSize = 0;
85  if (isUnmarshaling())
86  throw "Tried to marshal in obj marked isUnmarshaling == true";
87 
88  //Copy the sizespec into msh_currentSize here:
89  {
90  int size = param->size()+1;
91  while(size%8) size++;
92  msh_currentSize = size;
93  }
94 
95  //Increase the size of buffer if needed
96  EXTEND_BUFFER(msh_currentSize + sizeof(int) + sizeof(int));
97  // 4 bytes for the total size of field, 4 bytes for the number
98  // of elements in the array (in the case of array marshaling)
99  //Mark the beginning position for this field, will write the total
100  //size of this field here later
102 
103  //Advance cursor of distance = sizeof(int)
104  msh_cursor += sizeof(int);
105 
106  //Now just copy "get" functions here
107  {
108  memcpy(msh_cursor, param->c_str(), param->size());
109  *(msh_cursor+param->size()) = '\0';
110 
111  }
112  //Now advance the cursor
113  msh_cursor += msh_currentSize;
114  //Now set the size of this field
115  int tmp; //use memcpy instead of *(int*)... =... to prevent bus error
116  tmp = (msh_cursor-msh_field_begin) - sizeof(int);
117  memcpy(msh_field_begin, &tmp, sizeof(int));
118 
119  //Now set msh_size
122 }
123 
124 void unmarshal1() {
125  //declare currentSize to be the size of this field
126  int msh_currentSize = 0;
127  //copy the size of the current field into currentSize
128  memcpy(&msh_currentSize, msh_cursor, sizeof(int));
129  msh_cursor += sizeof(int);
130  //Now copy the setspec here
131  {
132  G4String* s = new G4String(msh_cursor);
133  memcpy(param, s, sizeof(G4String));
134 
135  }
136  msh_cursor += msh_currentSize;
137 }
138 
139 };
140 #endif
141 
bool msh_isUnmarshalDone
Definition: MarshaledObj.h:119
ShadowedMarshaledG4String * Shadowed_param
#define MSH_SET_TYPECHOICE(X)
Definition: MarshaledObj.h:21
bool isUnmarshaling()
Definition: MarshaledObj.h:92
size_t msh_size
Definition: MarshaledObj.h:110
const XML_Char * s
Definition: expat.h:262
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
G4String * unmarshal()
void EXTEND_BUFFER(int size)
Definition: MarshaledObj.h:122
char * msh_field_begin
Definition: MarshaledObj.h:107
MarshaledG4String(G4String *objptr)
char * msh_cursor
Definition: MarshaledObj.h:113
#define MSH_HEADER_SIZE
Definition: MarshaledObj.h:15
#define MSH_SET_TOTALSIZE(X)
Definition: MarshaledObj.h:22
char * msh_buffer
Definition: MarshaledObj.h:104
MarshaledG4String(void *buf, char chIsUnmarshaling= 'u')
void unmarshalTo(G4String *obj)