String Manipulation


There are a couple classes and functions to help manipulate strings of text found in src/base/string_conv.h.

The columnify class converts a set of strings into nicely formatted columns by padding with the necessary amount of spaces. This class operates on string objects of type std::string, and also works will for formatting columns of floating-point numbers. This class is used to provide output for matrices in the functions o2scl::matrix_out().

The format_float class will reformat double precision numbers into a form appropriate for HTML or LaTeX documents.

A related function, o2scl::screenify(), reformats a column of strings into many columns stored row-by-row in a new string array. It operates very similar to the way the classic Unix command ls organizes files and directories in multiple columns in order to save screen space.

The function o2scl::function_to_double() converts strings like "pi/3.0" and "exp(cos(-1.0e-2))" to double-precision floating point numbers using find_constants and calculator or calc_utf8. An alternate version which won’t call the error handler is o2scl::function_to_double_nothrow(). This latter function is the one used by acol -calc.

There are also a set of string conversion functions. They partially duplicate the functionality of C++ Standard Library functions like std::stod() and std::to_string, but often provide alternate forms and different options. These functions include:

Other functions in src/base/string_conv.h are: