Regina 7.0 Calculation Engine
Public Member Functions | List of all members
regina::ShortOutput< T, supportsUtf8 > Struct Template Reference

A common base class for objects that provide short text output only. More...

#include <core/output.h>

Inheritance diagram for regina::ShortOutput< T, supportsUtf8 >:
regina::Output< T, false > regina::TreeTraversal< LPConstraintNone, BanNone, Integer > regina::Vector< IntegerType > regina::TautEnumeration< LPConstraint, BanConstraint, IntType > regina::TreeEnumeration< LPConstraint, BanConstraint, IntType > regina::TreeSingleSoln< LPConstraint, BanConstraint, IntType >

Public Member Functions

void writeTextLong (std::ostream &out) const
 A default implementation for detailed output. More...
 
std::string str () const
 Returns a short text representation of this object. More...
 
std::string utf8 () const
 Returns a short text representation of this object using unicode characters. More...
 
std::string detail () const
 Returns a detailed text representation of this object. More...
 

Detailed Description

template<class T, bool supportsUtf8 = false>
struct regina::ShortOutput< T, supportsUtf8 >

A common base class for objects that provide short text output only.

All classes that provide human-readable text output should ultimately inherit from Output, which provides support for short output (both with and without unicode support) as well as detailed output. However, if your class is simple and has no need for detailed output, then you may inherit from ShortOutput instead.

If you inherit from this class, then you only need to provide a single function writeTextShort(), as described in the Output class notes. You do not need to provide writeTextLong(); this class will implement it for you.

As with Output, this class will provide three routines str(), utf8() and detail(). The function detail() will return the same output as str(), but with a final newline added.

Template Parameters
Tthe class that provides the implementation of writeTextShort(). Typically this will be your own class (i.e., your class C derives from ShortOutput<C>). However, this may be deeper in the class hierarchy.
supportsUtf8true if the class T can make use of the richer unicode character set, or false if the short and utf8 outputs are identical. If this is false then T::writeTextShort() will only ever be called in the form writeTextShort(std::ostream&), and you may for simplicity omit the second boolean utf8 argument. This ShortOutput base class will still provide a utf8() function, but it will return the same output as short().
Python
Not present, but the output routines str(), utf8() and detail() will be provided directly through the various subclasses.

Member Function Documentation

◆ detail()

std::string regina::Output< T, supportsUtf8 >::detail ( ) const
inherited

Returns a detailed text representation of this object.

This text may span many lines, and should provide the user with all the information they could want. It should be human-readable, should not contain extremely long lines (which cause problems for users reading the output in a terminal), and should end with a final newline. There are no restrictions on the underlying character set.

Returns
a detailed text representation of this object.

◆ str()

std::string regina::Output< T, supportsUtf8 >::str ( ) const
inherited

Returns a short text representation of this object.

This text should be human-readable, should use plain ASCII characters where possible, and should not contain any newlines.

Within these limits, this short text ouptut should be as information-rich as possible, since in most cases this forms the basis for the Python str() and repr() functions.

Python
The Python "stringification" function str() will use precisely this function, and for most classes the Python repr() function will incorporate this into its output.
Returns
a short text representation of this object.

◆ utf8()

std::string regina::Output< T, supportsUtf8 >::utf8 ( ) const
inherited

Returns a short text representation of this object using unicode characters.

Like str(), this text should be human-readable, should not contain any newlines, and (within these constraints) should be as information-rich as is reasonable.

Unlike str(), this function may use unicode characters to make the output more pleasant to read. The string that is returned will be encoded in UTF-8.

Returns
a short text representation of this object.

◆ writeTextLong()

template<class T , bool supportsUtf8>
void regina::ShortOutput< T, supportsUtf8 >::writeTextLong ( std::ostream &  out) const
inline

A default implementation for detailed output.

This routine simply calls T::writeTextShort() and appends a final newline.

Python
Not present; instead you can call detail() from the subclass T, which returns this output as a string.
Parameters
outthe output stream to which to write.

The documentation for this struct was generated from the following file:

Copyright © 1999-2021, The Regina development team
This software is released under the GNU General Public License, with some additional permissions; see the source code for details.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@maths.uq.edu.au).