Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

General Utility Classes

General utility classes. More...

Classes

struct  regina::boost::remove_pointer< T >
 A template class used to remove the indirection from a pointer type. More...
class  regina::boost::reference_wrapper< T >
 A wrapper allowing references to be passed through generic functions. More...
class  regina::boost::noncopyable
 A base class that guarantees that derived classes cannot be copied. More...
struct  regina::HashPointer
 A hash function used to calculate hash values for arbitrary pointers. More...
struct  regina::HashString
 A hash function used to calculate hash values for C++ strings. More...
struct  regina::FuncNew< T >
 An adaptable generator used to create objects using default constructors. More...
struct  regina::FuncNewCopyPtr< T >
 An adaptable unary function used to create objects using copy constructors. More...
struct  regina::FuncNewCopyRef< T >
 An adaptable unary function used to create objects using copy constructors. More...
struct  regina::FuncNewClonePtr< T >
 An adaptable unary function used to create objects using the clone() method. More...
struct  regina::FuncDelete< T >
 An adaptable unary function used to deallocate objects. More...
class  regina::NTriBool
 A three-way extension of the boolean type. More...
class  regina::NTriBool_Illegal_Integer_Conversion
 An exception thrown when an illegal integer conversion is attempted with NTriBool. More...
class  regina::NBoolSet
 A set of booleans. More...
class  regina::NIndexedArray< Data, HashFcn, EqualTo >
 A dynamically resizable array of objects of type T with fast random access and fast object-to-index lookup. More...
class  regina::NLargeInteger
 Represents an arbitrary precision integer. More...
class  regina::StoreValue< T >
 An NProperty storage policy indicating that the property should be held by value. More...
class  regina::StoreConstPtr< T >
 An NProperty storage policy indicating that the property should be held by constant pointer. More...
class  regina::StoreManagedPtr< T >
 An NProperty storage policy indicating that the property should be held by pointer and that the property wrapper will also take responsibility for memory management. More...
class  regina::NPropertyBase
 A base class that provides routines shared by all properties, regardless of their individual NProperty template parameters. More...
class  regina::NProperty< T, Storage >
 Stores a calculable property of an object. More...
class  regina::NRational
 Represents an arbitrary precision rational number. More...
class  regina::NMutex
 A mutual exclusion device (mutex) used to ensure that different threads do not interfere when working with the same data. More...
class  regina::NThread
 Provides very basic thread handling. More...
struct  regina::stl::select1st< Pair >
 An adaptable unary function used to select the first element of a pair. More...
struct  regina::stl::select2nd< Pair >
 An adaptable unary function used to select the second element of a pair. More...
class  regina::stl::unary_compose< Operation1, Operation2 >
 An adaptable unary function used to compose two unary functions. More...
class  regina::xml::XMLPropertyDict
 Represents a hashed map from property names to property values. More...
class  regina::xml::XMLParserCallback
 Provides the callbacks for an XMLParser. More...
class  regina::xml::XMLParser
 Used to parse an entire XML file. More...
class  regina::ZBuffer
 A common base class for compression/decompression stream buffers. More...
class  regina::CompressionBuffer
 An output stream buffer that compresses data as it is written. More...
class  regina::DecompressionBuffer
 An input stream buffer that decompresses data as it is read. More...
class  regina::CompressionStream
 An output stream that compresses data as it is written. More...
class  regina::DecompressionStream
 An input stream that decompresses data as it is read. More...

Typedefs

typedef pthread_t regina::NThreadID
 The type used for a thread identifier.

Functions

template<class T>
reference_wrapper< T > const regina::boost::ref (T &t)
 Returns a wrapper for the given reference.
template<class T>
reference_wrapper< T const
> const 
regina::boost::cref (T const &t)
 Returns a wrapper for the given const reference.
template<class T>
regina::boost::prior (T it)
 Returns the iterator prior to the given iterator.
template<class T>
regina::boost::next (T it)
 Returns the iterator following the given iterator.
std::ostream & regina::operator<< (std::ostream &out, const NTriBool &set)
 Writes the given three-way boolean to the given output stream.
std::ostream & regina::operator<< (std::ostream &out, const NBoolSet &set)
 Writes the given boolean set to the given output stream.
template<class Data, class HashFcn, class EqualTo>
bool regina::operator== (const NIndexedArray< Data, HashFcn, EqualTo > &array1, const NIndexedArray< Data, HashFcn, EqualTo > &array2)
 See the C++ standard.
template<class Data, class HashFcn, class EqualTo>
bool regina::operator< (const NIndexedArray< Data, HashFcn, EqualTo > &array1, const NIndexedArray< Data, HashFcn, EqualTo > &array2)
 See the C++ standard.
std::ostream & regina::operator<< (std::ostream &out, const NLargeInteger &large)
 Writes the given integer to the given output stream.
std::ostream & regina::operator<< (std::ostream &out, const NRational &rat)
 Writes the given rational to the given output stream.
template<class Operation1, class Operation2>
unary_compose< Operation1,
Operation2 > 
regina::stl::compose1 (const Operation1 &func1, const Operation2 &func2)
 Returns an adaptable unary function that is the composition of the two given functions.
char * regina::duplicate (const std::string &str)
 Creates a new C string that is a duplicate of the given C++ string.
bool regina::startsWith (const std::string &str, const std::string &prefix)
 Determines whether the given C++ string begins with the given prefix.
std::string regina::stripWhitespace (const std::string &str)
 Strips all whitespace from the beginning and end of the given C++ string.
bool regina::valueOf (const std::string &str, int &dest)
 Converts the entire given string to an integer and reports whether this conversion was successful.
bool regina::valueOf (const std::string &str, unsigned &dest)
 Converts the entire given string to an unsigned integer and reports whether this conversion was successful.
bool regina::valueOf (const std::string &str, long &dest)
 Converts the entire given string to a long integer and reports whether this conversion was successful.
bool regina::valueOf (const std::string &str, unsigned long &dest)
 Converts the entire given string to an unsigned long integer and reports whether this conversion was successful.
bool regina::valueOf (const std::string &str, NLargeInteger &dest)
 Converts the entire given string to an arbitrary precision integer and reports whether this conversion was successful.
bool regina::valueOf (const std::string &str, double &dest)
 Converts the entire given string to a double precision real number and reports whether this conversion was successful.
bool regina::valueOf (const std::string &str, bool &dest)
 Converts the entire given string to a boolean and reports whether this conversion was successful.
bool regina::valueOf (const std::string &str, NTriBool &dest)
 Converts the entire given string to a three-way boolean (true, false or unknown) and reports whether this conversion was successful.
bool regina::valueOf (const std::string &str, NBoolSet &dest)
 Converts the entire given string to a set of booleans and reports whether this conversion was successful.
template<class OutputIterator>
unsigned regina::basicTokenise (OutputIterator results, const std::string &str)
 Decomposes the given string into tokens.
std::string regina::xml::xmlEncodeSpecialChars (const std::string &original)
 Returns the given string with special characters converted to XML entities.
std::string regina::xml::xmlEncodeComment (const std::string &comment)
 Returns the given string encoded so it is suitable for use inside an XML comment.
template<class T>
std::string regina::xml::xmlValueTag (const std::string &tagName, const T &value)
 Returns an XML tag with a single property containing the given value.

Detailed Description

General utility classes.


Typedef Documentation

typedef pthread_t regina::NThreadID
 

The type used for a thread identifier.


Function Documentation

template<class OutputIterator>
unsigned regina::basicTokenise OutputIterator  results,
const std::string &  str
 

Decomposes the given string into tokens.

This is an extremely simple tokeniser; tokens are defined to be separated by whitespace.

Python:
Not present.
Parameters:
results the output iterator to which the resulting tokens will be written; this must accept objects of type const std::string&.
str the string to decompose.
Returns:
the number of tokens found.

template<class Operation1, class Operation2>
unary_compose<Operation1, Operation2> regina::stl::compose1 const Operation1 &  func1,
const Operation2 &  func2
[inline]
 

Returns an adaptable unary function that is the composition of the two given functions.

This class is for use with the Standard Template Library.

The composition of functions func1 and func2 is the function comp for which comp(x) == func1(func2(x)).

Precondition:
Both arguments are themselves adaptable unary functions.

Type Operation1::argument_type is the same as (or can be constructed from) type Operation2::result_type.

Python:
Not present.
Parameters:
func1 the first function to use in the composition.
func2 the second function to use in the composition.
Returns:
the composition of the two given functions.
Author:
This routine was taken and modified from the Standard Template Library (http://www.stlport.org/).

template<class T>
reference_wrapper<T const> const regina::boost::cref T const &  t  )  [inline]
 

Returns a wrapper for the given const reference.

See reference_wrapper for further details.

Python:
Not present.
Parameters:
t the reference to wrap.
Returns:
the corresponding wrapper.
Author:
This routine was taken and modified from the Boost C++ libraries (http://www.boost.org/).

char* regina::duplicate const std::string &  str  ) 
 

Creates a new C string that is a duplicate of the given C++ string.

The deallocation of the new C string is the responsibility of the caller of this routine.

Python:
Not present.
Parameters:
str the C++ string to duplicate.
Returns:
the new duplicate C string.

template<class T>
T regina::boost::next it  )  [inline]
 

Returns the iterator following the given iterator.

This function avoids having to explicitly create a temporary to increment.

Only the increment operator ++it needs to be defined.

Python:
Not present.
Parameters:
it the iterator to examine.
Returns:
the iterator following the given iterator.
Author:
This routine was taken and modified from the Boost C++ libraries (http://www.boost.org/).

template<class Data, class HashFcn, class EqualTo>
bool regina::operator< const NIndexedArray< Data, HashFcn, EqualTo > &  array1,
const NIndexedArray< Data, HashFcn, EqualTo > &  array2
[inline]
 

See the C++ standard.

std::ostream& regina::operator<< std::ostream &  out,
const NRational &  rat
 

Writes the given rational to the given output stream.

Infinity will be written as Inf. Undefined will be written as Undef. A rational with denominator one will be written as a single integer. All other rationals will be written in the form r/s.

Parameters:
out the output stream to which to write.
rat the rational to write.
Returns:
a reference to out.

std::ostream& regina::operator<< std::ostream &  out,
const NLargeInteger &  large
 

Writes the given integer to the given output stream.

Parameters:
out the output stream to which to write.
large the integer to write.
Returns:
a reference to out.

std::ostream& regina::operator<< std::ostream &  out,
const NBoolSet &  set
 

Writes the given boolean set to the given output stream.

The set will be written in the form { true, false }, { true }, { false } or { }.

Parameters:
out the output stream to which to write.
set the boolean set to write.
Returns:
a reference to out.

std::ostream& regina::operator<< std::ostream &  out,
const NTriBool &  set
 

Writes the given three-way boolean to the given output stream.

The value will be written in the form true, false or unknown.

Parameters:
out the output stream to which to write.
set the three-way boolean to write.
Returns:
a reference to out.

template<class Data, class HashFcn, class EqualTo>
bool regina::operator== const NIndexedArray< Data, HashFcn, EqualTo > &  array1,
const NIndexedArray< Data, HashFcn, EqualTo > &  array2
[inline]
 

See the C++ standard.

template<class T>
T regina::boost::prior it  )  [inline]
 

Returns the iterator prior to the given iterator.

This function avoids having to explicitly create a temporary to decrement.

Only the decrement operator --it needs to be defined.

Python:
Not present.
Parameters:
it the iterator to examine.
Returns:
the iterator prior to the given iterator.
Author:
This routine was taken and modified from the Boost C++ libraries (http://www.boost.org/).

template<class T>
reference_wrapper<T> const regina::boost::ref T &  t  )  [inline]
 

Returns a wrapper for the given reference.

See reference_wrapper for further details.

Python:
Not present.
Parameters:
t the reference to wrap.
Returns:
the corresponding wrapper.
Author:
This routine was taken and modified from the Boost C++ libraries (http://www.boost.org/).

bool regina::startsWith const std::string &  str,
const std::string &  prefix
 

Determines whether the given C++ string begins with the given prefix.

Python:
Not present.
Parameters:
str the full C++ string to examine.
prefix the prefix whose presence we are testing for.
Returns:
true if and only if str begins with prefix.

std::string regina::stripWhitespace const std::string &  str  ) 
 

Strips all whitespace from the beginning and end of the given C++ string.

The new stripped string is returned; the original string is not altered.

Python:
Not present.
Parameters:
str the string to be stripped.
Returns:
the resulting stripped string.

bool regina::valueOf const std::string &  str,
NBoolSet &  dest
 

Converts the entire given string to a set of booleans and reports whether this conversion was successful.

A set of booleans is represented by one of the four strings --, T-, -F or TF. If the conversion is unsuccessful, argument dest will be set to NBoolSet::sNone and false will be returned.

Python:
Not present.
Parameters:
str the string to convert.
dest the variable in which to store the resulting set of booleans.
Returns:
true if the conversion was successful or false otherwise.

bool regina::valueOf const std::string &  str,
NTriBool &  dest
 

Converts the entire given string to a three-way boolean (true, false or unknown) and reports whether this conversion was successful.

If the given string begins with T, F or U (either upper- or lower-case), the string will be successfully converted to true, false or unknown respectively. If the string is one of 1, -1 or 0, the string will likewise be converted to true, false or unknown respectively. Otherwise the conversion will be unsuccessful and argument dest will be set to unknown.

Python:
Not present.
Parameters:
str the string to convert.
dest the variable in which to store the resulting set of booleans.
Returns:
true if the conversion was successful or false otherwise.

bool regina::valueOf const std::string &  str,
bool &  dest
 

Converts the entire given string to a boolean and reports whether this conversion was successful.

If the given string begins with T or F (either upper- or lower-case), the string will be successfully converted to true or false respectively. Otherwise the conversion will be unsuccessful and argument dest will be set to false.

Python:
Not present.
Parameters:
str the string to convert.
dest the variable in which to store the resulting boolean.
Returns:
true if the conversion was completely successful or false otherwise.

bool regina::valueOf const std::string &  str,
double &  dest
 

Converts the entire given string to a double precision real number and reports whether this conversion was successful.

The given string should contain no whitespace or other characters that are not a part of the real number that the string represents. If any unexpected characters are encountered, the routine will convert the string as best it can but false will be returned.

Python:
Not present.
Parameters:
str the string to convert.
dest the variable in which to store the resulting real number.
Returns:
true if the conversion was completely successful or false otherwise.

bool regina::valueOf const std::string &  str,
NLargeInteger &  dest
 

Converts the entire given string to an arbitrary precision integer and reports whether this conversion was successful.

The given string should contain no whitespace or other characters that are not a part of the integer that the string represents. If any unexpected characters are encountered, the routine will convert the string as best it can but false will be returned.

Python:
Not present.
Parameters:
str the string to convert.
dest the variable in which to store the resulting arbitrary precision integer.
Returns:
true if the conversion was completely successful or false otherwise.

bool regina::valueOf const std::string &  str,
unsigned long &  dest
 

Converts the entire given string to an unsigned long integer and reports whether this conversion was successful.

The given string should contain no whitespace or other characters that are not a part of the integer that the string represents. If any unexpected characters are encountered, the routine will convert the string as best it can but false will be returned.

Python:
Not present.
Parameters:
str the string to convert.
dest the variable in which to store the resulting unsigned long integer.
Returns:
true if the conversion was completely successful or false otherwise.

bool regina::valueOf const std::string &  str,
long &  dest
 

Converts the entire given string to a long integer and reports whether this conversion was successful.

The given string should contain no whitespace or other characters that are not a part of the integer that the string represents. If any unexpected characters are encountered, the routine will convert the string as best it can but false will be returned.

Python:
Not present.
Parameters:
str the string to convert.
dest the variable in which to store the resulting long integer.
Returns:
true if the conversion was completely successful or false otherwise.

bool regina::valueOf const std::string &  str,
unsigned &  dest
 

Converts the entire given string to an unsigned integer and reports whether this conversion was successful.

The given string should contain no whitespace or other characters that are not a part of the integer that the string represents. If any unexpected characters are encountered, the routine will convert the string as best it can but false will be returned.

Python:
Not present.
Parameters:
str the string to convert.
dest the variable in which to store the resulting unsigned integer.
Returns:
true if the conversion was completely successful or false otherwise.

bool regina::valueOf const std::string &  str,
int &  dest
 

Converts the entire given string to an integer and reports whether this conversion was successful.

The given string should contain no whitespace or other characters that are not a part of the integer that the string represents. If any unexpected characters are encountered, the routine will convert the string as best it can but false will be returned.

Python:
Not present.
Parameters:
str the string to convert.
dest the variable in which to store the resulting integer.
Returns:
true if the conversion was completely successful or false otherwise.

std::string regina::xml::xmlEncodeComment const std::string &  comment  ) 
 

Returns the given string encoded so it is suitable for use inside an XML comment.

As well as converting special characters to XML entities, this routine will replace dashes with underscores to avoid double-hyphens (which are illegal in XML comments).

Python:
Not present.
Parameters:
comment the string to convert; this string will not be changed.
Returns:
the string converted to be usable inside an XML comment.

std::string regina::xml::xmlEncodeSpecialChars const std::string &  original  ) 
 

Returns the given string with special characters converted to XML entities.

For instance, the string "a \< b" would be converted to "a \&lt; b".

Python:
Not present.
Parameters:
original the string to convert; this string will not be changed.
Returns:
the converted string with special characters replaced by XML entities.

template<class T>
std::string regina::xml::xmlValueTag const std::string &  tagName,
const T &  value
[inline]
 

Returns an XML tag with a single property containing the given value.

The tag will be of the form <tagName value="..."/>.

The value itself will be written to the tag string using the standard output stream operator <<.

Precondition:
The property value when written to an output stream does not contain any special characters (such as < or &) that need to be encoded as XML entities.
Python:
Not present.
Parameters:
tagName the name of the XML tag to create.
value the value to assign to the value property of the tag.
Returns:
the corresponding XML tag.


Copyright © 1999-2004, Ben Burton
This software is released under the GNU General Public License.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@debian.org).