4 #include <utl/String.h>
5 #include <utl/TabularStream.h>
13 const int leftSize,
const char mid)
16 const int size = GetSize();
17 const int missing = totalSize - size;
21 return GetEntry(0, missing);
23 return GetEntry(missing);
26 const int half = missing/2;
27 return GetEntry(missing - half, half);
31 const size_t pos = fEntry.str().find_first_of(mid);
32 const bool hasChar = (pos != string::npos);
34 const int leftPad = leftSize - pos;
35 const int rightPad = totalSize - (leftPad + size);
36 return GetEntry(leftPad, rightPad);
38 const string& str = fEntry.str();
40 (str.find_first_not_of(
" +-0123456789eE.") != string::npos);
42 return GetEntry(eCenter, totalSize);
44 const size_t posE = str.find_first_of(
"eE");
45 bool hasE = (posE != string::npos);
47 return GetEntry(just, totalSize, leftSize, str.at(posE));
49 const int leftPad = leftSize - size;
50 const int rightPad = totalSize - leftSize;
51 return GetEntry(leftPad, rightPad);
57 return string(
"TableCell::GetEntry ERROR");
66 const int size = GetSize();
67 const size_t pos = fEntry.str().find_first_of(mid);
68 if (pos != string::npos)
69 return make_pair(size, pos);
73 (fEntry.str().find_first_not_of(
" +-0123456789eE.") != string::npos);
75 return make_pair(size, size/2);
77 const size_t posE = fEntry.str().find_first_of(
"eE");
78 bool hasE = (posE != string::npos);
80 return GetSize(fEntry.str().at(posE));
82 return make_pair(size, size);
97 if (entry.size() && entry.at(0) ==
'\r') {
98 const char symbol = entry.at(1);
100 res = string(fWidth + fPrefix.size() + fPostfix.size(), symbol);
102 for (
unsigned int i = 0; i < fPrefix.size(); ++i)
103 res += (fPrefix.at(i) ==
'|') ?
'+' : symbol;
104 res += string(fWidth, symbol);
105 for (
unsigned int i = 0; i < fPostfix.size(); ++i)
106 res += (fPostfix.at(i) ==
'|') ?
'+' : symbol;
111 fCells.back().GetEntry(fJustification, fWidth, fLeftWidth, fMidChar) :
112 fCells.back().GetEntry(fJustification, fWidth)) +
124 for (deque<TableCell>::const_iterator cIt = fCells.begin();
125 cIt != fCells.end(); ++cIt) {
126 const int size = cIt->GetSize();
133 for (deque<TableCell>::const_iterator cIt = fCells.begin();
134 cIt != fCells.end(); ++cIt) {
135 const pair<int, int> size = cIt->GetSize(fMidChar);
136 const int right = size.first - size.second;
137 if (right > rightWidth)
139 if (size.second > fLeftWidth)
140 fLeftWidth = size.second;
142 fWidth = fLeftWidth + rightWidth;
150 map<char, TableCell::Justification> justMap;
156 const int n = format.size();
159 for (
int i = 0; i < n; ++i) {
160 const char c = format.at(i);
168 fColumns.back().SetJustification(justMap[c], c);
170 fColumns.back().SetJustification(justMap[c]);
171 fColumns.back().SetMargins(str);
180 fColumns.back().SetMargins(pstr, str);
188 const int nRows = fColumns.front().GetLength();
189 for (
int i = 0; i < nRows; ++i) {
192 for (Columns::iterator cIt = fColumns.begin();
193 cIt != fColumns.end(); ++cIt)
Holds TabularStream cell entry.
std::string GetEntry(const int left=0, const int right=0) const
void MakeFormat(const std::string &format)