Doxygen
|
Text streaming class that buffers data. More...
#include <src/textstream.h>
Public Member Functions | |
TextStream (size_t capacity=INITIAL_CAPACITY) | |
Creates an empty stream object. | |
TextStream (std::ostream *s) | |
Create a text stream object for writing to a std::ostream. | |
TextStream (const std::string &s) | |
Create a text stream, initializing the buffer with string s. | |
~TextStream () | |
Writes any data that is buffered to the attached std::ostream. | |
void | setStream (std::ostream *s) |
Sets or changes the std::ostream to write to. | |
void | setFile (FILE *f) |
std::ostream * | stream () const |
Returns the attached std::ostream object. | |
FILE * | file () const |
TextStream & | operator<< (char c) |
Adds a character to the stream. | |
TextStream & | operator<< (unsigned char c) |
Adds an unsigned character to the stream. | |
TextStream & | operator<< (unsigned char *s) |
Adds an unsigned character string to the stream. | |
TextStream & | operator<< (const char *s) |
Adds a C-style string to the stream. | |
TextStream & | operator<< (const QCString &s) |
Adds a QCString to the stream. | |
TextStream & | operator<< (const std::string &s) |
Adds a std::string to the stream. | |
TextStream & | operator<< (signed short i) |
Adds a signed short integer to the stream. | |
TextStream & | operator<< (unsigned short i) |
Adds a unsigned short integer to the stream. | |
TextStream & | operator<< (signed int i) |
Adds a signed integer to the stream. | |
TextStream & | operator<< (unsigned int i) |
Adds a unsigned integer to the stream. | |
template<typename T, typename std::enable_if< std::is_same< T, size_t >::value, T >::type * = nullptr> | |
TextStream & | operator<< (T i) |
Adds a size_t integer to the stream. | |
TextStream & | operator<< (float f) |
Adds a float to the stream. | |
TextStream & | operator<< (double d) |
Adds a double to the stream. | |
void | write (const char *buf, size_t len) |
Adds a array of character to the stream. | |
void | flush () |
Flushes the buffer. | |
void | clear () |
Clears any buffered data. | |
std::string | str () const |
Return the contents of the buffer as a std::string object. | |
void | str (const std::string &s) |
Sets the buffer's contents to string s. | |
void | str (const char *s) |
Sets the buffer's contents to string s Any data already in the buffer will be flushed. | |
bool | empty () const |
Returns true iff the buffer is empty. | |
Private Member Functions | |
void | output_int32 (uint32_t n, bool neg) |
Writes a string representation of an integer to the buffer. | |
void | output_double (double d) |
Private Attributes | |
std::string | m_buffer |
std::ostream * | m_s = nullptr |
FILE * | m_f = nullptr |
Static Private Attributes | |
static const int | INITIAL_CAPACITY = 4096 |
Text streaming class that buffers data.
Simpler version of std::ostringstream that has much better performance.
Definition at line 35 of file textstream.h.
|
inlineexplicit |
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<<().
|
inlineexplicit |
Create a text stream object for writing to a std::ostream.
Definition at line 48 of file textstream.h.
References INITIAL_CAPACITY, m_buffer, and m_s.
|
inlineexplicit |
Create a text stream, initializing the buffer with string s.
Definition at line 54 of file textstream.h.
References INITIAL_CAPACITY, and m_buffer.
|
inline |
Writes any data that is buffered to the attached std::ostream.
Definition at line 60 of file textstream.h.
References flush().
|
inline |
|
inline |
Returns true iff the buffer is empty.
Definition at line 253 of file textstream.h.
References m_buffer.
Referenced by HtmlGenerator::endClassDiagram(), insertMapFile(), DotFilePatcher::run(), and writeDotImageMapFromFile().
|
inline |
Definition at line 89 of file textstream.h.
References m_f.
|
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().
|
inline |
Adds a character to the stream.
Definition at line 95 of file textstream.h.
References m_buffer, and TextStream().
|
inline |
Adds a C-style string to the stream.
Definition at line 123 of file textstream.h.
References m_buffer, and TextStream().
|
inline |
Adds a QCString to the stream.
Definition at line 130 of file textstream.h.
References m_buffer, QCString::str(), and TextStream().
|
inline |
Adds a std::string to the stream.
Definition at line 137 of file textstream.h.
References m_buffer, and TextStream().
|
inline |
Adds a double to the stream.
Definition at line 191 of file textstream.h.
References output_double(), and TextStream().
|
inline |
Adds a float to the stream.
Definition at line 184 of file textstream.h.
References output_double(), and TextStream().
|
inline |
Adds a signed integer to the stream.
Definition at line 158 of file textstream.h.
References output_int32(), and TextStream().
|
inline |
Adds a signed short integer to the stream.
Definition at line 144 of file textstream.h.
References output_int32(), and TextStream().
|
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().
|
inline |
Adds an unsigned character string to the stream.
Definition at line 108 of file textstream.h.
References m_buffer, and TextStream().
|
inline |
Adds an unsigned character to the stream.
Definition at line 101 of file textstream.h.
References m_buffer, and TextStream().
|
inline |
Adds a unsigned integer to the stream.
Definition at line 165 of file textstream.h.
References output_int32(), and TextStream().
|
inline |
Adds a unsigned short integer to the stream.
Definition at line 151 of file textstream.h.
References output_int32(), and TextStream().
|
inlineprivate |
Definition at line 276 of file textstream.h.
References m_buffer.
Referenced by operator<<(), and operator<<().
|
inlineprivate |
Writes a string representation of an integer to the buffer.
n | the absolute value of the integer |
neg | indicates if the integer is negative |
Definition at line 263 of file textstream.h.
References m_buffer.
Referenced by operator<<(), operator<<(), operator<<(), operator<<(), and operator<<().
|
inline |
|
inline |
Sets or changes the std::ostream to write to.
Definition at line 67 of file textstream.h.
References flush(), m_f, m_s, and setStream().
Referenced by Qhp::addContentsItem(), DotFilePatcher::run(), and setStream().
|
inline |
Return the contents of the buffer as a std::string object.
Definition at line 229 of file textstream.h.
References 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()(), parseCommentAsText(), DotFilePatcher::run(), stripIndentation(), substituteLatexKeywords(), templateSpec(), SearchTerm::termEncoded(), writeAnnotatedIndexGeneric(), writeConceptIndex(), ConceptDefImpl::writeDefinition(), writeDotImageMapFromFile(), writeFileIndex(), writeHierarchicalExceptionIndex(), writeHierarchicalIndex(), writeHierarchicalInterfaceIndex(), writeModuleIndex(), writeNamespaceIndex(), writePageIndex(), and writeTopicIndex().
|
inline |
|
inline |
|
inline |
Returns the attached std::ostream object.
Definition at line 84 of file textstream.h.
References m_s.
|
inline |
Adds a array of character to the stream.
buf | the character buffer |
len | the number of characters in the buffer to write |
Definition at line 201 of file textstream.h.
References m_buffer.
Referenced by generateXML(), and writeUTF8Char().
|
staticprivate |
Definition at line 37 of file textstream.h.
Referenced by TextStream(), TextStream(), and TextStream().
|
private |
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().
|
private |
Definition at line 284 of file textstream.h.
Referenced by file(), flush(), setFile(), and setStream().
|
private |
Definition at line 283 of file textstream.h.
Referenced by flush(), setFile(), setStream(), stream(), and TextStream().