Class auto_format (o2scl_auto_format)¶
-
class
o2scl_auto_format
::
auto_format
¶ Automatically format output.
This class is a wrapper around output streams which performs automatic spacing and table formatting. Only scientific formatting for floating-point numbers is supported at present.
- Todo:
Allow user-specified table alignments
- Todo:
switch to columnify::add_spaces() and add more complicated table line specifications
- Todo:
Support multiprecision types.
- Todo:
Implement row_max
- Note
Experimental.
- Note
This class caches each line before sending to cout, so issuing
cout << std::flush
in the middle of a line will not output the buffer to the screen.- Note
The attach() function stores a pointer to the output stream, so the user must take care to make sure this pointer is valid.
- Idea for Future:
Create a replacement for std::flush
- Idea for Future:
Finish automatic table detection
- Idea for Future:
For automatic table detection: allow user to change the number of rows which must have the same number of ‘words’ to verify a table.
- Idea for Future:
Make internal algorithm more efficient.
Standard buffer
-
std::vector<std::string>
lines
¶ Output line buffer.
-
size_t
precision_
¶ The output precision for floating-point numbers.
Table mode
-
bool
auto_tables
¶ If true, try to automatically detect tables (default true)
-
size_t
n_headers
¶ The number of table header rows.
-
std::vector<std::vector<std::string>>
headers
¶ Headers for table mode.
-
bool
inside_table
¶ If true, we are currently inside a table.
-
std::vector<std::vector<std::string>>
columns
¶ Columns for table mode.
-
size_t
next_column
¶ Index of next column.
-
size_t
row_max
¶ Maximum number of table rows (default 1000)
-
std::vector<int>
aligns
¶ Alignment specifications for table columns.
-
std::ostream *
outs
¶ Pointer to the output stream.
-
bool
align_matrices
¶ If true, align the output of matrices (default true)
-
int
verbose
¶ Verbosity parameter (default 0)
-
int
table_lines
¶ Parameter for table line output.
-
friend auto_format &
operator<<
(auto_format &at, double d)¶
-
template<class
data_t
>
friend auto_format &operator<<
(auto_format &at, const boost::numeric::ublas::matrix<data_t> &vu)¶ Output a ublas matrix.
If auto_format::align_matrices is true, then the output is organized into a table.
-
template<class
data_t
>
friend auto_format &operator<<
(auto_format &at, const std::vector<std::vector<data_t>> &vv)¶ Output a vector of vectors.
If auto_format::align_matrices is true and all of the vectors in the list have the same length, then the output is organized into a table.
-
auto_format
()¶
-
void
attach
(std::ostream &out)¶ Desc.
-
void
unattach
()¶ Desc.
-
void
add_string
(std::string s)¶ Add a string to the output buffer.
-
void
precision
(size_t p)¶ Desc.
-
void
off
()¶ Disable formatting and send all output directly to
cout
.
-
void
on
()¶ Turn on automatic formatting (on by default)
-
void
endline
()¶ Add an endline.
-
void
done
()¶ Flush all buffered output to the screen.
-
void
start_table
()¶ Start a table.
-
void
debug_table
()¶ Debug the table.
-
void
end_table
()¶ End a table.
Protected Attributes
-
bool
enabled
¶ If true, automatic formatting is enabled (default true)