Geant4-11
Macros | Functions
G4InteractorMessenger.cc File Reference
#include <string.h>
#include <stdlib.h>
#include "G4UIdirectory.hh"
#include "G4UIcommand.hh"
#include "G4VInteractiveSession.hh"
#include "G4InteractorMessenger.hh"

Go to the source code of this file.

Macros

#define STRDEL(str)   {if((str)!=NULL) {free(str);str=NULL;}}
 
#define STRDUP(str)   ((str) != NULL ? (strcpy((char*)malloc((unsigned)strlen(str) + 1), str)) : (char*)NULL)
 

Functions

static G4bool GetValues (G4String, int, G4String *)
 

Macro Definition Documentation

◆ STRDEL

#define STRDEL (   str)    {if((str)!=NULL) {free(str);str=NULL;}}

Definition at line 38 of file G4InteractorMessenger.cc.

◆ STRDUP

#define STRDUP (   str)    ((str) != NULL ? (strcpy((char*)malloc((unsigned)strlen(str) + 1), str)) : (char*)NULL)

Definition at line 37 of file G4InteractorMessenger.cc.

Function Documentation

◆ GetValues()

G4bool GetValues ( G4String  newValue,
int  paramn,
G4String params 
)
static

Definition at line 205 of file G4InteractorMessenger.cc.

210{
211 char* value = STRDUP(newValue.data());
212 if(value==NULL) return false;
213 char* tok = strtok(value," ");
214 for( int i=0; i<paramn;i++ ) {
215 if(tok==NULL) {
216 STRDEL(value);
217 return false;
218 }
219 G4String token = tok;
220 if( token[0]=='"' ) {
221 while( token.back() != '"' ) {
222 tok = strtok(NULL," ");
223 if( (tok==NULL) || (*tok=='\0')) {
224 STRDEL(value);
225 return false;
226 }
227 token += " ";
228 token += tok;
229 }
230 G4StrUtil::strip(token, '"');
231 }
232 if( token.empty() ) {
233 STRDEL(value);
234 return false;
235 } else {
236 params[i] = token;
237 }
238 tok = strtok(NULL," ");
239 }
240 STRDEL(value);
241 return true;
242}
#define STRDUP(str)
#define STRDEL(str)
void strip(G4String &str, char c=' ')
Remove leading and trailing characters from string.

References STRDEL, STRDUP, and G4StrUtil::strip().

Referenced by G4InteractorMessenger::SetNewValue().