Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4UIArrayString Class Reference

#include <G4UIArrayString.hh>

Public Member Functions

 G4UIArrayString (const G4String &stream)
 
 ~G4UIArrayString ()
 
void Show (G4int ncol)
 

Detailed Description

Definition at line 41 of file G4UIArrayString.hh.

Constructor & Destructor Documentation

G4UIArrayString::G4UIArrayString ( const G4String stream)

Definition at line 36 of file G4UIArrayString.cc.

38 {
39  nElement=0;
40  nColumn=5; // temporal assignment
41 
42  G4String tmpstr= stream; // G4String::strip() CONST !!
43  G4String astream= tmpstr.strip(G4String::both);
44 
45  // tokenize...
46  G4int indx=0;
47  while(1) {
48  G4int jc= astream.index(" ", indx);
49  nElement++;
50  if(jc == G4int(G4String::npos)) break;
51  jc++; // fix a tiny mistake...
52  for(; jc< G4int(astream.length()); ) { // skip continuing spaces
53  if(astream[(size_t)(jc)]==' ') jc++;
54  else break;
55  }
56  indx= jc;
57  }
58 
59  // allocate string array
60  stringArray= new G4String[nElement];
61 
62  // push...
63  indx=0;
64  for(G4int i=0; i<nElement; i++){
65  G4int jc= astream.index(" ", indx);
66  if(jc != G4int(G4String::npos))
67  stringArray[i]= astream(indx, jc-indx);
68  else { // last token
69  jc= astream.length()+1;
70  stringArray[i]= astream(indx, jc-indx);
71  }
72  for(G4int j=1; jc+j< G4int(astream.length()); j++ ) { // skip continuing spaces
73  if(astream(jc+j)==' ') jc++;
74  else break;
75  }
76  indx= jc+1;
77  }
78 }
G4String strip(G4int strip_Type=trailing, char c=' ')
int G4int
Definition: G4Types.hh:78
str_size index(const char *, G4int pos=0) const

Here is the call graph for this function:

G4UIArrayString::~G4UIArrayString ( )

Definition at line 81 of file G4UIArrayString.cc.

83 {
84  delete [] stringArray;
85 }

Member Function Documentation

void G4UIArrayString::Show ( G4int  ncol)

Definition at line 155 of file G4UIArrayString.cc.

157 {
158  // calculate #colums in need...
159  while( CalculateColumnWidth()< ncol ) {
160  nColumn++;
161  }
162  while( CalculateColumnWidth()> ncol && nColumn>1 ) {
163  nColumn--;
164  }
165 
166  for(G4int iy=1; iy<= GetNRow(1); iy++) {
167  G4int nc= nColumn;
168  if(iy == GetNRow(1)) { // last row
169  nc= nElement%nColumn;
170  if(nc==0) nc= nColumn;
171  }
172  for(G4int ix=1; ix<=nc; ix++) {
173  G4String word= GetElement(ix,iy)-> data();
174 
175  // care for color code
176  G4String colorWord;
177  //if(word.index(strESC,0) != G4String::npos) {
178  //if(strESC == word[0]) {
179  const char tgt = word[(size_t)0];
180  if(strESC == tgt) {
181  colorWord= word(0,5);
182  word.erase(0,5);
183  }
184  if(!colorWord.empty()) G4cout << colorWord << std::flush;
185 
186  G4cout << std::setiosflags(std::ios::left) << std::setw(GetNField(ix))
187  << word.c_str() << std::flush;
188  // against problem w/ g++ iostream
189  if(ix != nc) G4cout << " " << std::flush;
190  else G4cout << G4endl;
191  }
192  }
193 }
static const char strESC
int G4int
Definition: G4Types.hh:78
const XML_Char const XML_Char * data
Definition: expat.h:268
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61

Here is the caller graph for this function:


The documentation for this class was generated from the following files: