Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4UIArrayString Class Reference

#include <G4UIArrayString.hh>

Public Member Functions

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

Detailed Description

Definition at line 40 of file G4UIArrayString.hh.

Constructor & Destructor Documentation

◆ G4UIArrayString()

G4UIArrayString::G4UIArrayString ( const G4String stream)

Definition at line 35 of file G4UIArrayString.cc.

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

◆ ~G4UIArrayString()

G4UIArrayString::~G4UIArrayString ( )

Definition at line 80 of file G4UIArrayString.cc.

82{
83 delete [] stringArray;
84}

Member Function Documentation

◆ Show()

void G4UIArrayString::Show ( G4int  ncol)

Definition at line 154 of file G4UIArrayString.cc.

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

Referenced by G4VUIshell::ListCommand().


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