This file contains some useful functions related to the text input/output procedures. More...
#include "chomp/system/config.h"
#include <ctime>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
Go to the source code of this file.
Classes | |
class | chomp::homology::outputstream |
This class defines an output stream for replacing the standard 'cout'. More... | |
struct | chomp::homology::outputstream::mute |
Local mute of the stream. More... | |
class | chomp::homology::textfile |
A class for reading text data from a text file. More... | |
Namespaces | |
namespace | chomp |
This namespace contains the entire CHomP library interface. | |
namespace | chomp::homology |
This namespace contains the core of the homology computation procedures and related classes and templates contained in the CHomP C++ library. | |
Defines | |
#define | ERRORMSG {std::ostringstream error_msg_string; error_msg_string |
The first macro in a pair of macrodefinitions for throwing an error message. | |
#define | THROW ""; throw error_msg_string. str (). c_str (); } |
The second macro in a pair of macrodefinitions for throwing an error message. | |
#define | MAXTEXTLENGTH 200 |
The maximal length of a phrase read at a time from the input text file by the class textfile. | |
Functions | |
template<typename type > | |
outputstream & | chomp::homology::operator<< (outputstream &out, const type &object) |
The operator << for writing any kind of object to the output stream. | |
outputstream & | chomp::homology::operator<< (outputstream &out, const char *object) |
A specialization of the operator << for writing a C-style string to the output stream. | |
outputstream & | chomp::homology::operator<< (outputstream &out, std::ostream &(*object)(std::ostream &)) |
A specialization of the operator << for putting manipulators (like std::endl, std::flush) to the output stream. | |
template<class type > | |
void | chomp::homology::swapelements (type &x, type &y) |
A simple template for swapping two elements with the use of a temporary variable of the same type and the assignment operator. | |
template<class type > | |
int | chomp::homology::sortelements (type *tab, int n) |
A simple template that sorts an array using the bubble sort method, removes repeated elements and returns the new number of the elements. | |
void | chomp::homology::ignoreline (std::istream &in) |
Ignores the input characters until the end of a line, including this end of the line. | |
void | chomp::homology::ignorecomments (std::istream &in) |
Ignores white characters (spaces, tabulators, CRs and LFs), as well as comments from the input text file. | |
int | chomp::homology::closingparenthesis (int ch) |
Returns the matching closing parenthesis for the given opening one or EOF if none. | |
int | chomp::homology::readparenthesis (std::istream &in) |
Reads an opening parenthesis from the input file. | |
std::string | chomp::homology::commandline (int argc, char *argv[]) |
Returns the entire command line as a single string. | |
const char * | chomp::homology::currenttime (void) |
Retrieves the current time as a pointer to a C-style string. | |
template<class settype > | |
static void | chomp::homology::savetheset (const settype &c, const char *prefix, const char *filename, const char *name) |
Writes the given object to a file whose name is a concatenation of the prefix and the given file name. | |
void | chomp::homology::fileerror (const char *filename, const char *what="open") |
Throws a message about the inability to do something with a file. | |
Variables | |
outputstream | chomp::homology::sout |
A replacement for standard output stream, with optional logging and other features provided by the class 'outputstream'. | |
outputstream | chomp::homology::scon |
The console output stream to which one should put all the junk that spoils the log file, like progress indicators. | |
outputstream | chomp::homology::serr |
A wrapper for the standard error stream. | |
outputstream | chomp::homology::slog |
The output stream to which one can send messages for logging only. | |
outputstream | chomp::homology::sbug |
An output stream for writing additional debug messages. | |
outputstream | chomp::homology::sseq |
An auxiliary stream which captures sequences of processed data. |
This file contains some useful functions related to the text input/output procedures.
It also contains the definition of some output streams that can be used instead the standard ones (sout, serr) which support logging to a file or suppressing messages to the screen.
Definition in file textfile.h.
#define ERRORMSG {std::ostringstream error_msg_string; error_msg_string |
The first macro in a pair of macrodefinitions for throwing an error message.
In order to throw an error message of the type std::string, one can type something like the following:
ERRORMSG << "Wrong number: " << n << " instead of 0." << THROW
Note that there is no semicolon at the end. This is important especially in the setting like below:
if (n != 0) ERRORMSG << .......... << THROW else ..........
In some cases this pair of macros may probably not work properly, but at the moment I couldn't come up with anything better.
Definition at line 497 of file textfile.h.
Referenced by chomp::homology::fileerror().
#define MAXTEXTLENGTH 200 |
The maximal length of a phrase read at a time from the input text file by the class textfile.
Definition at line 522 of file textfile.h.
#define THROW ""; throw error_msg_string. str (). c_str (); } |
The second macro in a pair of macrodefinitions for throwing an error message.
See the description at the ERRORMSG macro.
Definition at line 501 of file textfile.h.
Referenced by chomp::homology::fileerror().