1.1.0
CCC
 
AStringable.cpp File Reference
#include "geoslib_old_f.h"
#include "Matrix/LinkMatrixSparse.hpp"
#include "Enum/EJustify.hpp"
#include "Basic/AStringable.hpp"
#include "Basic/VectorNumT.hpp"
#include "Basic/String.hpp"
#include "Basic/Utilities.hpp"
#include "Basic/File.hpp"
#include "Basic/OptCst.hpp"
#include <string>
#include <iostream>
#include <sstream>
#include <typeinfo>
#include <iomanip>
#include <stdio.h>
#include <stdarg.h>
#include <math.h>
#include <string.h>

Macros

#define CASE_DOUBLE   0
 
#define CASE_REAL   1
 
#define CASE_INT   2
 
#define CASE_COL   3
 
#define CASE_ROW   4
 
#define TRI(i)   (((i) * ((i) + 1)) / 2)
 
#define TL1(i, j)   (tl[(j)*neq+(i)-TRI(j)]) /* only for i >= j */
 
#define TL2(i, j)   (tl[TRI(i)+(j)]) /* only for i >= j */
 

Functions

std::stringstream _formatColumn (const EJustify &justify, int localSize=0)
 
String _tabPrintString (const String &string, const EJustify &justify, int localSize=0)
 
String _tabPrintDouble (double value, const EJustify &justify, int localSize=0)
 
String _tabPrintInt (int value, const EJustify &justify, int localSize=0)
 
String _tabPrintRowColumn (int icase, int value, int flagAdd)
 
String _printColumnHeader (const VectorString &colnames, int colfrom, int colto, int colSize=_getColumnSize())
 
String _printRowHeader (const VectorString &rownames, int iy, int rowSize=_getColumnSize())
 
String _printTrailer (int ncols, int nrows, int ncols_util, int nrows_util)
 
void message (const char *format,...)
 
void messageNoDiff (const char *format,...)
 
void messageFlush (const String &string)
 
void messerrFlush (const String &string)
 
void messerr (const char *format,...)
 
void mesArg (const char *title, int current, int nmax, bool flagStartOne)
 
void mestitle (int level, const char *format,...)
 
void mes_process (const char *string, int ntot, int iech)
 
String toTitle (int level, const char *format,...)
 
void messageAbort (const char *format,...)
 
String toMatrix (const String &title, const AMatrix &mat, bool flagOverride, bool flagSkipZero)
 
String toMatrix (const String &title, const VectorString &colnames, const VectorString &rownames, bool bycol, int ncols, int nrows, const VectorDouble &tab, bool flagOverride, bool flagSkipZero)
 
String toMatrix (const String &title, const VectorString &colnames, const VectorString &rownames, bool bycol, int ncols, int nrows, const VectorInt &tab, bool flagOverride, bool flagSkipZero)
 
String toVector (const String &title, const VectorDouble &tab, bool flagOverride)
 
String toVector (const String &title, const VectorVectorDouble &tab, bool flagOverride)
 
String toVector (const String &title, const VectorString &tab, bool flagOverride)
 
String toVector (const String &title, const VectorInt &tab, bool flagOverride)
 
String toStr (const String &string, const EJustify &justify, int localSize)
 
String toDouble (double value, const EJustify &justify)
 
VectorString toVectorDouble (const VectorDouble &values, const EJustify &justify)
 
String toInt (int value, const EJustify &justify)
 
String toInterval (double zmin, double zmax)
 
void tab_prints (const char *title, const char *string, int ncol, const EJustify &justify)
 
void tab_printg (const char *title, double value, int ncol, const EJustify &justify)
 
void tab_printd (const char *title, double value, int ncol, const EJustify &justify)
 
void tab_printi (const char *title, int value, int ncol, const EJustify &justify)
 
void tab_print_rc (const char *title, int mode, int value, int ncol, const EJustify &justify)
 
void tab_print_rowname (const char *string, int taille)
 
void print_matrix (const char *title, int flag_limit, int bycol, int nx, int ny, const double *sel, const double *tab)
 
void print_matrix (const char *title, int flag_limit, const AMatrix &mat)
 
void print_trimat (const char *title, int mode, int neq, const double *tl)
 
void print_imatrix (const char *title, int flag_limit, int bycol, int nx, int ny, const double *sel, const int *tab)
 
void print_vector (const char *title, int flag_limit, int ntab, const double *tab)
 
void print_vector (const char *title, int flag_limit, int ntab, const VectorDouble &tab)
 
void print_ivector (const char *title, int flag_limit, int ntab, const int *itab)
 
void print_ivector (const char *title, int flag_limit, int ntab, const VectorInt &itab)
 

Macro Definition Documentation

#define CASE_COL   3
#define CASE_DOUBLE   0
#define CASE_INT   2
#define CASE_REAL   1
#define CASE_ROW   4
#define TL1 (   i,
 
)    (tl[(j)*neq+(i)-TRI(j)]) /* only for i >= j */
#define TL2 (   i,
 
)    (tl[TRI(i)+(j)]) /* only for i >= j */
#define TRI (   i)    (((i) * ((i) + 1)) / 2)

Function Documentation

std::stringstream _formatColumn ( const EJustify &  justify,
int  localSize = 0 
)
String _printColumnHeader ( const VectorString colnames,
int  colfrom,
int  colto,
int  colSize = _getColumnSize() 
)
String _printRowHeader ( const VectorString rownames,
int  iy,
int  rowSize = _getColumnSize() 
)
String _printTrailer ( int  ncols,
int  nrows,
int  ncols_util,
int  nrows_util 
)
String _tabPrintDouble ( double  value,
const EJustify &  justify,
int  localSize = 0 
)
String _tabPrintInt ( int  value,
const EJustify &  justify,
int  localSize = 0 
)
String _tabPrintRowColumn ( int  icase,
int  value,
int  flagAdd 
)
String _tabPrintString ( const String string,
const EJustify &  justify,
int  localSize = 0 
)
void mes_process ( const char *  string,
int  ntot,
int  iech 
)

Conditionally print the progress of a procedure

Parameters
stringString to be printed
ntotTotal number of samples
iechRank of the current sample
Remarks
The value 'nproc' designates the quantile such that,
when changed, the printout is provoked.
void mesArg ( const char *  title,
int  current,
int  nmax,
bool  flagStartOne 
)

Print a standard Error Message if an argument does not lie in Interval

Parameters
titleTitle to be printed
currentCurrent value of the argument
nmaxMaximum (inclusive) possible value
flagStartOneTrue if the count starts at 1 (instead of 0)
void message ( const char *  format,
  ... 
)

Print a formatted message

Parameters
formatOutput format
...Additional arguments
void messageAbort ( const char *  format,
  ... 
)

Function for aborting the API

Parameters
formatFatal error format
...Additional arguments
void messageFlush ( const String string)

When message has been collected as a String, this function produces it out without passing through useless internal buffering

Parameters
stringString to be printed out
void messageNoDiff ( const char *  format,
  ... 
)

Print a formatted message (with "#NO_DIFF#" prefix)

Parameters
formatOutput format
...Additional arguments
void messerr ( const char *  format,
  ... 
)

Print Error message

Parameters
formatOutput format
...Additional arguments
void messerrFlush ( const String string)

When the error message has been collected as a String, this function produces it out without passing through useless internal buffering

Parameters
stringString to be produced
Remarks
This function is similar to messageFlush but dedicated to Errors
void mestitle ( int  level,
const char *  format,
  ... 
)

Print a message and underlines it with various formats

Parameters
levelLevel of the title
formatOutput format
...Additional arguments
void print_imatrix ( const char *  title,
int  flag_limit,
int  bycol,
int  nx,
int  ny,
const double *  sel,
const int *  tab 
)

Tabulated printout of a matrix (integer version)

Parameters
[in]titleTitle (Optional)
[in]flag_limitoption for the limits
  • 1 if limits must be applied
  • 0 if the whole matrix is printed
[in]bycol1 if values in 'tab' are sorted by column, 0 otherwise
[in]nxnumber of columns in the matrix
[in]nynumber of rows in the matrix
[in]selarray of selection or NULL
[in]tabarray containing the matrix
void print_ivector ( const char *  title,
int  flag_limit,
int  ntab,
const int *  itab 
)

Print a vector of integer values in a matrix form

Parameters
[in]titleTitle (Optional)
[in]flag_limit1 if NTCOL is used; 0 otherwise
[in]ntabNumber of elements in the array
[in]itabArray to be printed
void print_ivector ( const char *  title,
int  flag_limit,
int  ntab,
const VectorInt itab 
)
void print_matrix ( const char *  title,
int  flag_limit,
int  bycol,
int  nx,
int  ny,
const double *  sel,
const double *  tab 
)

Tabulated printout of a matrix

Parameters
[in]titleTitle (Optional)
[in]flag_limitoption for the limits
  • 1 if limits must be applied
  • 0 if the whole matrix is printed
[in]bycol1 if values in 'tab' are sorted by column, 0 otherwise
[in]nxnumber of columns in the matrix
[in]nynumber of rows in the matrix
[in]selarray of selection or NULL
[in]tabarray containing the matrix
Remarks
The order of the dimension (nx,ny) is opposite
of the one used in R-packages where dim[1]=nrow and dim[2]=ncol
void print_matrix ( const char *  title,
int  flag_limit,
const AMatrix mat 
)
void print_trimat ( const char *  title,
int  mode,
int  neq,
const double *  tl 
)

Tabulated printout of a upper triangular matrix

Parameters
[in]titleTitle (Optional)
[in]mode1 if the matrix is stored linewise 2 if the matrix is stored columnwise
[in]neqsize of the matrix
[in]tlarray containing the upper triangular matrix
Remarks
The ordering (compatible with matrix_solve is mode==2)
void print_vector ( const char *  title,
int  flag_limit,
int  ntab,
const double *  tab 
)

Print a vector of real values in a matrix form

Parameters
[in]titleTitle (Optional)
[in]flag_limit1 if NTCOL is used; 0 otherwise
[in]ntabNumber of elements in the array
[in]tabArray to be printed
void print_vector ( const char *  title,
int  flag_limit,
int  ntab,
const VectorDouble tab 
)
void tab_print_rc ( const char *  title,
int  mode,
int  value,
int  ncol,
const EJustify &  justify 
)

Tabulated printout of a row or column value

Parameters
[in]titleoptional title (NULL if not defined)
[in]modeCASE_ROW or CASE_COL
[in]valueValue to be written
[in]ncolnumber of columns for the printout
[in]justifyjustification flag (EJustify::LEFT, EJustify::CENTER or EJustify::RIGHT)
void tab_print_rowname ( const char *  string,
int  taille 
)

Tabulated printout of a string (character size provided)

Parameters
[in]stringString to be written
[in]tailleNumber of characters
Remarks
The string is printed (left-adjusted) on 'taille' characters
void tab_printd ( const char *  title,
double  value,
int  ncol,
const EJustify &  justify 
)

Tabulated printout of a double value

Parameters
[in]titleoptional title (NULL if not defined)
[in]valueValue to be written
[in]ncolnumber of columns for the printout
[in]justifyjustification flag (EJustify::LEFT, EJustify::CENTER or EJustify::RIGHT)
void tab_printg ( const char *  title,
double  value,
int  ncol,
const EJustify &  justify 
)

Tabulated printout of a real value

Parameters
[in]titleoptional title (NULL if not defined)
[in]valueValue to be written
[in]ncolnumber of columns for the printout
[in]justifyjustification flag (EJustify::LEFT, EJustify::CENTER or EJustify::RIGHT)
void tab_printi ( const char *  title,
int  value,
int  ncol,
const EJustify &  justify 
)

Tabulated printout of an integer value

Parameters
[in]titleoptional title (NULL if not defined)
[in]valueValue to be written
[in]ncolnumber of columns for the printout
[in]justifyjustification flag (EJustify::LEFT, EJustify::CENTER or EJustify::RIGHT)
void tab_prints ( const char *  title,
const char *  string,
int  ncol,
const EJustify &  justify 
)

Tabulated printout of a string

Parameters
[in]titleoptional title (NULL if not defined)
[in]stringString to be written
[in]ncolnumber of columns for the printout
[in]justifyjustification flag (EJustify::LEFT, EJustify::CENTER or EJustify::RIGHT)
String toDouble ( double  value,
const EJustify &  justify 
)
String toInt ( int  value,
const EJustify &  justify 
)
String toInterval ( double  zmin,
double  zmax 
)
String toMatrix ( const String title,
const AMatrix mat,
bool  flagOverride,
bool  flagSkipZero 
)

Print the contents of a VectorDouble in a Matrix Form

Parameters
titleTitle of the printout
matContents of a AMatrix
flagOverridetrue to override printout limitations
flagSkipZerowhen true, skip the zero values (represented by a '.' as for sparse matrix) always true for sparse matrix
String toMatrix ( const String title,
const VectorString colnames,
const VectorString rownames,
bool  bycol,
int  ncols,
int  nrows,
const VectorDouble tab,
bool  flagOverride,
bool  flagSkipZero 
)

Print the contents of a VectorDouble in a Matrix Form

Parameters
titleTitle of the printout
colnamesNames of the columns (optional)
rownamesNames of the rows (optional)
bycoltrue if values as sorted by column; false otherwise
ncolsNumber of columns
nrowsNumber of rows
tabVectorDouble containing the values
flagOverridetrue to override printout limitations
flagSkipZerowhen true, skip the zero values (represented by a '.' as for sparse matrix)
String toMatrix ( const String title,
const VectorString colnames,
const VectorString rownames,
bool  bycol,
int  ncols,
int  nrows,
const VectorInt tab,
bool  flagOverride,
bool  flagSkipZero 
)

Print the contents of a VectorDouble in a Matrix Form

Parameters
titleTitle of the printout
colnamesNames of the columns (optional)
rownamesNames of the rows (optional)
bycoltrue if values as sorted by column; false otherwise
ncolsNumber of columns
nrowsNumber of rows
tabVectorInt containing the values
flagOverridetrue to override printout limitations
flagSkipZerowhen true, skip the zero values (represented by a '.' as for sparse matrix)
String toStr ( const String string,
const EJustify &  justify,
int  localSize 
)
String toTitle ( int  level,
const char *  format,
  ... 
)

Print a message and underlines it with various formats

Parameters
levelLevel of the title
formatOutput format
...Additional arguments
String toVector ( const String title,
const VectorDouble tab,
bool  flagOverride 
)

Printout a vector in a formatted manner

Parameters
titleTitle of the printout (or empty string)
tabVector (real values) to be printed
flagOverridetrue to override printout limitations
Returns
The string (terminated with a newline)
String toVector ( const String title,
const VectorVectorDouble tab,
bool  flagOverride 
)

Printout a list of vectors in a formatted manner

Parameters
titleTitle of the printout (or empty string)
tabVector of vectors (real values) to be printed
flagOverridetrue to override printout limitations
Returns
The string (terminated with a newline)
String toVector ( const String title,
const VectorString tab,
bool  flagOverride 
)
String toVector ( const String title,
const VectorInt tab,
bool  flagOverride 
)

Printout a vector in a formatted manner

Parameters
titleTitle of the printout (or empty string)
tabVector (integer values) to be printed
flagOverridetrue to override printout limitations
Returns
The string (terminated with a newline)
VectorString toVectorDouble ( const VectorDouble values,
const EJustify &  justify 
)