概述
#### Option's Format:选项格式
## ----------------
## Long options (starting with '--') must be written one at a time.
## Short options (starting with '-') may be appended together.
## Thus, -bps4 is the same as -b -p -s4
## By default, astyle is set up to indent C/C++/C#/Java files,
## with 4 spaces per indent, a maximal indentation of 40 spaces inside continuous statements,and NO formatting.
#### 大括号三种基本风格:
## attach:大括号前一个与上一行在同一行(java)
## break:大括号与前一块隔开为两行 (allman,bsd)
## linux:大括号在class,namespace,function分行,其他不分行(K&R,linux)
## --brackets=attach OR -a 大括号前一个与上一行在同一行 Attach brackets to pre-block code (i.e. Java style).
## --brackets=break OR -b 大括号与前一块隔开为两行 Break brackets from pre-block code (i.e. ANSI C/C++, allman, bsd style).
## --brackets=linux OR -l 定义块 和 函数块中的大括号都被处理 Break definition-block brackets and attach command-block brackets.(k/r, linux)
## --brackets=stroustrup OR -u 只处理函数中的大括号 Attach all brackets except function definition brackets.
#### 风格花括号Style定义(默认都不处理namespace, 默认都在语句和代码块后分行):
## --style=allman or --style=bsd or -A1
## --style=java or -A2
## --style=k&r or --style=k/r or -A3
## --style=stroustrup or -A4
## --style=whitesmith or -A5
## --style=banner or -A6
## --style=gnu or -A7
## --style=linux or -A8
A3
#### tab选项: 默认tab是4个空格.
## --indent=spaces=# OR -s# 默认行缩进为4个空格,可以将#替换为缩进量
s4
## --indent=tab OR --indent=tab=# OR -t OR -t# 行缩进用tab, 续行语句用空格
## --indent=force-tab=# OR -T# 行缩进用tab, 续行语句用也用tab
## --indent=force-tab-x OR --indent=force-tab-x=# OR -xT OR -xT# 比较复杂,不建议使用
#### 大括号选项: If no brackets option is set, the brackets will not be changed.
## --attach-namespaces / -xn namespaces后的大括号不分行
## --attach-classes / -xc class后的大括号不分行
## --attach-inlines / -xl C++中定义的inlines函数的大括号不分行
## --attach-extern-c / -xk C++中的extern "C" 后的大括号不分行
## --attach-closing-while / -xV do while中的while条件不分行
#### 缩进选项:
## --indent-classes OR -C 缩进类定义中的public private protected标签.
## Indent 'class' blocks, so that the inner 'public:','protected:' and 'private:
## headers are indented in relation to the class block.
##--indent-modifiers / -xG 类中的public private protected标签缩进改为1/2.
## Indent 'class ' and 'struct' access modifiers, 'public:', 'protected:' and 'private:', one half indent.
## The rest of the class is not indented. This option is effective for C++ files only.
## If used with indent‑classes this option will be ignored.
## --indent-switches OR -S 缩进switch中的case块,case和switch不在同一列
## Indent 'switch' blocks, so that the inner 'case XXX:' headers are indented in relation to the switch block.
S
## --indent-cases OR -K 缩进case下面的语句
## Indent case blocks from the 'case XXX:' headers.
## Case statements not enclosed in blocks are NOT indented.
K
## --indent-blocks OR -G 缩进块, 包括大括号
## Add extra indentation entire blocks (including brackets).
## --indent-brackets OR -B 缩进大括号
## Add extra indentation to '{' and '}' block brackets.
## --indent-namespaces OR -N 缩进命名空间定义行
## Indent the contents of namespace blocks.
## --indent-labels OR -L 缩进标签
## Indent labels so that they appear one indent less than the current indentation level,
## rather than being flushed completely to the left (which is the default).
## --indent-preprocessor OR -w 缩进多行宏定义
## Indent multi-line #define statements.
## --max-instatement-indent=# OR -M# 跨行缩进,比如函数定义中的参数处在多行,那么参数缩进到同一列
## Indent a maximal # spaces in a continuous statement, relative to the previous line.
## --min-conditional-indent=# OR -m#
## Indent a minimal # spaces in a continuous conditional belonging to a conditional header.
#### 格式化选项:
## --break-blocks OR -f 空行分隔没有关系的块,类,标签(不包括函数块)
## Insert empty lines around unrelated blocks, labels, classes, ...
## --break-blocks=all OR -F 空行分隔无关系的块,包括else catch等
## Like --break-blocks,
## except also insert empty lines around closing headers (e.g. 'else', 'catch', ...).
f
## --break-closing-brackets OR -y else catch左边的大括号与else catch分隔
## Break brackets before closing headers (e.g. 'else', 'catch', ...).
## Use with --brackets=attach, --brackets=linux, or --brackets=stroustrup.
## --break-elseifs OR -e else if()分隔为两行
## Break 'else if()' statements into two different lines.
## --pad-comma / -xg 参数之间插入空格
## Insert space padding after commas.
xg
## --delete-empty-lines OR -x 删除多余空行
## Delete empty lines within a function or method.
## It will NOT delete lines added by the break-blocks options.
## --pad-oper OR -p 操作符两端插入一个空格
## Insert space paddings around operators.
p
## --pad-paren OR -P 括号内外都插入空格
## Insert space padding around parenthesis on both the outside and the inside.
## --pad-paren-out OR -d 括号外部插入空格
## Insert space padding around parenthesis on the outside only.
## --pad-paren-in OR -D 括号外部插入空格
## Insert space padding around parenthesis on the inside only.
## --pad-header / -H 在if for while 等条件语句中,(前增加空格
## Insert space padding between a header (e.g. 'if', 'for', 'while'...) and the following paren.
H
## --unpad-paren OR -U 移除括号两端多余空格
## Remove unnecessary space padding around parenthesis.
## This can be used in combination with the 'pad' options above.
U
## --keep-one-line-statements OR -o 一行中的多个申明不分隔 int x;int y;int z 不被分为3行
## Don't break lines containing multiple statements into multiple single-statement lines.
o
## --keep-one-line-blocks OR -O 大括号中的单行语句不被拆分
## Don't break blocks residing completely on one line.
O
## --convert-tabs OR -c tab转换为空格
## Convert tabs to the appropriate number of spaces.
c
## --fill-empty-lines OR -E 块间空行的换行符前插入一个空格
## Fill empty lines with the white space of their previous lines.
## --align-pointer=type / -k1 指针对齐方式
## --align-pointer=middle / -k2 指针对齐方式
## --align-pointer=name / -k3 指针对齐方式
k3
## --align-reference=none / -W0 引用对齐方式
## --align-reference=type / -W1 引用对齐方式
## --align-reference=middle / -W2 引用对齐方式
## --align-reference=name / -W3 引用对齐方式
W3
## --add-braces / -j if,for, while 语句没有大括号就增加大括号
## Add braces to unbraced one line conditional statements (e.g. 'if', 'for', 'while'...).
j
## --add-one-line-braces / -J if,for, while 语句没有大括号就增加大括号,单语句不换行
## Add one line braces to unbraced one line conditional statements (e.g. 'if', 'for', 'while'...).
## --remove-braces / -xj 删除if,for, while 单语句中的大括号
## Remove one line braces to unbraced one line conditional statements (e.g. 'if', 'for', 'while'...).
J
## --max-code-length=# / -xC# 代码最长数,有效值为50-200
## The option max‑code‑length will break a line if the code exceeds # characters. The valid values are 50 thru 200.
xC200
## --break-after-logical / -xL 逻辑代码中的,多个逻辑分行
xL
## --mode=c 处理c文件
## Indent a C or C++ source file (this is the default).
## --mode=java 处理jave文件
## Indent a Java source file.
## --mode=cs 处理c#文件
## Indent a C# source file.
## 其他选项:
## --suffix=#### 指定备份文件的后缀
## Append the suffix #### instead of '.orig' to original filename.
## --suffix=none OR -n 不备份文件
## Do not retain a backup of the original file.
n
## --options=#### 指定从####文件读取选项信息
## Specify an options file #### to read and use.
## --options=none 禁止从文件读取选项信息
## Disable the default options file.Only the command-line parameters will be used.
## --recursive OR -r OR -R 递归处理子目录
## Process subdirectories recursively.
## --exclude=#### 排除不处理的文件夹
## Specify a file or directory #### to be excluded from processing.
## --errors-to-stdout OR -X
## Print errors and help information to standard-output rather than to standard-error.
## --preserve-date OR -Z 不修改时间
## The date and time modified will not be changed in the formatted file.
Z
## --verbose OR -v 输出详细处理信息
## Verbose mode. Extra informational messages will be displayed.
## --formatted OR -Q 输出信息中只包括被修改的文件信息
## Formatted display mode. Display only the files that have been formatted.
## --quiet OR -q 忽略所有错误
## Quiet mode. Suppress all output except error messages.
## --version OR -V 输出astyle版本
## Print version number.
## --help OR -h OR -? 帮助信息
## Print this help message.
## --lineend=windows / -z1 行尾rn
## --lineend=linux / -z2 行尾n
## --lineend=macold / -z3 行尾r
z1
转载于:https://my.oschina.net/kshuang/blog/1579334
最后
以上就是个性书本为你收集整理的Astyle格式说明的全部内容,希望文章能够帮你解决Astyle格式说明所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复