|
CeresEngine 0.2.0
A game development framework
|
#include <CeresEngine/Foundation/CodeWriter.hpp>
Classes | |
| struct | AlignedLine |
| struct | AlignedLineQueue |
| struct | Options |
| struct | ScopeOptions |
| struct | ScopeState |
| struct | SeparatedList |
Public Types | |
| using | WriterFunctor = FunctionView< void() const > |
Public Member Functions | |
| CodeWriter () | |
| CodeWriter (std::ostream &stream) | |
| void | setOutputStream (std::ostream &stream) |
| Throws std::runtime_error If stream is invalid. | |
| void | pushOptions (const Options &options) |
| void | popOptions () |
| void | beginSeparatedList (String separator=", ") |
| Begins a new separated list. | |
| void | endSeparatedList () |
| Ends a separated list. | |
| void | separator () |
Prints the separator, as indicated on the beginSeparatedList call. | |
| void | beginAlignedLines () |
| void | endAlignedLines () |
| void | alignLine () |
| Inserts spaces to align with the previous groups if line alignment formatting is currently enabled. | |
| void | beginLine () |
| Begins a new line and inserts the current indentation. | |
| void | endLine () |
| Ends the current line and inserts the new-line character to the output stream. | |
| void | write (const StringView &text) |
Writes the given text to the writer stream. | |
| template<typename... Args> | |
| void | write (const StringView &text1, const StringView &text2, const Args &... rest) |
| Writes the given strings to the writer stream. | |
| void | writeLine (const StringView &text) |
| Shortcut for: beginLine(), write(text), endLine(). | |
| void | writeJoined (String separator, const InitializerList< WriterFunctor > &functors) |
Writes multiple entries joined by separator. | |
| void | beginScope (bool compact=false, bool endWithSemicolon=false, bool useBraces=true) |
| Begins a new scope with the '{' character and adds a new line either before or after this character. | |
| void | endScope () |
| Ends the current scope with the '}' character. | |
| void | continueScope () |
| Continues the previously ended scope. | |
| bool | isOpenLine () const |
| Returns true if the code writer is currently in an open line (i.e. beginLine was called without closing endLine). | |
Public Member Functions inherited from CeresEngine::IndentHandler | |
| IndentHandler (const String &initialIndent=" ") | |
| virtual | ~IndentHandler () |
| void | setIndent (const String &indent) |
| Sets the next indentation string. By default two spaces. | |
| void | incrementIndent () |
| Increments the indentation. | |
| void | decrementIndent () |
| Decrements the indentation. | |
| const String & | getFullIndent () const |
| Returns the current full indentation string. | |
Public Attributes | |
| bool | newLineOpenScope = false |
Private Member Functions | |
| void | writeSeparatorIfPending () |
| const Options & | getCurrentOptions () const |
| void | flushSeparatedLines (AlignedLineQueue &lineQueue) |
| std::ostream & | getOutputStream () |
Private Attributes | |
| std::ostream * | mStream = nullptr |
| Stack< Options > | mOptionsStack |
| bool | mOpenLine = true |
| UInt32 | mLineAlignmentLevel = 0 |
| AlignedLineQueue | mQueuedAlignedLines |
| ScopeState | mScopeState |
| Stack< ScopeOptions > | mScopeOptionStack |
| Stack< SeparatedList > | mSeparatedLists |
| CeresEngine::CodeWriter::CodeWriter | ( | ) |
|
explicit |
| void CeresEngine::CodeWriter::alignLine | ( | ) |
Inserts spaces to align with the previous groups if line alignment formatting is currently enabled.
| void CeresEngine::CodeWriter::beginAlignedLines | ( | ) |
| void CeresEngine::CodeWriter::beginLine | ( | ) |
Begins a new line and inserts the current indentation.
| void CeresEngine::CodeWriter::beginScope | ( | bool | compact = false, |
| bool | endWithSemicolon = false, |
||
| bool | useBraces = true |
||
| ) |
Begins a new scope with the '{' character and adds a new line either before or after this character.
Begins a new separated list.
While enabled separator will be printed everytime separator() is called, unless it's the last call before endSeparatedList.
| separator | A separator to used to join items. |
| void CeresEngine::CodeWriter::continueScope | ( | ) |
Continues the previously ended scope.
| void CeresEngine::CodeWriter::endAlignedLines | ( | ) |
| void CeresEngine::CodeWriter::endLine | ( | ) |
Ends the current line and inserts the new-line character to the output stream.
| void CeresEngine::CodeWriter::endScope | ( | ) |
Ends the current scope with the '}' character.
If next command is not "continueScope", the line wil be ended first.
| void CeresEngine::CodeWriter::endSeparatedList | ( | ) |
Ends a separated list.
|
private |
|
inlineprivate |
|
inline |
Returns true if the code writer is currently in an open line (i.e. beginLine was called without closing endLine).
| void CeresEngine::CodeWriter::popOptions | ( | ) |
| void CeresEngine::CodeWriter::separator | ( | ) |
Prints the separator, as indicated on the beginSeparatedList call.
| void CeresEngine::CodeWriter::setOutputStream | ( | std::ostream & | stream | ) |
Throws std::runtime_error If stream is invalid.
| void CeresEngine::CodeWriter::write | ( | const StringView & | text | ) |
Writes the given text to the writer stream.
|
inline |
Writes the given strings to the writer stream.
| void CeresEngine::CodeWriter::writeJoined | ( | String | separator, |
| const InitializerList< WriterFunctor > & | functors | ||
| ) |
Writes multiple entries joined by separator.
| separator | The separator to be used when joining the multiple writes. |
| functors | The functors to be called for writing entries. If a functor doesn't write anything, no separator will be written as well. |
| void CeresEngine::CodeWriter::writeLine | ( | const StringView & | text | ) |
Shortcut for: beginLine(), write(text), endLine().
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |