Geant4 11.1.1
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 astream = G4StrUtil::strip_copy(stream);
42
43 // tokenize...
44 std::size_t indx=0;
45 while(1) {
46 std::size_t jc= astream.find(" ", indx);
47 nElement++;
48 if(jc == G4String::npos) break;
49 jc++; // fix a tiny mistake...
50 for(; jc< astream.length(); ) { // skip continuing spaces
51 if(astream[(G4int)jc]==' ') jc++;
52 else break;
53 }
54 indx= jc;
55 }
56
57 // allocate string array
58 stringArray= new G4String[nElement];
59
60 // push...
61 indx=0;
62 for(G4int i=0; i<nElement; ++i){
63 std::size_t jc= astream.find(" ", indx);
64 if(jc != G4String::npos)
65 stringArray[i]= astream.substr(indx, jc-indx);
66 else { // last token
67 jc= astream.length()+1;
68 stringArray[i]= astream.substr(indx, jc-indx);
69 }
70 for(std::size_t j=1; jc+j< astream.length(); ++j ) { // skip continuing spaces
71 if(astream[G4int(jc+j)]==' ') jc++;
72 else break;
73 }
74 indx= jc+1;
75 }
76}
int G4int
Definition: G4Types.hh:85
G4String strip_copy(G4String str, char ch=' ')
Return copy of string with leading and trailing characters removed.

◆ ~G4UIArrayString()

G4UIArrayString::~G4UIArrayString ( )

Definition at line 79 of file G4UIArrayString.cc.

81{
82 delete [] stringArray;
83}

Member Function Documentation

◆ Show()

void G4UIArrayString::Show ( G4int  ncol)

Definition at line 152 of file G4UIArrayString.cc.

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