41 const string & sColName,
56 const string & sColumnSeparator)
67 max<Uint4>(col_it->m_iColWidth, (
Uint4)col_it->m_sColName.length());
108 m_ostrm << setw(col_it->m_iColWidth) << left
109 << col_it->m_sColName;
115 const string & sValue)
134 static const char kErrMsg[] =
"**ERROR**";
135 static const size_t kErrMsgLen =
sizeof(kErrMsg) - 1;
144 const static string kEllipses =
"...";
147 string::const_iterator value_end_it = sValue.end();
148 value_end_it -= kEllipses.length();
150 copy( sValue.begin(), value_end_it,
151 ostream_iterator<char>(
m_ostrm) );
169 "CTablePrinter cannot fit cell data into allotted space. "
172 <<
", Length of oversized data: " << sValue.length()
173 <<
"Oversized data starts with: "
174 << sValue.substr(0, colInfo.
m_iColWidth) <<
"...[snip]...");
CTablePrinter(const SColInfoVec &vecColInfo, ostream &ostrm, const string &sColumnSeparator=" ")
SColInfoVec m_vecColInfo
The info about columns of the table.
const string m_sColumnSeparator
The text that separates columns (both in the header as well as dat).
Uint4 m_iNextCol
The 0-based index of the column that the next AddCell will use.
void FinishTable(void)
If the table is not already finished, this finishes it by writing the closing row (which is usually a...
EDataTooLong
controls how table should behave when a data cell is too long to fit into its column.
@ eDataTooLong_ShowErrorInColumn
The data will be replaced with some sort of error message, or at least question marks if the error me...
@ eDataTooLong_ShowWholeData
This recklessly prints the whole table data, regardless of formatting corruption and regardless of ho...
@ eDataTooLong_TruncateWithEllipses
The data is truncated with ellipses (that is, "...").
@ eDataTooLong_ThrowException
Throws an exception when the data won't fit.
void x_PrintDashes(void)
This writes a row of dashes which starts the table, separates the header from the data,...
void x_PrintColumnNames(void)
This prints the column names, appropriately spaced and separated.
ostream & m_ostrm
The ostream to which the table is written.
EState m_eState
This keeps track of the state of the table writer.
@ eState_PrintingRows
This means the header row HAS been printed, and data rows are being printed.
@ eState_Initial
This means the header row has NOT been printed yet.
EJustify
controls how the data in each column is justified.
void x_AddCellValue(const string &sValue)
This is the underlying logic to add another cell to the table data.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
#define NCBI_USER_THROW_FMT(message)
Throw a "user exception" with message processed as output to ostream.
uint32_t Uint4
4-byte (32-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
This holds the info about all columns for the table.
vector< SColInfo > TColInfoVec
void AddCol(const string &sColName, Uint4 iColWidth=0, EJustify eJustify=eJustify_Left, EDataTooLong eDataTooLong=eDataTooLong_Default)
TColInfoVec m_colInfoVec
The underlying column info vector for which SColInfoVec is a wrapper.
This structure contains info about a given column.
EJustify m_eJustify
Justification of data cells in this column (the name of the column is always left-justified,...
EDataTooLong m_eDataTooLong
How data cells should behave in this column behave when there is too much data to fit in them.
string m_sColName
The name of the column, which is shown in the header.
Uint4 m_iColWidth
How many characters wide the column is.