PSCF v1.1
Classes | Functions
Miscellaneous Utilities

Miscellaneous utility classes and functions. More...

Classes

class  Util::Bit
 Represents a specific bit location within an unsigned int. More...
 
class  Util::Exception
 A user-defined exception. More...
 
class  Util::FileMaster
 A FileMaster manages input and output files for a simulation. More...
 
class  Util::FlagSet
 A set of boolean variables represented by characters. More...
 
class  Util::Log
 A static class that holds a log output stream. More...
 
class  Util::Memory
 Provides method to allocate array. More...
 
class  Util::Notifier< Event >
 Abstract template for a notifier (or subject) in the Observer design pattern. More...
 
class  Util::Observer< Event >
 Abstract class template for observer in the observer design pattern. More...
 
class  Util::Setable< T >
 Template for a value that can be set or declared null (i.e., unknown). More...
 
class  Util::Timer
 Wall clock timer. More...
 

Functions

std::string Util::toString (int n)
 Return string representation of an integer. More...
 
int Util::rStrip (std::string &string)
 Strip trailing whitespace from a string. More...
 
void Util::checkString (std::istream &in, const std::string &expected)
 Extract string from stream, and compare to expected value. More...
 
bool Util::getLine (std::istream &in, std::stringstream &line)
 Read the next line into a stringstream. More...
 
bool Util::getNextLine (std::istream &in, std::string &line)
 Read the next non-empty line into a string, strip trailing whitespace. More...
 
bool Util::getNextLine (std::istream &in, std::stringstream &line)
 Read next non-empty line into a stringstream, strip trailing whitespace. More...
 
template<typename D , typename B , typename M >
ptrdiff_t Util::memberOffset (D &object, M B::*memPtr)
 Template for calculating offsets of data members. More...
 

Detailed Description

Miscellaneous utility classes and functions.

Function Documentation

◆ toString()

std::string Util::toString ( int  n)

Return string representation of an integer.

Parameters
ninteger to be converted.

Definition at line 52 of file ioUtil.cpp.

Referenced by Pscf::Fd1d::Sweep::getSolution(), Pscf::Fd1d::System::writeQAll(), Pscf::Pspc::System< D >::writeQAll(), and Pscf::Pspg::System< D >::writeQAll().

◆ rStrip()

int Util::rStrip ( std::string &  string)

Strip trailing whitespace from a string.

Parameters
stringstring (stripped upon return).
Returns
length of stripped string.

Definition at line 18 of file ioUtil.cpp.

Referenced by Util::getNextLine(), and Util::XmlAttribute::match().

◆ checkString()

void Util::checkString ( std::istream &  in,
const std::string &  expected 
)

Extract string from stream, and compare to expected value.

Exceptions
Exceptionif input value differs from expected value.
Parameters
ininput stream
expectedexpected value of string read from stream

Definition at line 37 of file ioUtil.cpp.

References Util::Log::file(), and UTIL_THROW.

◆ getLine()

bool Util::getLine ( std::istream &  in,
std::stringstream &  line 
)

Read the next line into a stringstream.

Variant of std::getline(). Does not strip trailing whitespace.

Parameters
ininput stream from which to read.
linestringstream containing line, on output.

Definition at line 62 of file ioUtil.cpp.

◆ getNextLine() [1/2]

bool Util::getNextLine ( std::istream &  in,
std::string &  line 
)

Read the next non-empty line into a string, strip trailing whitespace.

Variant of std::getline() that skips empty lines.

Parameters
ininput stream from which to read.
linestring with next non-empty line, on output.
Returns
true if not end-of-file, false if end-of-file.

Definition at line 79 of file ioUtil.cpp.

References Util::rStrip().

◆ getNextLine() [2/2]

bool Util::getNextLine ( std::istream &  in,
std::stringstream &  line 
)

Read next non-empty line into a stringstream, strip trailing whitespace.

Variant of std::getline() that skips empty lines and uses stringstream.

Parameters
ininput stream from which to read.
linestringstream containing next non-empty line, on output.
Returns
true if not end-of-file, false if end-of-file.

Definition at line 100 of file ioUtil.cpp.

References Util::rStrip().

◆ memberOffset()

template<typename D , typename B , typename M >
ptrdiff_t Util::memberOffset ( D &  object,
M B::*  memPtr 
)

Template for calculating offsets of data members.

Types: D - derived class B - base class M - member type

Definition at line 27 of file Offset.h.