.TH "rheostream" 7rheolef "Sat Mar 13 2021" "Version 7.1" "rheolef" \" -*- nroff -*- .ad l .nh .SH NAME rheostream \- i/o utilities (rheolef-7\&.1) .PP .SH "DESCRIPTION" .PP Here, utilities for stream input and output are suitable are reviewed\&. Two classes are provided, together with a set of useful functions\&. .SH "OUTPUT STREAM" .PP The \fCirheostream\fP is suitable for a sequential memory envinement: for a distributed memory and parallel computation case, see the \fBdiststream(2)\fP class\&. Indeed, the \fCirheostream\fP is used as a base class for the \fCidiststream\fP one\&. .PP File decompresion is assumed using \fCgzip\fP and a recursive search in a directory list is provided for input\&. .PP .nf orheostream foo("NAME", "suffix"); .fi .PP is like .PP .nf ofstream foo("NAME.suffix"). .fi .PP However, if \fCNAME\fP does not end with \fC\&.suffix\fP, then \fC\&.suffix\fP is automatically added\&. By default, compression is performed on the fly with \fCgzip\fP, adding an additional \fC\&.gz\fP suffix\&. The \fCflush\fP action is nicely handled in compression mode: .PP .nf foo.flush(); .fi .PP This feature allows intermediate results to be available during long computations\&. The compression can be deactivated while opening a file by an optional argument: .PP .nf orheostream foo("NAME", "suffix", io::nogz); .fi .PP An existing compressed file can be reopen in \fCappend\fP mode: new results will be appended at the end of an existing file: .PP .nf orheostream foo("NAME", "suffix", io::app); .fi .PP .SH "INPUT STREAM" .PP Conversely, .PP .nf irheostream foo("NAME","suffix"); .fi .PP is like .PP .nf ifstream foo("NAME.suffix"). .fi .PP However, we look at a search path environment variable \fCRHEOPATH\fP in order to find \fCNAME\fP while suffix is assumed\&. Moreover, \fCgzip\fP compressed files, ending with the \fC\&.gz\fP suffix is assumed, and decompression is done\&. .SH "OPTIONS" .PP The following code: .PP .nf irheostream is("results", "data"); .fi .PP will recursively look for a \fCresults[\&.data[\&.gz]]\fP file in the rectory mentioned by the \fCRHEOPATH\fP environment variable\&. .PP For instance, if you insert in our '\&.cshrc' something like: .PP .nf setenv RHEOPATH ".:/home/dupont:/usr/local/math/demo" .fi .PP the process will study the current directory \fC\&.\fP, then, if neither \fCsquare\&.data\&.gz\fP nor \fCsquare\&.data\fP exits, it scan all subdirectory of the current directory\&. Then, if file is not founded, it start recusively in \fC/home/dupond\fP and then in \fC/usr/local/math/demo\fP\&. .PP File decompression is performed by using the \fCgzip\fP command, and data are pipe-lined directly in memory\&. .PP If the file start with \fC\&.\fP as \fC\&./square\fP or with a \fC/\fP as \fC/home/oscar/square\fP, no search occurs and \fCRHEOPATH\fP environment variable is not used\&. .PP Also, if the environment variable \fCRHEOPATH\fP is not set, the default value is the current directory \fC\&.\fP\&. .PP For output stream: .PP .nf orheostream os("newresults", "data"); .fi .PP file compression is assumed, and 'newresults\&.data\&.gz' will be created\&. .PP File loading and storing are mentioned by a message, either: .PP .nf ! load "./results.data.gz" .fi .PP or: .PP .nf ! file "./newresults.data.gz" created. .fi .PP on the \fCclog\fP stream\&. By adding the following: .PP .nf clog << noverbose; .fi .PP you turn off these messages\&. .SH "USEFULL FUNCTIONS" .PP .PP .nf // integer-to-string conversion std::string itos (std::string::size_type i); // float-to-string conversion std::string ftos (const Float& x); // catch first occurrence of string in file bool scatch (std::istream& in, const std::string& ch, bool full_match = true); // has_suffix("toto\&.suffix", "suffix") -> true bool has_suffix (const std::string& name, const std::string& suffix); // "toto\&.suffix" --> "toto" std::string delete_suffix (const std::string& name, const std::string& suffix); // has_any_suffix("toto\&.any_suffix") -> true bool has_any_suffix (const std::string& name); // delete_any_suffix("toto\&.any_suffix") --> "toto" std::string delete_any_suffix (const std::string& name); // "/usr/local/dir/toto\&.suffix" --> "toto\&.suffix" std::string get_basename (const std::string& name); // "/usr/local/dir/toto\&.suffix" --> "/usr/local/dir" std::string get_dirname (const std::string& name); // "toto" --> "/usr/local/math/data/toto\&.suffix" std::string get_full_name_from_rheo_path (const std::string& rootname, const std::string& suffix); // "\&." + "\&.\&./geodir" --> "\&.:\&.\&./geodir" void append_dir_to_rheo_path (const std::string& dir); // "\&.\&./geodir" + "\&." --> "\&.\&./geodir:\&." void prepend_dir_to_rheo_path (const std::string& dir); // predicate when a file exists bool file_exists (const std::string& filename); // is_float("3\&.14") -> true bool is_float (const std::string&); // string-to-float conversion Float to_float (const std::string&); // in TMPDIR environment variable or "/tmp" by default std::string get_tmpdir(); .fi .PP .SH "IMPLEMENTATION" .PP This documentation has been generated from file util/lib/rheostream\&.h .PP .PP .nf class irheostream : public boost::iostreams::filtering_stream { public: irheostream() : boost::iostreams::filtering_stream(), _ifs() {} irheostream(const std::string& name, const std::string& suffix = std::string()); virtual ~irheostream(); void open (const std::string& name, const std::string& suffix = std::string()); void close(); .fi .PP .PP .nf }; .fi .PP .PP .nf class orheostream : public boost::iostreams::filtering_stream { public: orheostream() : boost::iostreams::filtering_stream(), _mode(), _full_name() {} orheostream(const std::string& name, const std::string& suffix = std::string(), io::mode_type mode = io::out); virtual ~orheostream(); void open (const std::string& name, const std::string& suffix = std::string(), io::mode_type mode = io::out); void flush(); void close(); const std::string& filename() const { return _full_name; } .fi .PP .PP .nf }; .fi .PP .SH AUTHOR Pierre Saramito .SH COPYRIGHT Copyright (C) 2000-2018 Pierre Saramito GPLv3+: GNU GPL version 3 or later . This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.