32static const char strESC=
'\033';
46 std::size_t jc= astream.find(
" ", indx);
48 if(jc == G4String::npos)
break;
50 for(; jc< astream.length(); ) {
51 if(astream[(
G4int)jc]==
' ') jc++;
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);
67 jc= astream.length()+1;
68 stringArray[i]= astream.substr(indx, jc-indx);
70 for(std::size_t j=1; jc+j< astream.length(); ++j ) {
71 if(astream[
G4int(jc+j)]==
' ') jc++;
82 delete [] stringArray;
89 if( !(icol>=1 && irow>=1))
91 if(icol>nColumn)
G4cerr <<
"G4UIArrayString: overrange" <<
G4endl;
93 G4int jq= (irow-1)*nColumn + icol;
94 if(jq> nElement)
G4cerr <<
"G4UIArrayString: overrange" <<
G4endl;
97 return &stringArray[jq];
101G4int G4UIArrayString::GetNRow(
int icol)
const
105 if(nElement%nColumn ==0) ni= nElement/nColumn;
106 else ni= nElement/nColumn + 1;
109 if(nn==0)
nn= nColumn;
111 if(icol<= nn)
return ni;
116G4int G4UIArrayString::GetNField(
int icol)
const
119 std::size_t maxWidth=0;
120 for (
G4int iy=1; iy<= GetNRow(icol); iy++) {
121 std::size_t ilen= GetElement(icol,iy)->length();
125 const char tgt = (*GetElement(icol,iy))[(std::size_t)0];
129 if(ilen> maxWidth) maxWidth= ilen;
132 return (
G4int)maxWidth;
136int G4UIArrayString::CalculateColumnWidth() const
141 for(
G4int ix=1; ix<= nColumn; ix++) {
142 totalWidth+= GetNField(ix);
145 const G4int nwSpace= 2;
146 totalWidth+= (nColumn-1)*nwSpace;
156 while( CalculateColumnWidth()< ncol ) {
159 while( CalculateColumnWidth()> ncol && nColumn>1 ) {
163 for(
G4int iy=1; iy<= GetNRow(1); iy++) {
165 if(iy == GetNRow(1)) {
166 nc= nElement%nColumn;
167 if(nc==0) nc= nColumn;
169 for(
G4int ix=1; ix<=nc; ix++) {
170 G4String word= GetElement(ix,iy)-> data();
174 const char tgt = word[(std::size_t)0];
176 colorWord= word.substr(0,5);
179 if(!colorWord.empty())
G4cout << colorWord << std::flush;
181 G4cout << std::setiosflags(std::ios::left) << std::setw(GetNField(ix))
182 << word.c_str() << std::flush;
184 if(ix != nc)
G4cout <<
" " << std::flush;
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
G4UIArrayString(const G4String &stream)
G4String strip_copy(G4String str, char ch=' ')
Return copy of string with leading and trailing characters removed.