33static const char strESC =
'\033';
42 G4String astream = G4StrUtil::strip_copy(stream);
47 std::size_t jc = astream.find(
' ', indx);
49 if (jc == G4String::npos)
break;
51 for (; jc < astream.length();) {
52 if (astream[(
G4int)jc] ==
' ')
61 stringArray =
new G4String[nElement];
65 for (std::size_t i = 0; i < nElement; ++i) {
66 std::size_t jc = astream.find(
' ', indx);
67 if (jc != G4String::npos)
68 stringArray[i] = astream.substr(indx, jc - indx);
70 jc = astream.length() + 1;
71 stringArray[i] = astream.substr(indx, jc - indx);
73 for (std::size_t j = 1; jc + j < astream.length(); ++j) {
74 if (astream[
G4int(jc + j)] ==
' ')
94 if (icol < 1 || irow < 1)
98 std::size_t jq = (irow - 1) * nColumn + icol;
99 if (jq > nElement)
G4cerr <<
"G4UIArrayString: overrange" <<
G4endl;
102 return &stringArray[jq];
106G4int G4UIArrayString::GetNRow(
G4int icol)
const
110 if (nElement % nColumn == 0)
111 ni =
G4int(nElement / nColumn);
113 ni =
G4int(nElement / nColumn) + 1;
116 if (nn == 0)
nn = (
G4int)nColumn;
118 if (icol <= nn)
return ni;
123G4int G4UIArrayString::GetNField(
G4int icol)
const
126 std::size_t maxWidth = 0;
127 for (
G4int iy = 1; iy <= GetNRow(icol); ++iy) {
128 std::size_t ilen = GetElement(icol, iy)->length();
132 const char tgt = (*GetElement(icol, iy))[(std::size_t)0];
136 if (ilen > maxWidth) maxWidth = ilen;
139 return (
G4int)maxWidth;
143G4int G4UIArrayString::CalculateColumnWidth() const
146 G4int totalWidth = 0;
148 for (
G4int ix = 1; ix <= (
G4int)nColumn; ++ix) {
149 totalWidth += GetNField(ix);
152 const G4int nwSpace = 2;
153 totalWidth += (nColumn - 1) * nwSpace;
163 while (CalculateColumnWidth() < ncol) {
166 while (CalculateColumnWidth() > ncol && nColumn > 1) {
170 for (
G4int iy = 1; iy <= GetNRow(1); iy++) {
172 if (iy == GetNRow(1)) {
173 nc =
G4int(nElement % nColumn);
174 if (nc == 0) nc = (
G4int)nColumn;
176 for (
G4int ix = 1; ix <= nc; ++ix) {
177 G4String word = GetElement(ix, iy)->data();
181 const char tgt = word[(std::size_t)0];
183 colorWord = word.substr(0, 5);
186 if (! colorWord.empty())
G4cout << colorWord << std::flush;
188 G4cout << std::setiosflags(std::ios::left) << std::setw(GetNField(ix)) << word.c_str()
192 G4cout <<
" " << std::flush;
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
G4UIArrayString(const G4String &stream)