The Original CHomP Software
Classes | Namespaces | Macros | Functions | Variables
textfile.h File Reference

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.
 

Macros

#define ERRORMSG   {std::ostringstream error_msg_string; error_msg_string
 The first macro in a pair of macrodefinitions for throwing an error message. More...
 
#define THROW   ""; throw error_msg_string. str (). c_str (); }
 The second macro in a pair of macrodefinitions for throwing an error message. More...
 
#define MAXTEXTLENGTH   200
 The maximal length of a phrase read at a time from the input text file by the class textfile. More...
 

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. More...
 
outputstream & chomp::homology::operator<< (outputstream &out, const char *object)
 A specialization of the operator << for writing a C-style string to the output stream. More...
 
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. More...
 
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. More...
 
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. More...
 
void chomp::homology::ignoreline (std::istream &in)
 Ignores the input characters until the end of a line, including this end of the line. More...
 
void chomp::homology::ignorecomments (std::istream &in)
 Ignores white characters (spaces, tabulators, CRs and LFs), as well as comments from the input text file. More...
 
int chomp::homology::closingparenthesis (int ch)
 Returns the matching closing parenthesis for the given opening one or EOF if none. More...
 
int chomp::homology::readparenthesis (std::istream &in)
 Reads an opening parenthesis from the input file. More...
 
std::string chomp::homology::commandline (int argc, char *argv[])
 Returns the entire command line as a single string. More...
 
const char * chomp::homology::currenttime (void)
 Retrieves the current time as a pointer to a C-style string. More...
 
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. More...
 
void chomp::homology::fileerror (const char *filename, const char *what="open")
 Throws a message about the inability to do something with a file. More...
 

Variables

outputstream chomp::homology::sout
 A replacement for standard output stream, with optional logging and other features provided by the class 'outputstream'. More...
 
outputstream chomp::homology::scon
 The console output stream to which one should put all the junk that spoils the log file, like progress indicators. More...
 
outputstream chomp::homology::serr
 A wrapper for the standard error stream. More...
 
outputstream chomp::homology::slog
 The output stream to which one can send messages for logging only. More...
 
outputstream chomp::homology::sbug
 An output stream for writing additional debug messages. More...
 
outputstream chomp::homology::sseq
 An auxiliary stream which captures sequences of processed data. More...
 

Detailed Description

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.

Author
Pawel Pilarczyk

Definition in file textfile.h.

Macro Definition Documentation

◆ ERRORMSG

#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 521 of file textfile.h.

◆ MAXTEXTLENGTH

#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 546 of file textfile.h.

◆ THROW

#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 525 of file textfile.h.