#include <G4UIArrayString.hh>
Public Member Functions | |
G4UIArrayString (const G4String &stream) | |
~G4UIArrayString () | |
void | Show (G4int ncol) |
Definition at line 41 of file G4UIArrayString.hh.
G4UIArrayString::G4UIArrayString | ( | const G4String & | stream | ) |
Definition at line 36 of file G4UIArrayString.cc.
References G4String::both, G4String::index(), and G4String::strip().
00038 { 00039 nElement=0; 00040 nColumn=5; // temporal assignment 00041 00042 G4String tmpstr= stream; // G4String::strip() CONST !! 00043 G4String astream= tmpstr.strip(G4String::both); 00044 00045 // tokenize... 00046 G4int indx=0; 00047 while(1) { 00048 G4int jc= astream.index(" ", indx); 00049 nElement++; 00050 if(jc == G4int(G4String::npos)) break; 00051 jc++; // fix a tiny mistake... 00052 for(; jc< G4int(astream.length()); ) { // skip continuing spaces 00053 if(astream[(size_t)(jc)]==' ') jc++; 00054 else break; 00055 } 00056 indx= jc; 00057 } 00058 00059 // allocate string array 00060 stringArray= new G4String[nElement]; 00061 00062 // push... 00063 indx=0; 00064 for(G4int i=0; i<nElement; i++){ 00065 G4int jc= astream.index(" ", indx); 00066 if(jc != G4int(G4String::npos)) 00067 stringArray[i]= astream(indx, jc-indx); 00068 else { // last token 00069 jc= astream.length()+1; 00070 stringArray[i]= astream(indx, jc-indx); 00071 } 00072 for(G4int j=1; jc+j< G4int(astream.length()); j++ ) { // skip continuing spaces 00073 if(astream(jc+j)==' ') jc++; 00074 else break; 00075 } 00076 indx= jc+1; 00077 } 00078 }
G4UIArrayString::~G4UIArrayString | ( | ) |
void G4UIArrayString::Show | ( | G4int | ncol | ) |
Definition at line 155 of file G4UIArrayString.cc.
References G4cout.
Referenced by G4VUIshell::ListCommand().
00157 { 00158 // calculate #colums in need... 00159 while( CalculateColumnWidth()< ncol ) { 00160 nColumn++; 00161 } 00162 while( CalculateColumnWidth()> ncol && nColumn>1 ) { 00163 nColumn--; 00164 } 00165 00166 for(G4int iy=1; iy<= GetNRow(1); iy++) { 00167 G4int nc= nColumn; 00168 if(iy == GetNRow(1)) { // last row 00169 nc= nElement%nColumn; 00170 if(nc==0) nc= nColumn; 00171 } 00172 for(G4int ix=1; ix<=nc; ix++) { 00173 G4String word= GetElement(ix,iy)-> data(); 00174 00175 // care for color code 00176 G4String colorWord; 00177 //if(word.index(strESC,0) != G4String::npos) { 00178 //if(strESC == word[0]) { 00179 const char tgt = word[(size_t)0]; 00180 if(strESC == tgt) { 00181 colorWord= word(0,5); 00182 word.erase(0,5); 00183 } 00184 if(!colorWord.empty()) G4cout << colorWord << std::flush; 00185 00186 G4cout << std::setiosflags(std::ios::left) << std::setw(GetNField(ix)) 00187 << word.c_str() << std::flush; 00188 // against problem w/ g++ iostream 00189 if(ix != nc) G4cout << " " << std::flush; 00190 else G4cout << G4endl; 00191 } 00192 } 00193 }