179 void beginScope(
bool compact =
false,
bool endWithSemicolon =
false,
bool useBraces =
true);
Definition CodeWriter.hpp:57
bool isOpenLine() const
Returns true if the code writer is currently in an open line (i.e. beginLine was called without closi...
Definition CodeWriter.hpp:189
UInt32 mLineAlignmentLevel
Definition CodeWriter.hpp:107
void continueScope()
Continues the previously ended scope.
void endScope()
Ends the current scope with the '}' character.
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 beginLine()
Begins a new line and inserts the current indentation.
const Options & getCurrentOptions() const
ScopeState mScopeState
Definition CodeWriter.hpp:110
Stack< SeparatedList > mSeparatedLists
Definition CodeWriter.hpp:113
void beginSeparatedList(String separator=", ")
Begins a new separated list.
void write(const StringView &text)
Writes the given text to the writer stream.
Stack< Options > mOptionsStack
Definition CodeWriter.hpp:104
void endLine()
Ends the current line and inserts the new-line character to the output stream.
std::ostream * mStream
Definition CodeWriter.hpp:102
std::ostream & getOutputStream()
Definition CodeWriter.hpp:199
void pushOptions(const Options &options)
void endSeparatedList()
Ends a separated list.
void write(const StringView &text1, const StringView &text2, const Args &... rest)
Writes the given strings to the writer stream.
Definition CodeWriter.hpp:160
bool newLineOpenScope
Definition CodeWriter.hpp:117
void writeJoined(String separator, const InitializerList< WriterFunctor > &functors)
Writes multiple entries joined by separator.
bool mOpenLine
Definition CodeWriter.hpp:105
void setOutputStream(std::ostream &stream)
Throws std::runtime_error If stream is invalid.
FunctionView< void() const > WriterFunctor
Definition CodeWriter.hpp:65
AlignedLineQueue mQueuedAlignedLines
Definition CodeWriter.hpp:108
void separator()
Prints the separator, as indicated on the beginSeparatedList call.
void alignLine()
Inserts spaces to align with the previous groups if line alignment formatting is currently enabled.
Stack< ScopeOptions > mScopeOptionStack
Definition CodeWriter.hpp:111
void writeSeparatorIfPending()
CodeWriter(std::ostream &stream)
void writeLine(const StringView &text)
Shortcut for: beginLine(), write(text), endLine().
void flushSeparatedLines(AlignedLineQueue &lineQueue)
Indentation handler base class.
Definition CodeWriter.hpp:23
void decrementIndent()
Decrements the indentation.
String mIndentFull
Definition CodeWriter.hpp:26
Stack< String::size_type > mIndentStack
Definition CodeWriter.hpp:27
String mIndent
Definition CodeWriter.hpp:25
void incrementIndent()
Increments the indentation.
void setIndent(const String &indent)
Sets the next indentation string. By default two spaces.
IndentHandler(const String &initialIndent=" ")
const String & getFullIndent() const
Returns the current full indentation string.
Helper class for temporary indentation.
Definition CodeWriter.hpp:47
IndentHandler & mHandler
Definition CodeWriter.hpp:49
~ScopedIndent()
Definition CodeWriter.hpp:53
ScopedIndent(IndentHandler &handler)
Definition CodeWriter.hpp:52
Definition Application.hpp:19
std::stack< T, Container > Stack
The Stack class is a container adapter that gives the programmer the functionality of a stack - speci...
Definition Stack.hpp:18
std::initializer_list< T > InitializerList
An object of type InitializerList<T> is a lightweight proxy object that provides access to an array o...
Definition InitializerList.hpp:40
BasicStringView< char > StringView
Narrow string view used for handling narrow encoded text in UTF-8.
Definition String.hpp:190
std::vector< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > Vector
Vector is a sequence container that encapsulates dynamic size arrays.
Definition Vector.hpp:17
std::list< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > List
List is a container that supports constant time insertion and removal of elements from anywhere in th...
Definition List.hpp:21
FunctionBase< false, true, fu2::capacity_default, true, false, Signatures... > FunctionView
A non owning copyable function wrapper for arbitrary callable types.
Definition Function.hpp:64
std::uint32_t UInt32
Definition DataTypes.hpp:23
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Definition CodeWriter.hpp:68
void offsets(Vector< std::size_t > &offsets) const
Vector< String > parts
Definition CodeWriter.hpp:70
String indent
Definition CodeWriter.hpp:69
AlignedLine & operator<<(const StringView &text)
Definition CodeWriter.hpp:78
List< AlignedLine > lines
Definition CodeWriter.hpp:79
Definition CodeWriter.hpp:59
bool enableNewLine
Definition CodeWriter.hpp:60
bool parseNewLines
Definition CodeWriter.hpp:62
bool enableIndent
Definition CodeWriter.hpp:61
Definition CodeWriter.hpp:91
bool compact
Definition CodeWriter.hpp:92
bool useBraces
Definition CodeWriter.hpp:94
bool endWithSemicolon
Definition CodeWriter.hpp:93
Definition CodeWriter.hpp:84
bool endLineQueued
Definition CodeWriter.hpp:88
bool scopeUsedBraces
Definition CodeWriter.hpp:86
bool scopeCanContinue
Definition CodeWriter.hpp:85
bool beginLineQueued
Definition CodeWriter.hpp:87
Definition CodeWriter.hpp:97
String separator
Definition CodeWriter.hpp:98
bool isItemPending
Definition CodeWriter.hpp:99