The TextStream
Class Reference
Text streaming class that buffers data. More...
Declaration
Included Headers
Public Constructors Index
TextStream (size_t capacity=INITIAL_CAPACITY) | |
Creates an empty stream object. More... | |
TextStream (std::ostream *s) | |
Create a text stream object for writing to a std::ostream. More... | |
TextStream (const std::string &s) | |
Create a text stream, initializing the buffer with string s. More... | |
Public Destructor Index
~TextStream () | |
Writes any data that is buffered to the attached std::ostream. More... | |
Public Operators Index
TextStream & | operator<< (char c) |
Adds a character to the stream. More... | |
TextStream & | operator<< (unsigned char c) |
Adds an unsigned character to the stream. More... | |
TextStream & | operator<< (unsigned char *s) |
Adds an unsigned character string to the stream. More... | |
TextStream & | operator<< (const char *s) |
Adds a C-style string to the stream. More... | |
TextStream & | operator<< (const QCString &s) |
TextStream & | operator<< (const std::string &s) |
Adds a std::string to the stream. More... | |
TextStream & | operator<< (signed short i) |
Adds a signed short integer to the stream. More... | |
TextStream & | operator<< (unsigned short i) |
Adds a unsigned short integer to the stream. More... | |
TextStream & | operator<< (signed int i) |
Adds a signed integer to the stream. More... | |
TextStream & | operator<< (unsigned int i) |
Adds a unsigned integer to the stream. More... | |
template < ... > | |
TextStream & | operator<< (T i) |
Adds a size_t integer to the stream. More... | |
TextStream & | operator<< (float f) |
Adds a float to the stream. More... | |
TextStream & | operator<< (double d) |
Adds a double to the stream. More... | |
Public Member Functions Index
void | setStream (std::ostream *s) |
Sets or changes the std::ostream to write to. More... | |
void | setFile (FILE *f) |
std::ostream * | stream () const |
Returns the attached std::ostream object. More... | |
FILE * | file () const |
void | write (const char *buf, size_t len) |
Adds a array of character to the stream. More... | |
void | flush () |
Flushes the buffer. More... | |
void | clear () |
Clears any buffered data. More... | |
std::string | str () const |
Return the contents of the buffer as a std::string object. More... | |
void | str (const std::string &s) |
Sets the buffer's contents to string s. More... | |
void | str (const char *s) |
Sets the buffer's contents to string s Any data already in the buffer will be flushed. More... | |
bool | empty () const |
Returns true iff the buffer is empty. More... | |
Private Member Functions Index
void | output_int32 (uint32_t n, bool neg) |
Writes a string representation of an integer to the buffer. More... | |
void | output_double (double d) |
Private Member Attributes Index
std::string | m_buffer |
std::ostream * | m_s = nullptr |
FILE * | m_f = nullptr |
Private Static Attributes Index
static const int | INITIAL_CAPACITY = 4096 |
Description
Text streaming class that buffers data.
Simpler version of std::ostringstream that has much better performance.
Definition at line 35 of file textstream.h.
Public Constructors
TextStream()
| inline explicit |
Creates an empty stream object.
Definition at line 41 of file textstream.h.
References INITIAL_CAPACITY and m_buffer.
Referenced by operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<< and operator<<.
TextStream()
| inline explicit |
Create a text stream object for writing to a std::ostream.
data is buffered until flush() is called or the object is destroyed.
Definition at line 48 of file textstream.h.
References INITIAL_CAPACITY, m_buffer and m_s.
TextStream()
| inline explicit |
Create a text stream, initializing the buffer with string s.
Definition at line 54 of file textstream.h.
References INITIAL_CAPACITY and m_buffer.
Public Destructor
~TextStream()
| inline |
Writes any data that is buffered to the attached std::ostream.
Definition at line 60 of file textstream.h.
Reference flush.
Public Operators
operator<<()
| inline |
Adds a character to the stream.
Definition at line 95 of file textstream.h.
References m_buffer and TextStream.
operator<<()
| inline |
Adds an unsigned character to the stream.
Definition at line 101 of file textstream.h.
References m_buffer and TextStream.
operator<<()
| inline |
Adds an unsigned character string to the stream.
Definition at line 108 of file textstream.h.
References m_buffer and TextStream.
operator<<()
| inline |
Adds a C-style string to the stream.
Definition at line 123 of file textstream.h.
References m_buffer and TextStream.
operator<<()
| inline |
Adds a QCString to the stream.
Definition at line 130 of file textstream.h.
References m_buffer, QCString::str and TextStream.
operator<<()
| inline |
Adds a std::string to the stream.
Definition at line 137 of file textstream.h.
References m_buffer and TextStream.
operator<<()
| inline |
Adds a signed short integer to the stream.
Definition at line 144 of file textstream.h.
References output_int32 and TextStream.
operator<<()
| inline |
Adds a unsigned short integer to the stream.
Definition at line 151 of file textstream.h.
References output_int32 and TextStream.
operator<<()
| inline |
Adds a signed integer to the stream.
Definition at line 158 of file textstream.h.
References output_int32 and TextStream.
operator<<()
| inline |
Adds a unsigned integer to the stream.
Definition at line 165 of file textstream.h.
References output_int32 and TextStream.
operator<<()
| inline |
Adds a size_t integer to the stream.
We use SFINAE to avoid a compiler error in case size_t already matches the 'unsigned int' overload.
Definition at line 177 of file textstream.h.
References output_int32 and TextStream.
operator<<()
| inline |
Adds a float to the stream.
Definition at line 184 of file textstream.h.
References output_double and TextStream.
operator<<()
| inline |
Adds a double to the stream.
Definition at line 191 of file textstream.h.
References output_double and TextStream.
Public Member Functions
clear()
| inline |
empty()
| inline |
Returns true iff the buffer is empty.
Definition at line 253 of file textstream.h.
Reference m_buffer.
Referenced by HtmlGenerator::endClassDiagram, insertMapFile, DotFilePatcher::run and writeDotImageMapFromFile.
file()
| inline |
Definition at line 89 of file textstream.h.
Reference m_f.
flush()
| inline |
Flushes the buffer.
If a std::ostream is attached, the buffer's contents will be written to the stream.
Definition at line 209 of file textstream.h.
References m_buffer, m_f and m_s.
Referenced by Qhp::addContentsItem, FormulaManager::createLatexFile, RTFGenerator::preProcessFileInplace, DotFilePatcher::run, setFile, setStream, str, str, FlowChart::writeFlowChart and ~TextStream.
setFile()
| inline |
setStream()
| inline |
Sets or changes the std::ostream to write to.
Any data already buffered will be flushed.
Definition at line 67 of file textstream.h.
References flush, m_f, m_s and setStream.
Referenced by Qhp::addContentsItem, DotFilePatcher::run and setStream.
str()
| inline |
Return the contents of the buffer as a std::string object.
Definition at line 229 of file textstream.h.
Reference m_buffer.
Referenced by addConceptToContext, addMemberDocs, addVariableToClass, addVariableToFile, DotGraph::computeGraph, DotDirDeps::computeTheGraph, DotGfxHierarchyTable::computeTheGraph, DotGroupCollaboration::computeTheGraph, DotLegendGraph::computeTheGraph, convertToLaTeX, HtmlGenerator::endClassDiagram, Entry::Entry, generateHtmlOutput, getMscImageMapFromFile, getSearchBox, getSQLDocBlock, insertMapFile, latexEscapeIndexChars, latexEscapeLabelName, latexEscapePDFString, latexFilterURL, HtmlDocVisitor::operator(), parseCommentAsHtml, parseCommentAsText, DotFilePatcher::run, stripIndentation, substituteLatexKeywords, templateSpec, SearchTerm::termEncoded, writeAnnotatedIndexGeneric, writeConceptIndex, ConceptDefImpl::writeDefinition, writeDotImageMapFromFile, writeFileIndex, writeHierarchicalExceptionIndex, writeHierarchicalIndex, writeHierarchicalInterfaceIndex, writeModuleIndex, writeNamespaceIndex, writePageIndex and writeTopicIndex.
str()
| inline |
str()
| inline |
stream()
| inline |
Returns the attached std::ostream object.
- See Also
Definition at line 84 of file textstream.h.
Reference m_s.
write()
| inline |
Adds a array of character to the stream.
- Parameters
-
buf the character buffer
len the number of characters in the buffer to write
Definition at line 201 of file textstream.h.
Reference m_buffer.
Referenced by generateXML and writeUTF8Char.
Private Member Functions
output_double()
| inline |
Definition at line 276 of file textstream.h.
Reference m_buffer.
Referenced by operator<< and operator<<.
output_int32()
| inline |
Writes a string representation of an integer to the buffer.
- Parameters
-
n the absolute value of the integer
neg indicates if the integer is negative
Definition at line 263 of file textstream.h.
Reference m_buffer.
Referenced by operator<<, operator<<, operator<<, operator<< and operator<<.
Private Member Attributes
m_buffer
|
Definition at line 282 of file textstream.h.
Referenced by clear, empty, flush, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, output_double, output_int32, str, str, str, TextStream, TextStream, TextStream and write.
m_f
|
m_s
|
Definition at line 283 of file textstream.h.
Referenced by flush, setFile, setStream, stream and TextStream.
Private Static Attributes
INITIAL_CAPACITY
| static |
Definition at line 37 of file textstream.h.
Referenced by TextStream, TextStream and TextStream.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus by Doxygen 1.14.0.