mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
|
Various input/output utilities
Modules | |
Working with strings | |
File System Utilities | |
ASCII I/O Utilities | |
FITS Files | |
binVector Binary File Format | |
A simple binary file format for storing vectors of data on disk. | |
Functions | |
template<char space = ' ', bool flush = true, char eol = '\n', typename valT , typename... valTs> | |
void | mx::ioutils::pout (valT value, const valTs &... values) |
A simple formatted output function. More... | |
template<typename T > | |
int | mx::ioutils::readRawBinary (T *data, size_t szData, const std::string &fileName) |
Read an array of data from a file as raw binary. More... | |
template<typename T > | |
int | mx::ioutils::writeRawBinary (const std::string &fileName, T *data, size_t szData) |
Write an array of data to file as raw binary. More... | |
void mx::ioutils::pout | ( | valT | value, |
const valTs &... | values | ||
) |
A simple formatted output function.
This function writes its arguments, of any type and of any number, to stdout. By default, the arguments are separated by a space, the new line '\n' is written at the end, and the std::cout stream is flushed. These behaviors can be altered via template parameters.
Example:
Note that the types of the values do not need to be specified as templated arguments. When run, this code results in
* $ output: 2.567 3 * $ *
The behavior can be changed with template arguments like
which would use the tab instead of space, and neither flush nor print a newline at the end.
space | is the character to place between the values, by default this is space. |
flush | controls whether std::cout.flush() is called, by default it is true. |
eol | is the character to print at end of line, by default it is '\n'. |
valT | a type which can be output by std::cout |
valTs | a variadic list of additional types which can be output by std::cout |
[in] | value | a value to print. |
[in] | values | a variadic list of additional values. Any number of values can be specified, with any type handled by std::cout. |
int mx::ioutils::readRawBinary | ( | T * | data, |
size_t | szData, | ||
const std::string & | fileName | ||
) |
Read an array of data from a file as raw binary.
Here raw binary means no formatting or metadata.
[out] | data | the data pointer |
[in] | szData | number of elements of sizeof(T) to read |
[in] | fileName | the file to read from |
Definition at line 50 of file rawBinary.hpp.
int mx::ioutils::writeRawBinary | ( | const std::string & | fileName, |
T * | data, | ||
size_t | szData | ||
) |
Write an array of data to file as raw binary.
Here raw binary means no formatting or metadata, just the bytes pointed to by the array are written to disk.
[in] | fileName | the file to write to |
[in] | data | the data pointer |
[in] | szData | number of elements of sizeof(T) to write |
Definition at line 101 of file rawBinary.hpp.