Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
ParN02/include/MarshaledG4String.h
이 파일의 문서화 페이지로 가기
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 
Float_t tmp
#define MSH_SET_TOTALSIZE(X)
const XML_Char * s
Definition: expat.h:262
#define MSH_SET_TYPECHOICE(X)
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
MarshaledG4String(void *buf, char chIsUnmarshaling= 'u')
#define MSH_HEADER_SIZE
ShadowedMarshaledG4String * Shadowed_param
void EXTEND_BUFFER(int size)