/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Copyright (C) 2006-2010 by Jim Pattee <jimp03@email.com>
* Copyright (C) 1998-2002 by Tal Davidson
* <http://www.gnu.org/licenses/lgpl-3.0.html>
*
* This file is a part of Artistic Style - an indentation and
* reformatting tool for C, C++, C# and Java source files.
* <http://astyle.sourceforge.net>
*
* Artistic Style is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Artistic Style is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Artistic Style. If not, see <http://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
#include "astyle.h"
#include <algorithm>
#include <fstream>
#include <iostream>
namespace astyle
{
// static member variables
int ASFormatter::formatterFileType = 9; // initialized with an invalid type
vector<const string*>* ASFormatter::headers = NULL;
vector<const string*>* ASFormatter::nonParenHeaders = NULL;
vector<const string*>* ASFormatter::preDefinitionHeaders = NULL;
vector<const string*>* ASFormatter::preCommandHeaders = NULL;
vector<const string*>* ASFormatter::operators = NULL;
vector<const string*>* ASFormatter::assignmentOperators = NULL;
vector<const string*>* ASFormatter::castOperators = NULL;
/**
* Constructor of ASFormatter
*/
ASFormatter::ASFormatter()
{
sourceIterator = NULL;
enhancer = new ASEnhancer;
preBracketHeaderStack = NULL;
bracketTypeStack = NULL;
parenStack = NULL;
structStack = NULL;
lineCommentNoIndent = false;
formattingStyle = STYLE_NONE;
bracketFormatMode = NONE_MODE;
pointerAlignment = ALIGN_NONE;
lineEnd = LINEEND_DEFAULT;
shouldPadOperators = false;
shouldPadParensOutside = false;
shouldPadParensInside = false;
shouldPadHeader = false;
shouldUnPadParens = false;
shouldBreakOneLineBlocks = true;
shouldBreakOneLineStatements = true;
shouldConvertTabs = false;
shouldIndentCol1Comments = false;
shouldBreakBlocks = false;
shouldBreakClosingHeaderBlocks = false;
shouldBreakClosingHeaderBrackets = false;
shouldDeleteEmptyLines = false;
shouldBreakElseIfs = false;
shouldAddBrackets = false;
shouldAddOneLineBrackets = false;
// initialize ASFormatter static member vectors
formatterFileType = 9; // reset to an invalid type
initVector(headers);
initVector(nonParenHeaders);
initVector(preDefinitionHeaders);
initVector(preCommandHeaders);
initVector(operators);
initVector(assignmentOperators);
initVector(castOperators);
// the following prevents warning messages with cppcheck
// it will NOT compile if activated
// init();
}
/**
* Destructor of ASFormatter
*/
ASFormatter::~ASFormatter()
{
// delete ASFormatter stack vectors
deleteContainer(preBracketHeaderStack);
deleteContainer(bracketTypeStack);
deleteContainer(parenStack);
deleteContainer(structStack);
// delete static member vectors using swap to eliminate memory leak reporting
// delete ASFormatter static member vectors
formatterFileType = 9; // reset to an invalid type
deleteVector(headers);
deleteVector(nonParenHeaders);
deleteVector(preDefinitionHeaders);
deleteVector(preCommandHeaders);
deleteVector(operators);
deleteVector(assignmentOperators);
deleteVector(castOperators);
// delete ASBeautifier static member vectors
// must be done when the ASFormatter object is deleted (not ASBeautifier)
ASBeautifier::deleteStaticVectors();
delete enhancer;
}
/**
* initialize the ASFormatter.
*
* init() should be called every time a ASFormatter object is to start
* formatting a NEW source file.
* init() recieves a pointer to a ASSourceIterator object that will be
* used to iterate through the source code.
*
* @param sourceIterator a pointer to the ASSourceIterator or ASStreamIterator object.
*/
void ASFormatter::init(ASSourceIterator *si)
{
buildLanguageVectors();
fixOptionVariableConflicts();
ASBeautifier::init(si);
enhancer->init(getFileType(),
getIndentLength(),
getIndentString(),
getCaseIndent(),
getEmptyLineFill());
sourceIterator = si;
initContainer(preBracketHeaderStack, new vector<const string*>);
initContainer(parenStack, new vector<int>);
initContainer(structStack, new vector<bool>);
parenStack->push_back(0); // parenStack must contain this default entry
initContainer(bracketTypeStack, new vector<BracketType>);
bracketTypeStack->push_back(NULL_TYPE);
currentHeader = NULL;
currentLine = "";
readyFormattedLine = "";
formattedLine = "";
currentChar = ' ';
previousChar = ' ';
previousCommandChar = ' ';
previousNonWSChar = ' ';
quoteChar = '"';
charNum = 0;
leadingSpaces = 0;
formattedLineCommentNum = 0;
preprocBracketTypeStackSize = 0;
spacePadNum = 0;
nextLineSpacePadNum = 0;
currentLineFirstBracketNum = string::npos;
previousReadyFormattedLineLength = string::npos;
templateDepth = 0;
traceLineNumber = 0;
horstmannIndentChars = 0;
tabIncrementIn = 0;
previousBracketType = NULL_TYPE;
previousOperator = NULL;
isVirgin = true;
isInLineComment = false;
isInComment = false;
noTrimCommentContinuation = false;
isInPreprocessor = false;
doesLineStartComment = false;
lineEndsInCommentOnly = false;
lineIsLineCommentOnly = false;
lineIsEmpty = false;
isImmediatelyPostCommentOnly = false;
isImmediatelyPostEmptyLine = false;
isInQuote = false;
isInVerbatimQuote = false;
haveLineContinuationChar = false;
isInQuoteContinuation = false;
isSpecialChar = false;
isNonParenHeader = false;
foundNamespaceHeader = false;
foundClassHeader = false;
foundStructHeader = false;
foundInterfaceHeader = false;
foundPreDefinitionHeader = false;
foundPreCommandHeader = false;
foundCastOperator = false;
foundQuestionMark = false;
isInLineBreak = false;
endOfCodeReached = false;
isInExecSQL = false;
isInAsm = false;
isInAsmOneLine = false;
isInAsmBlock = false;
isLineReady = false;
isPreviousBracketBlockRelated = false;
isInPotentialCalculation = false;
shouldReparseCurrentChar = false;
needHeaderOpeningBracket = false;
shouldBreakLineAtNextChar = false;
passedSemicolon = false;
passedColon = false;
clearNonInStatement = false;
isInTemplate = false;
isInBlParen = false;
isImmediatelyPostComment = false;
isImmediatelyPostLineComment = false;
isImmediatelyPostEmptyBlock = false;
isImmediatelyPostPreprocessor = false;
isImmediatelyPostReturn = false;
isImmediatelyPostOperator = false;
isCharImmediatelyPostReturn = false;
isCharImmediatelyPostOperator = false;
isCharImmediatelyPostComment = false;
isPreviousCharPostComment = false;
isCharImmediatelyPostLineComment = false;
isCharImmediatelyPostOpenBlock = false;
isCharImmediatelyPostCloseBlock = false;
isCharImmediatelyPostTemplate = false;
breakCurrentOneLineBlock = false;
isInHorstmannRunIn = false;
currentLineBeginsWithBracket = false;
isPrependPostBlockEmptyLineRequested = false;
isAppendPostBlockEmptyLineRequested = false;
prependEmptyLine = false;
appendOpeningBracket = false;
foundClosingHeader = false;
isImmediatelyPostHeader = false;
isInHeader = false;
isInCase = false;
isJavaStaticConstructor = false;
}
/**
* build vectors for each programing language
* depending on the file exte
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
这是astyle 1.24的windows下的工程文件和源代码. 内部有vs2003,2005,2008,2010的工程文件.还有编译好的astyle.exe.有dll工程和lib工程文件,也有static工程. 提示:这个并不是我修改的.是我下载的.我上传只是想赚点积分.也方便有些有有需要的人.特别是搞astyle嵌入的. bug:它依然没有解决中文问题.
资源推荐
资源详情
资源评论
收起资源包目录
astyle-src-bin-vs-1.24.rar (51个子文件)
astyle
bin
AStyle.exe 405KB
src
astyle_main.cpp 73KB
ASEnhancer.cpp 15KB
ASFormatter.cpp 129KB
astyle.h 29KB
ASResource.cpp 19KB
astyle_main.h 10KB
ASBeautifier.cpp 74KB
doc
install.html 18KB
links.html 7KB
notes.html 69KB
index.html 10KB
scripts.html 6KB
license.html 11KB
styles.css 2KB
news.html 43KB
subversion.html 4KB
astyle.html 60KB
build
vs2003
AStyle.vcproj 15KB
AStyle.sln 2KB
vs2005
AStyleLib.sln 892B
AStyleDll
AStyleDll.vcproj 5KB
AStyleJava.sln 895B
All AStyle.sln 3KB
AStyle.sln 1KB
AStyleJava
AStyleJava.vcproj 5KB
AStyleLib
AStyleLib.vcproj 4KB
AStyleDll.sln 892B
AStyle
AStyle.vcproj 6KB
vs2008
AStyleLib.sln 893B
AStyleDll
AStyleDll.vcproj 5KB
AStyleJava.sln 896B
All AStyle.sln 3KB
AStyle.sln 1KB
AStyleJava
AStyleJava.vcproj 5KB
AStyleLib
AStyleLib.vcproj 4KB
AStyleDll.sln 893B
AStyle
AStyle.vcproj 6KB
vs2010
AStyleLib.sln 899B
AStyleDll
AStyleDll.vcxproj.filters 1KB
AStyleDll.vcxproj 6KB
AStyleJava.sln 902B
All AStyle.sln 3KB
AStyle.sln 1KB
AStyleJava
AStyleJava.vcxproj 6KB
AStyleJava.vcxproj.filters 1KB
AStyleLib
AStyleLib.vcxproj 5KB
AStyleLib.vcxproj.filters 1KB
AStyleDll.sln 899B
AStyle
AStyle.vcxproj.filters 1KB
AStyle.vcxproj 8KB
共 51 条
- 1
资源评论
- pirate_zju2015-07-13挺好用的,挺好用的
- onedolph2013-01-21不错的说,可以使用。
- lwl79693172014-07-24还行,可以使用
- 吕帅2014-06-26不好意思,不是我需要的东西。
- hbzx20082016-08-29不错的说,可以使用。
goas
- 粉丝: 32
- 资源: 15
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功