astyle::ASFormatter Class Reference
#include <astyle.h>
Inheritance diagram for astyle::ASFormatter:


Public Member Functions | |
ASFormatter () | |
Constructor of ASFormatter. | |
virtual | ~ASFormatter () |
Destructor of ASFormatter. | |
virtual void | init (ASSourceIterator *iter) |
initialize the ASFormatter. | |
virtual bool | hasMoreLines () const |
check if there are any indented lines ready to be read by nextLine() | |
virtual string | nextLine () |
get the next formatted line. | |
void | setBracketFormatMode (BracketMode mode) |
set the bracket formatting mode. | |
void | setBreakClosingHeaderBracketsMode (bool state) |
set closing header bracket breaking mode options: true brackets just before closing headers (e.g. | |
void | setOperatorPaddingMode (bool mode) |
set operator padding mode. | |
void | setParenthesisPaddingMode (bool mode) |
set parentheies padding mode. | |
void | setBreakOneLineBlocksMode (bool state) |
set option to break/not break one-line blocks | |
void | setSingleStatementsMode (bool state) |
set option to break/not break lines consisting of multiple statements. | |
void | setTabSpaceConversionMode (bool state) |
set option to convert tabs to spaces. | |
void | setBreakBlocksMode (bool state) |
set option to break unrelated blocks of code with empty lines. | |
void | setBreakClosingHeaderBlocksMode (bool state) |
set option to break closing header blocks of code (such as 'else', 'catch', ...) with empty lines. | |
void | setBreakElseIfsMode (bool state) |
set 'else if()' breaking mode options: true 'else' headers will be broken from their succeeding 'if' headers. | |
Private Member Functions | |
void | ASformatter (ASFormatter ©) |
void | operator= (ASFormatter &) |
void | staticInit () |
initialization of static data of ASFormatter. | |
bool | isFormattingEnabled () const |
check if formatting options are enabled, in addition to indentation. | |
void | goForward (int i) |
jump over several characters. | |
bool | getNextChar () |
get the next character, increasing the current placement in the process. | |
char | peekNextChar () const |
peek at the next unread character. | |
bool | isBeforeComment () const |
check if current placement is before a comment or line-comment | |
void | trimNewLine () |
jump over the leading white space in the current line, IF the line does not begin a comment or is in a preprocessor definition. | |
BracketType | getBracketType () const |
check if the currently reached open-bracket (i.e. | |
bool | isPointerOrReference () const |
check if the currently reached '*' or '&' character is a pointer-or-reference symbol, or another operator. | |
bool | isUnaryMinus () const |
check if the currently reached '-' character is a unary minus this method takes for granted that the current character is a '-'. | |
bool | isInExponent () const |
check if the currently reached '-' or '+' character is part of an exponent, i.e. | |
bool | isOneLineBlockReached () const |
check if a one-line bracket has been reached, i.e. | |
void | appendChar (char ch, bool canBreakLine=true) |
append a character to the current formatted line. | |
void | appendCurrentChar (bool canBreakLine=true) |
append the CURRENT character (curentChar)to the current formatted line. | |
void | appendSequence (const string &sequence, bool canBreakLine=true) |
append a string sequence to the current formatted line. | |
void | appendSpacePad () |
append a space to the current formattedline, UNLESS the last character is already a white-space character. | |
void | breakLine () |
register a line break for the formatted line. | |
bool | isSequenceReached (const string &sequence) const |
check if a specific sequence exists in the current placement of the current line | |
const string * | findHeader (const vector< const string * > &headers, bool checkBoundry=true) |
check if one of a set of headers has been reached in the current position of the current line. | |
Private Attributes | |
ASSourceIterator * | sourceIterator |
vector< const string * > * | preBracketHeaderStack |
vector< BracketType > * | bracketTypeStack |
vector< int > * | parenStack |
string | readyFormattedLine |
string | currentLine |
string | formattedLine |
const string * | currentHeader |
const string * | previousOperator |
char | currentChar |
char | previousChar |
char | previousNonWSChar |
char | previousCommandChar |
char | quoteChar |
int | charNum |
BracketMode | bracketFormatMode |
bool | isVirgin |
bool | shouldPadOperators |
bool | shouldPadParenthesies |
bool | shouldConvertTabs |
bool | isInLineComment |
bool | isInComment |
bool | isInPreprocessor |
bool | isInTemplate |
bool | doesLineStartComment |
bool | isInQuote |
bool | isSpecialChar |
bool | isNonParenHeader |
bool | foundQuestionMark |
bool | foundPreDefinitionHeader |
bool | foundPreCommandHeader |
bool | isInLineBreak |
bool | isInClosingBracketLineBreak |
bool | endOfCodeReached |
bool | isLineReady |
bool | isPreviousBracketBlockRelated |
bool | isInPotentialCalculation |
bool | shouldBreakOneLineBlocks |
bool | shouldReparseCurrentChar |
bool | shouldBreakOneLineStatements |
bool | shouldBreakLineAfterComments |
bool | shouldBreakClosingHeaderBrackets |
bool | shouldBreakElseIfs |
bool | passedSemicolon |
bool | passedColon |
bool | isImmediatelyPostComment |
bool | isImmediatelyPostLineComment |
bool | isImmediatelyPostEmptyBlock |
bool | shouldBreakBlocks |
bool | shouldBreakClosingHeaderBlocks |
bool | isPrependPostBlockEmptyLineRequested |
bool | isAppendPostBlockEmptyLineRequested |
bool | prependEmptyLine |
bool | foundClosingHeader |
int | previousReadyFormattedLineLength |
bool | isInHeader |
bool | isImmediatelyPostHeader |
Static Private Attributes | |
vector< const string * > | headers |
vector< const string * > | nonParenHeaders |
vector< const string * > | preprocessorHeaders |
vector< const string * > | preDefinitionHeaders |
vector< const string * > | preCommandHeaders |
vector< const string * > | operators |
vector< const string * > | assignmentOperators |
bool | calledInitStatic = false |
Constructor & Destructor Documentation
|
Constructor of ASFormatter.
Definition at line 61 of file ASFormatter.cpp. References bracketFormatMode, bracketTypeStack, parenStack, preBracketHeaderStack, shouldBreakBlocks, shouldBreakClosingHeaderBlocks, shouldBreakClosingHeaderBrackets, shouldBreakElseIfs, shouldBreakOneLineBlocks, shouldBreakOneLineStatements, shouldConvertTabs, shouldPadOperators, shouldPadParenthesies, sourceIterator, and staticInit(). |
|
Destructor of ASFormatter.
Definition at line 84 of file ASFormatter.cpp. References DELETE_CONTAINER, and preBracketHeaderStack. |
Member Function Documentation
|
append a character to the current formatted line. Unless disabled (via canBreakLine == false), first check if a line-break has been registered, and if so break the formatted line, and only then append the character into the next formatted line.
Definition at line 1202 of file ASFormatter.cpp. References breakLine(), and formattedLine. Referenced by appendCurrentChar(). |
|
append the CURRENT character (curentChar)to the current formatted line. Unless disabled (via canBreakLine == false), first check if a line-break has been registered, and if so break the formatted line, and only then append the character into the next formatted line.
Definition at line 1217 of file ASFormatter.cpp. References appendChar(), and currentChar. Referenced by nextLine(). |
|
append a string sequence to the current formatted line. Unless disabled (via canBreakLine == false), first check if a line-break has been registered, and if so break the formatted line, and only then append the sequence into the next formatted line.
Definition at line 1231 of file ASFormatter.cpp. References breakLine(), and formattedLine. Referenced by nextLine(). |
|
append a space to the current formattedline, UNLESS the last character is already a white-space character.
Definition at line 1241 of file ASFormatter.cpp. References formattedLine, astyle::ASBeautifier::isWhiteSpace(), and len. Referenced by nextLine(). |
|
|
|
register a line break for the formatted line.
Definition at line 1250 of file ASFormatter.cpp. References formattedLine, isAppendPostBlockEmptyLineRequested, isInLineBreak, isLineReady, isPrependPostBlockEmptyLineRequested, prependEmptyLine, and readyFormattedLine. Referenced by appendChar(), appendSequence(), and nextLine(). |
|
check if one of a set of headers has been reached in the current position of the current line.
Definition at line 1443 of file ASFormatter.cpp. References charNum, and currentLine. Referenced by nextLine(). |
|
check if the currently reached open-bracket (i.e. '{') opens a:
Definition at line 1279 of file ASFormatter.cpp. References BracketType, COMMAND_TYPE, currentHeader, foundPreCommandHeader, isOneLineBlockReached(), and previousCommandChar. Referenced by nextLine(). |
|
get the next character, increasing the current placement in the process. the new character is inserted into the variable currentChar.
Definition at line 1101 of file ASFormatter.cpp. References charNum, currentChar, currentLine, doesLineStartComment, endOfCodeReached, formattedLine, astyle::ASSourceIterator::hasMoreLines(), isBeforeComment(), isImmediatelyPostLineComment, isInComment, isInLineBreak, isInLineComment, isInPreprocessor, isInQuote, isSequenceReached(), isVirgin, astyle::ASBeautifier::isWhiteSpace(), len, astyle::ASSourceIterator::nextLine(), peekNextChar(), previousChar, previousCommandChar, previousNonWSChar, shouldConvertTabs, shouldPadOperators, sourceIterator, and trimNewLine(). Referenced by goForward(), and nextLine(). |
|
jump over several characters.
Definition at line 1045 of file ASFormatter.cpp. References getNextChar(). Referenced by nextLine(). |
|
check if there are any indented lines ready to be read by nextLine()
Reimplemented from astyle::ASBeautifier. Definition at line 903 of file ASFormatter.cpp. References isFormattingEnabled(). Referenced by AStylePart::beautifySource(), and AStylePart::formatSource(). |
|
|
check if current placement is before a comment or line-comment
Definition at line 1077 of file ASFormatter.cpp. References charNum, currentLine, astyle::ASBeautifier::isWhiteSpace(), and len. Referenced by getNextChar(). |
|
check if formatting options are enabled, in addition to indentation.
Definition at line 915 of file ASFormatter.cpp. References bracketFormatMode, NONE_MODE, and shouldPadOperators. Referenced by hasMoreLines(), and nextLine(). |
|
check if the currently reached '-' or '+' character is part of an exponent, i.e. 0.2E-5. this method takes for granted that the current character is a '-' or '+'.
Definition at line 1357 of file ASFormatter.cpp. References formattedLine. Referenced by nextLine(). |
|
check if a one-line bracket has been reached, i.e. if the currently reached '{' character is closed with a complimentry '}' elsewhere on the current line.
Definition at line 1376 of file ASFormatter.cpp. References charNum, currentLine, isInComment, isInQuote, and quoteChar. Referenced by getBracketType(). |
|
check if the currently reached '*' or '&' character is a pointer-or-reference symbol, or another operator. this method takes for granted that the current character is either a '*' or '&'.
Definition at line 1311 of file ASFormatter.cpp. References bracketTypeStack, IS_A, isInPotentialCalculation, astyle::ASBeautifier::isLegalNameChar(), astyle::ASBeautifier::isWhiteSpace(), peekNextChar(), and previousNonWSChar. Referenced by nextLine(). |
|
check if a specific sequence exists in the current placement of the current line
Definition at line 1035 of file ASFormatter.cpp. References charNum, and currentLine. Referenced by getNextChar(), nextLine(), and trimNewLine(). |
|
check if the currently reached '-' character is a unary minus this method takes for granted that the current character is a '-'.
Definition at line 1341 of file ASFormatter.cpp. References previousCommandChar, and previousOperator. Referenced by nextLine(). |
|
get the next formatted line.
Reimplemented from astyle::ASBeautifier. Definition at line 284 of file ASFormatter.cpp. References appendCurrentChar(), appendSequence(), appendSpacePad(), ARRAY_TYPE, assignmentOperators, ATTACH_MODE, BDAC_MODE, astyle::ASBeautifier::beautify(), bracketFormatMode, BracketType, bracketTypeStack, BREAK_MODE, breakLine(), charNum, currentChar, currentHeader, currentLine, findHeader(), foundClosingHeader, foundPreCommandHeader, foundPreDefinitionHeader, foundQuestionMark, getBracketType(), getNextChar(), goForward(), headers, IS_A, isAppendPostBlockEmptyLineRequested, isFormattingEnabled(), isImmediatelyPostComment, isImmediatelyPostEmptyBlock, isImmediatelyPostHeader, isImmediatelyPostLineComment, isInComment, isInExponent(), isInHeader, isInLineBreak, isInLineComment, isInPotentialCalculation, isInPreprocessor, isInQuote, isInTemplate, astyle::ASBeautifier::isLegalNameChar(), isLineReady, isNonParenHeader, isPointerOrReference(), isPrependPostBlockEmptyLineRequested, isPreviousBracketBlockRelated, isSequenceReached(), isSpecialChar, isUnaryMinus(), astyle::ASBeautifier::isWhiteSpace(), nonParenHeaders, operators, parenStack, passedColon, passedSemicolon, peekNextChar(), preBracketHeaderStack, preCommandHeaders, preDefinitionHeaders, prependEmptyLine, previousChar, previousCommandChar, previousNonWSChar, previousOperator, previousReadyFormattedLineLength, quoteChar, readyFormattedLine, shouldBreakBlocks, shouldBreakClosingHeaderBlocks, shouldBreakClosingHeaderBrackets, shouldBreakLineAfterComments, shouldBreakOneLineBlocks, shouldBreakOneLineStatements, shouldPadOperators, shouldReparseCurrentChar, SINGLE_LINE_TYPE, and astyle::ASBeautifier::trim(). Referenced by AStylePart::beautifySource(), and AStylePart::formatSource(). |
|
|
|
peek at the next unread character.
Definition at line 1055 of file ASFormatter.cpp. References charNum, currentLine, astyle::ASBeautifier::isWhiteSpace(), len, and shouldConvertTabs. Referenced by getNextChar(), isPointerOrReference(), and nextLine(). |
|
set the bracket formatting mode. options: astyle::NONE_MODE no formatting of brackets. astyle::ATTACH_MODE Java, K&R style bracket placement. astyle::BREAK_MODE ANSI C/C++ style bracket placement.
Definition at line 930 of file ASFormatter.cpp. References bracketFormatMode. Referenced by KDevFormatter::KDevFormatter(). |
|
set option to break unrelated blocks of code with empty lines.
Definition at line 1016 of file ASFormatter.cpp. References shouldBreakBlocks. |
|
set option to break closing header blocks of code (such as 'else', 'catch', ...) with empty lines.
Definition at line 1025 of file ASFormatter.cpp. References shouldBreakClosingHeaderBlocks. |
|
set closing header bracket breaking mode options: true brackets just before closing headers (e.g. 'else', 'catch') will be broken, even if standard brackets are attached. false closing header brackets will be treated as standard brackets.
Definition at line 943 of file ASFormatter.cpp. References shouldBreakClosingHeaderBrackets. |
|
set 'else if()' breaking mode options: true 'else' headers will be broken from their succeeding 'if' headers. false 'else' headers will be attached to their succeeding 'if' headers.
Definition at line 955 of file ASFormatter.cpp. References shouldBreakElseIfs. |
|
set option to break/not break one-line blocks
Definition at line 988 of file ASFormatter.cpp. References shouldBreakOneLineBlocks. Referenced by KDevFormatter::KDevFormatter(). |
|
set operator padding mode. options: true statement operators will be padded with spaces around them. false statement operators will not be padded.
Definition at line 967 of file ASFormatter.cpp. References shouldPadOperators. Referenced by KDevFormatter::KDevFormatter(). |
|
set parentheies padding mode. options: true statement parenthesies will be padded with spaces around them. false statement parenthesies will not be padded.
Definition at line 979 of file ASFormatter.cpp. References shouldPadParenthesies. Referenced by KDevFormatter::KDevFormatter(). |
|
set option to break/not break lines consisting of multiple statements.
Definition at line 997 of file ASFormatter.cpp. References shouldBreakOneLineStatements. Referenced by KDevFormatter::KDevFormatter(). |
|
set option to convert tabs to spaces.
Definition at line 1006 of file ASFormatter.cpp. References shouldConvertTabs. |
|
initialization of static data of ASFormatter.
Definition at line 91 of file ASFormatter.cpp. References assignmentOperators, calledInitStatic, headers, nonParenHeaders, preCommandHeaders, preDefinitionHeaders, and preprocessorHeaders. Referenced by ASFormatter(). |
|
jump over the leading white space in the current line, IF the line does not begin a comment or is in a preprocessor definition.
Definition at line 1175 of file ASFormatter.cpp. References charNum, currentLine, doesLineStartComment, isInComment, isSequenceReached(), astyle::ASBeautifier::isWhiteSpace(), and len. Referenced by getNextChar(). |
Member Data Documentation
|
Reimplemented from astyle::ASBeautifier. Definition at line 56 of file ASFormatter.cpp. Referenced by nextLine(), and staticInit(). |
|
Definition at line 277 of file astyle.h. Referenced by ASFormatter(), isFormattingEnabled(), nextLine(), and setBracketFormatMode(). |
|
Definition at line 264 of file astyle.h. Referenced by ASFormatter(), init(), isPointerOrReference(), and nextLine(). |
|
Reimplemented from astyle::ASBeautifier. Definition at line 49 of file ASFormatter.cpp. Referenced by staticInit(). |
|
Definition at line 276 of file astyle.h. Referenced by findHeader(), getNextChar(), init(), isBeforeComment(), isOneLineBlockReached(), isSequenceReached(), nextLine(), peekNextChar(), and trimNewLine(). |
|
Definition at line 271 of file astyle.h. Referenced by appendCurrentChar(), getNextChar(), init(), and nextLine(). |
|
Reimplemented from astyle::ASBeautifier. Definition at line 269 of file astyle.h. Referenced by getBracketType(), init(), and nextLine(). |
|
Definition at line 267 of file astyle.h. Referenced by findHeader(), getNextChar(), init(), isBeforeComment(), isOneLineBlockReached(), isSequenceReached(), nextLine(), peekNextChar(), and trimNewLine(). |
|
Definition at line 286 of file astyle.h. Referenced by getNextChar(), init(), and trimNewLine(). |
|
Definition at line 295 of file astyle.h. Referenced by getNextChar(), and init(). |
|
Definition at line 268 of file astyle.h. Referenced by appendChar(), appendSequence(), appendSpacePad(), breakLine(), getNextChar(), init(), and isInExponent(). |
|
Definition at line 318 of file astyle.h. Referenced by init(), and nextLine(). |
|
Definition at line 292 of file astyle.h. Referenced by getBracketType(), init(), and nextLine(). |
|
Definition at line 291 of file astyle.h. Referenced by init(), and nextLine(). |
|
Definition at line 290 of file astyle.h. Referenced by init(), and nextLine(). |
|
Reimplemented from astyle::ASBeautifier. Definition at line 50 of file ASFormatter.cpp. Referenced by nextLine(), and staticInit(). |
|
Definition at line 315 of file astyle.h. Referenced by breakLine(), init(), and nextLine(). |
|
Definition at line 308 of file astyle.h. Referenced by init(), and nextLine(). |
|
Definition at line 310 of file astyle.h. Referenced by init(), and nextLine(). |
|
Definition at line 322 of file astyle.h. Referenced by init(), and nextLine(). |
|
Definition at line 309 of file astyle.h. Referenced by getNextChar(), init(), and nextLine(). |
|
|
|
Reimplemented from astyle::ASBeautifier. Definition at line 283 of file astyle.h. Referenced by getNextChar(), init(), isOneLineBlockReached(), nextLine(), and trimNewLine(). |
|
Reimplemented from astyle::ASBeautifier. Definition at line 321 of file astyle.h. Referenced by init(), and nextLine(). |
|
Definition at line 293 of file astyle.h. Referenced by breakLine(), getNextChar(), init(), and nextLine(). |
|
Definition at line 282 of file astyle.h. Referenced by getNextChar(), init(), and nextLine(). |
|
Definition at line 298 of file astyle.h. Referenced by init(), isPointerOrReference(), and nextLine(). |
|
Definition at line 284 of file astyle.h. Referenced by getNextChar(), init(), and nextLine(). |
|
Reimplemented from astyle::ASBeautifier. Definition at line 287 of file astyle.h. Referenced by getNextChar(), init(), isOneLineBlockReached(), and nextLine(). |
|
Reimplemented from astyle::ASBeautifier. Definition at line 285 of file astyle.h. Referenced by init(), and nextLine(). |
|
Definition at line 296 of file astyle.h. Referenced by breakLine(), init(), and nextLine(). |
|
Definition at line 289 of file astyle.h. Referenced by init(), and nextLine(). |
|
Definition at line 314 of file astyle.h. Referenced by breakLine(), init(), and nextLine(). |
|
Definition at line 297 of file astyle.h. Referenced by init(), and nextLine(). |
|
Definition at line 288 of file astyle.h. Referenced by init(), and nextLine(). |
|
Definition at line 278 of file astyle.h. Referenced by getNextChar(), and init(). |
|
Reimplemented from astyle::ASBeautifier. Definition at line 51 of file ASFormatter.cpp. Referenced by nextLine(), and staticInit(). |
|
Definition at line 55 of file ASFormatter.cpp. Referenced by nextLine(). |
|
Definition at line 265 of file astyle.h. Referenced by ASFormatter(), init(), and nextLine(). |
|
Definition at line 307 of file astyle.h. Referenced by init(), and nextLine(). |
|
Definition at line 306 of file astyle.h. Referenced by init(), and nextLine(). |
|
Definition at line 263 of file astyle.h. Referenced by ASFormatter(), init(), nextLine(), and ~ASFormatter(). |
|
Definition at line 54 of file ASFormatter.cpp. Referenced by nextLine(), and staticInit(). |
|
Definition at line 53 of file ASFormatter.cpp. Referenced by nextLine(), and staticInit(). |
|
Definition at line 317 of file astyle.h. Referenced by breakLine(), init(), and nextLine(). |
|
Reimplemented from astyle::ASBeautifier. Definition at line 52 of file ASFormatter.cpp. Referenced by staticInit(). |
|
Definition at line 272 of file astyle.h. Referenced by getNextChar(), and nextLine(). |
|
Definition at line 274 of file astyle.h. Referenced by getBracketType(), getNextChar(), init(), isUnaryMinus(), and nextLine(). |
|
Definition at line 273 of file astyle.h. Referenced by getNextChar(), init(), isPointerOrReference(), and nextLine(). |
|
Definition at line 270 of file astyle.h. Referenced by init(), isUnaryMinus(), and nextLine(). |
|
Definition at line 319 of file astyle.h. Referenced by init(), and nextLine(). |
|
Reimplemented from astyle::ASBeautifier. Definition at line 275 of file astyle.h. Referenced by init(), isOneLineBlockReached(), and nextLine(). |
|
Definition at line 266 of file astyle.h. Referenced by breakLine(), and nextLine(). |
|
Definition at line 312 of file astyle.h. Referenced by ASFormatter(), nextLine(), and setBreakBlocksMode(). |
|
Definition at line 313 of file astyle.h. Referenced by ASFormatter(), nextLine(), and setBreakClosingHeaderBlocksMode(). |
|
Definition at line 304 of file astyle.h. Referenced by ASFormatter(), nextLine(), and setBreakClosingHeaderBracketsMode(). |
|
Definition at line 305 of file astyle.h. Referenced by ASFormatter(), and setBreakElseIfsMode(). |
|
Definition at line 303 of file astyle.h. Referenced by init(), and nextLine(). |
|
Definition at line 300 of file astyle.h. Referenced by ASFormatter(), nextLine(), and setBreakOneLineBlocksMode(). |
|
Definition at line 302 of file astyle.h. Referenced by ASFormatter(), nextLine(), and setSingleStatementsMode(). |
|
Definition at line 281 of file astyle.h. Referenced by ASFormatter(), getNextChar(), peekNextChar(), and setTabSpaceConversionMode(). |
|
Definition at line 279 of file astyle.h. Referenced by ASFormatter(), getNextChar(), isFormattingEnabled(), nextLine(), and setOperatorPaddingMode(). |
|
Definition at line 280 of file astyle.h. Referenced by ASFormatter(), and setParenthesisPaddingMode(). |
|
Definition at line 301 of file astyle.h. Referenced by init(), and nextLine(). |
|
Reimplemented from astyle::ASBeautifier. Definition at line 262 of file astyle.h. Referenced by ASFormatter(), getNextChar(), and init(). |
The documentation for this class was generated from the following files:
- lib/astyle/astyle.h
- lib/astyle/ASFormatter.cpp