<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Artistic Style</title> <meta http-equiv="Content-Language" content="en-us" /> <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" /> <meta name="description" content="Artistic Style is a source code indenter, source code formatter, and source code beautifier for the C, C++, C# and Java programming languages." /> <meta name="keywords" content="artistic style, astyle, source code indenter, source code formatter, source code beautifier" /> <link href="styles.css" rel="stylesheet" type="text/css" /> <!-- the following styles are additions to astyle.html --> <style type="text/css"> code { color:navy; } code.title { font-size:larger; font-weight:bold; } p.code { margin-left:0.3in; } pre { color:navy; font-weight:bold; } span.brace { color:red; } span.comment { color:#696969; } /*dimgray*/ span.option { color:#8B4513; } /*saddlebrown*/ hr { margin-left:-0.4in } </style> </head> <body> <!-- CUT HERE FOR INSERTION INTO SOURCEFORGE DOC MANAGER --> <h1> Artistic Style 1.24</h1> <h2> A Free, Fast and Small Automatic Formatter<br />for C, C++, C#, and Java Source Code</h2> <h3 id="Contents"> Contents</h3> <p class="contents1"><a class="contents" href="#_General_Information">General Information</a></p> <p class="contents1"><a class="contents" href="#_Usage">Usage</a></p> <p class="contents1"><a class="contents" href="#_Options">Options</a></p> <p class="contents1"><a class="contents" href="#_Options_File">Options File</a></p> <p class="contents1"> <a class="contents" href="#_Predefined_Style_Options">Predefined Style Options</a></p> <p class="contents2"> <a class="contents" href="#_style=allman">style=allman</a> <a class="contents" href="#_style=java">style=java</a> <a class="contents" href="#_style=k&r">style=k&r</a> <a class="contents" href="#_style=stroustrup">style=stroustrup</a> <a class="contents" href="#_style=whitesmith">style=whitesmith</a> <a class="contents" href="#_style=banner">style=banner</a> <a class="contents" href="#_style=gnu">style=gnu</a> <a class="contents" href="#_style=linux">style=linux</a> <a class="contents" href="#_style=horstmann">style=horstmann</a> <a class="contents" href="#_style=1tbs">style=1tbs</a> </p> <p class="contents1"> <a class="contents" href="#_Tab_and_Bracket_Options">Tab and Bracket Options</a> </p> <p class="contents2"><a class="contents" href="#_default_indent">default indent</a> <a class="contents" href="#_indent=spaces">indent=spaces</a> <a class="contents" href="#_indent=tab">indent=tab</a> <a class="contents" href="#_indent=force-tab">indent=force‑tab</a> <a class="contents" href="#_default_brackets">default brackets</a> <a class="contents" href="#_brackets=break">brackets=break</a> <a class="contents" href="#_brackets=attach">brackets=attach</a> <a class="contents" href="#_brackets=linux">brackets=linux</a> <a class="contents" href="#_brackets=stroustrup">brackets=stroustrup</a> <a class="contents" href="#_brackets=horstmann">brackets=horstmann</a> </p> <p class="contents1"> <a class="contents" href="#_Indentation_Options">Indentation Options</a></p> <p class="contents2"><a class="contents" href="#_indent-classes">indent‑classes</a> <a class="contents" href="#_indent-switches">indent‑switches</a> <a class="contents" href="#_indent-cases">indent‑cases</a> <a class="contents" href="#_indent-brackets">indent‑brackets</a> <a class="contents" href="#_indent-blocks">indent‑blocks</a> <a class="contents" href="#_indent-namespaces">indent‑namespaces</a> <a class="contents" href="#_indent-labels">indent‑labels</a> <a class="contents" href="#_indent-preprocessor">indent‑preprocessor</a> <a class="contents" href="#_indent-col1-comments">indent‑col1‑comments</a> <a class="contents" href="#_max-instatement-indent">max‑instatement‑indent</a> <a class="contents" href="#_min-conditional-indent">min‑conditional‑indent</a> </p> <p class="contents1"><a class="contents" href="#_Padding_Options">Padding Options</a></p> <p class="contents2"> <a class="contents" href="#_break-blocks">break‑blocks</a> <a class="contents" href="#_break-blocks=all">break‑blocks=all</a> <a class="contents" href="#_pad-oper">pad‑oper</a> <a class="contents" href="#_pad-paren">pad‑paren</a> <a class="contents" href="#_pad-paren-out">pad‑paren‑out</a> <a class="contents" href="#_pad-paren-in">pad‑paren‑in</a> <a class="contents" href="#_pad-header">pad‑header</a> <a class="contents" href="#_unpad-paren">unpad‑paren</a> <a class="contents" href="#_delete-empty-lines">delete‑empty‑lines</a> <a class="contents" href="#_fill-empty-lines">fill‑empty‑lines</a> </p> <p class="contents1"><a class="contents" href="#_Formatting_Options">Formatting Options</a></p> <p class="contents2"> <a class="contents" href="#_break-closing-brackets">break‑closing‑brackets</a> <a class="contents" href="#_break-elseifs">break‑elseifs</a> <a class="contents" href="#_add-brackets">add‑brackets</a> <a class="contents" href="#_add-one-line-brackets">add‑one‑line‑brackets</a> <a class="contents" href="#_keep-one-line-blocks">keep‑one‑line‑blocks</a> <a class="contents" href="#_keep-one-line-statements">keep‑one‑line‑statements</a> <a class="contents" href="#_convert-tabs">convert‑tabs</a> <a class="contents" href="#_align-pointer">align‑pointer</a> <a class="contents" href="#_mode">mode</a> </p> <p class="contents1"><a class="contents" href="#_Other_Options">Other Options</a></p> <p class="contents2"><a class="contents" href="#_suffix">suffix</a> <a class="contents" href="#_suffix=none">suffix=none</a> <a class="contents" href="#_options">options</a> <a class="contents" href="#_options=none">options=none</a> <a class="contents" href="#_recursive">recursive</a> <a class="contents" href="#_exclude">exclude</a> <a class="contents" href="#_errors-to-stdout">errors‑to‑stdout</a> <a class="contents" href="#_preserve-date">preserve‑date</a> <a class="contents" href="#_verbose">verbose</a> <a class="contents" href="#_formatted">formatted</a> <a class="contents" href="#_quiet">quiet</a> <a class="contents" href="#_lineend">lineend</a> <a class="contents" href="#_version">version</a> <a class="contents" href="#_help">help</a> </p> <p> </p> <hr /> <!-- * * * * * * * * * * * * General Information< * * * * * * * * * * * * --> <h3 id="_General_Information"> General Information</h3> <h4> Line Endings</h4> <p> Line endings in the formatted file will be the same as the input file. If there are mixed line endings the most frequent occurrence will be used.</p> <h4> File Type</h4> <p> Artistic Style will determine the file type from the file extension. The extension ".java" indicates a Java file, and ".cs" indicates a C# file. Everything else is a C or C++ file. If you are using a non-standard file extension for Java or C#, use one of the <code>--mode=</code> options.</p> <h4> Wildcards and Recursion</h4> <p> Artistic Style can process directories recursively. Wildcards (such as "*.cpp" or "*.c??") are processed internally. If a shell is used it should pass the wildcards to Artistic Style instead of resolving them first. For Linux use double quotes around paths whose filename contains wildcards. For Windows use double quotes around paths whose filename contains spaces. The "Other Options" section contains information on recursive processing.</p> <h4> File Names</h4> <p> When a file is formatted, the newly indented file retains the original file name. A copy of the original file is created with an <code><strong>.orig</strong></code> appended to the original file name. (This can be set to a different string by the option <code>--suffix=</code>, or suppressed altogether by the options <code>-n</code> or <code>--suffix=none</code>). Thus, after indenting <code><em>SourceFile.cpp</em></code> the indented file will be named <code><em>SourceFile.cpp</em></code>, while the original pre-indented file will be renamed to <code><em>SourceFile.cpp.orig</em></code>.</p> <h4> Considerations</h4> <p> Artistic Style can format standard class library statements such as Open GL, wxWidgets, QT, and MFC.</p> <p> Embedded assembler language is formatted correctly. This includes extended assembly and Microsoft specific assembler lines and blocks.</p> <p> Artistic Style can format embedded SQL statements. The SQL formatting will be maintained as long as the standard hanging indent format is used. If the "exec sql" statement is indented more than the following statements, the SQL will be aligned in a single column.</p> <p> Files encoded as UTF 16 or 32 bit can NOT be formatted. These are left unformatted and a warning message is displayed. These files can be converted with the program iconv and with some text editors, such as SciTE.</p> <p> Embedded statements that are multiple-line and are NOT in a C type format, such as Python, are usually mal-formatted. (A C type format has blocks enclosed by brackets and statements terminated by a semi-colon). Macros that define functions may cause the following code to be mal-formatted because the macro is missing the brackets and semi-colons from the definition. If you have source code with these types of statements, exclude them with the <code>--exclude=</code> statement described in the "Other Options" section.</p> <h4> Quick Start</h4> <p> If you have never used Artistic Style there are a couple of ways to start. One is to run it with no options at all. This will format the file with 4 spaces per indent and will leave the brackets unchanged. Another is to use one of the predefined styles described in the "Predefined Style Options" section. Select one with a bracket formatting style you like. Once you are familiar with the options you can customize the format to your personal preference.</p> <p> </p> <hr /> <!-- * * * * * * * * * * * * * * * Usage * * * * * * * * * * * * * * * --> <h3 id="_Usage"> Usage</h3> <p> Artistic style is a console program that receives information from the command line. The format of the command line is:</p> <pre>astyle [options] <em>SourceFile1 SourceFile2 SourceFile3</em> [ . . . ] </pre> <p> The block parens [ ] indicate that more than one option or more than one filename can be entered. They are NOT actually included in the command. For the options format see the following Options section.</p> <div class="code"> <p> Example to format a single file:</p> <pre>astyle --style=allman /home/user/project/foo.cpp </pre> <p> Example to format all .cpp and .h files recursively:</p> <pre>astyle --style=allman --recursive /home/user/project/*.cpp /home/user/project/*.h </pre> </div> <p> Or to format the file with a different name:</p> <pre>astyle [options] < <em>OriginalSourceFile</em> > <em>BeautifiedSourceFile</em> </pre> <p> The <span style="color: #0000a0"><</span> and <span style="color: #0000a0">></span> characters are used to redirect the files into standard input (cin) and out of standard output (cout) - don't forget them! With this option only one file at a time can be formatted. Wildcards are not recognized, there are no console messages, and a backup is not created.</p> <p> </p> <hr /> <!-- * * * * * * * * * * * * * * * Options * * * * * * * * * * * * * * * --> <h3 id="_Options"> Options</h3> <p> Not specifying any option will result in 4 spaces per indent, no change in bracket placement, and no formatting changes.</p> <p> Options may be written in two different ways.</p> <h4> Long options</h4> <p> These options start with '<strong>--</strong>', and must be written one at a time.<br />(Example: '<code>--brackets=attach --indent=spaces=4</code>')</p> <h4> Short Options</h4> <p> These options start with a single '<strong>-</strong>', and may be concatenated together.<br />(Example: '<code>-bps4</code>' is the same as writing '<code>-b -p -s4</code>'.)</p> <p> </p> <hr /> <!-- * * * * * * * * * * * * * * Options File * * * * * * * * * * * * * * --> <h3 id="_Options_File"> Options File</h3> <p> An OPTIONAL default options file may be used to supplement or replace the command line options. </p> <ul> <li>The command line options have precedence. If there is a conflict between a command line option and an option in the default options file, the command line option will be used.</li> <li>Artistic Style looks for this file in the following locations (in order): <ol> <li>the file indicated by the --options= command line option;</li> <li>the file and directory indicated by the environment variable ARTISTIC_STYLE_OPTIONS (if it exists);</li> <li>the file named .astylerc in the directory pointed to by the HOME environment variable (e.g. "$HOME/.astylerc" on Linux);</li> <li>the file named astylerc in the directory pointed to by the USERPROFILE environment variable (e.g. "%USERPROFILE%\astylerc" on Windows).</li> </ol> </li> <li>This option file lookup can be disabled by specifying --options=none on the command line.</li> <li>Options may be set apart by new-lines, tabs, commas, or spaces.</li> <li>Long options in the options file may be written without the preceding '--'.</li> <li>Lines within the options file that begin with '#' are considered line-comments.</li> </ul> <p> Example of a default options file:</p> <div class="code"> <pre><span class="comment"># this line is a comment</span> --brackets=attach <span class="comment"># this is a line-end comment</span> <span class="comment"># long options can be written without the preceding '--'</span> indent-switches <span class="comment"># cannot do this on the command line</span> <span class="comment"># short options must have the preceding '-'</span> -t -p <span class="comment"># short options can be concatenated together</span> -M65Ucv</pre> </div> <p> </p> <hr /> <!-- * * * * * * * * * * * * Predefined Style Options * * * * * * * * * * * * --> <h3 id="_Predefined_Style_Options"> Predefined Style Options</h3> <p> Predefined Style options define the style by setting other options. The style options always override any individual option settings. You will always get the requested style regardless of other defined options.</p> <p> The predefined style options always set the options brackets=###, indent‑blocks, and indent‑brackets. These options can NOT be changed with the individual option settings.</p> <p> Some styles use the default setting for spaces per indent and some use a different setting. You may use any of the indent= options with any style. The indent options that do not set the spaces per indent (indent=spaces, indent=tab, or indent=force‑tab) will use the default spaces per tab setting for the style. The indent options that set the spaces per indent (indent=spaces=#, indent=tab=#, or indent=force‑tab=#) will use the specified spaces per tab setting instead of the default for the style. For the options that set the spaces per indent see the following style descriptions.</p> <p> All other options are available to customize the style. By default, none of the styles indent namespaces. This can be changed with the indent‑namespaces option.</p> <p> </p> <p id="_style=allman"> <code class="title">--style=allman / --style=ansi / --style=bsd / -A1</code><br />Allman style formatting/indenting uses broken brackets.</p> <div class="code"> <pre>int Foo(bool isBar) <span class="brace">{</span> if (isBar) <span class="brace">{</span> bar(); return 1; <span class="brace">}</span> else return 0; <span class="brace">}</span> </pre> </div> <p> </p> <p id="_style=java"> <code class="title">--style=java / -A2</code><br />Java style formatting/indenting uses attached brackets.</p> <div class="code"> <pre>int Foo(bool isBar) <span class="brace">{</span> if (isBar) <span class="brace">{</span> bar(); return 1; <span class="brace">}</span> else return 0; <span class="brace">}</span> </pre> </div> <p> </p> <p id="_style=k&r"> <code class="title">--style=k&r / --style=k/r / -A3</code><br />Kernighan & Ritchie style formatting/indenting uses linux brackets. Brackets are broken from namespaces, classes, and function definitions. Brackets are attached to statements within a function.</p> <p> Using the k&r option may cause problems because of the &. This can be resolved by enclosing the k&r in quotes (e.g. ‑‑style="k&r") or by using the alternate ‑‑style=k/r.</p> <div class="code"> <pre>int Foo(bool isBar) <span class="brace">{</span> if (isBar) <span class="brace">{</span> bar(); return 1; <span class="brace">}</span> else return 0; <span class="brace">}</span> </pre> </div> <p> </p> <p id="_style=stroustrup"> <code class="title">--style=stroustrup / -A4</code><br />Stroustrup style formatting/indenting uses stroustrup brackets. Brackets are broken from function definitions only. Brackets are attached to namespaces, classes, and statements within a function. <strong>Indentation</strong> is 5 spaces. </p> <div class="code"> <pre>int Foo(bool isBar) <span class="brace">{</span> if (isBar) <span class="brace">{</span> bar(); return 1; <span class="brace">}</span> else return 0; <span class="brace">}</span> </pre> </div> <p> </p> <p id="_style=whitesmith"> <code class="title">--style=whitesmith / -A5</code><br />Whitesmith style formatting/indenting uses broken, indented brackets. Class blocks and switch blocks are indented to prevent a 'hanging indent' with switch statements and C++ class modifiers (public, private, protected). </p> <div class="code"> <pre>int Foo(bool isBar) <span class="brace">{</span> if (isBar) <span class="brace">{</span> bar(); return 1; <span class="brace">}</span> else return 0; <span class="brace">}</span> </pre> </div> <p> </p> <p id="_style=banner"> <code class="title">--style=banner / -A6</code><br />Banner style formatting/indenting uses attached, indented brackets. Class blocks and switch blocks are indented to prevent a 'hanging indent' with switch statements and C++ class modifiers (public, private, protected). </p> <div class="code"> <pre>int Foo(bool isBar) <span class="brace">{</span> if (isBar) <span class="brace">{</span> bar(); return 1; <span class="brace">}</span> else return 0; <span class="brace">}</span> </pre> </div> <p> </p> <p id="_style=gnu"> <code class="title">--style=gnu / -A7</code><br />GNU style formatting/indenting uses broken brackets and indented blocks. <strong>Indentation</strong> is 2 spaces. </p> <p> Extra indentation is added to blocks <strong>within a function</strong>. The opening bracket for namespaces, classes, and functions is not indented. </p> <div class="code"> <pre>int Foo(bool isBar) <span class="brace">{</span> if (isBar) <span class="brace">{</span> bar(); return 1; <span class="brace">}</span> else return 0; <span class="brace">}</span> </pre> </div> <p> </p> <p id="_style=linux"> <code class="title">--style=linux / -A8</code><br />Linux style formatting/indenting uses linux style brackets. Brackets are broken from namespace, class, and function definitions. Brackets are attached to statements within a function. <strong>Indentation</strong> is 8 spaces. <strong>Minimum conditional indent</strong> is 4 spaces, or one-half the spaces per indent if a different setting is used. If you want to change the spaces per indent for this style it will be easier to use the K&R style instead.</p> <p> Also known as Kernel Normal Form (KNF) style, this is the style used in the Linux kernel.</p> <div class="code"> <pre>int Foo(bool isBar) <span class="brace">{</span> if (isFoo) <span class="brace">{</span> bar(); return 1; <span class="brace">}</span> else return 0; <span class="brace">}</span> </pre> </div> <p> </p> <p id="_style=horstmann"> <code class="title">--style=horstmann / -A9</code><br />Horstmann style formatting/indenting uses horstmann style brackets. Brackets are broken with run-in statements. Switches are indented. <strong>Indentation</strong> is 3 spaces. </p> <div class="code"> <pre>int Foo(bool isBar) <span class="brace">{</span> if (isBar) <span class="brace">{</span> bar(); return 1; <span class="brace">} </span>else return 0; <span class="brace">}</span> </pre> </div> <p> </p> <p id="_style=1tbs"> <code class="title">--style=1tbs / --style=otbs / -A10</code><br />"One True Brace Style" formatting/indenting uses linux style brackets and adds brackets to unbracketed one line conditional statements. In the following example brackets have been added to the "<code>return 0;</code>" statement. The option ‑‑add‑one‑line‑brackets can also be used with this style.</p> <div class="code"> <pre>int Foo(bool isBar) <span class="brace">{</span> if (isFoo) <span class="brace">{</span> bar(); return 1; <span class="brace">}</span> else <span class="brace">{</span> return 0; <span class="brace">}</span> <span class="brace">}</span> </pre> </div> <p> </p> <hr /> <!-- * * * * * * * * * * * * Tab and Bracket Options * * * * * * * * * * * * --> <h3 id="_Tab_and_Bracket_Options"> Tab and Bracket Options</h3> <p id="_default_indent"> <code class="title">default indent option</code><br />If no indentation option is set, the default option of 4 spaces will be used (e.g. <code>-s<span class="option">4</span> --indent=spaces=<span class="option">4</span></code>).</p> <p id="_indent=spaces"> <code class="title">--indent=spaces / --indent=spaces=<span class="option">#</span> / -s<span class="option">#</span></code><br /> Indent using # spaces per indent (e.g. <code>-s<span class="option">6</span></code> <code>--indent=spaces=<span class="option">6</span></code>). # must be between 2 and 20. Not specifying # will result in a default of 4 spaces per indent.</p> <p id="_indent=tab"> <code class="title">--indent=tab / --indent=tab=<span class="option">#</span> / -t / -t<span class="option">#</span></code><br /> Indent using tab characters. Treat each tab as # spaces (e.g. <code>-t<span class="option">6</span></code> / <code> --indent=tab=<span class="option">6</span></code>). # must be between 2 and 20. If no # is set, treats tabs as 4 spaces.</p> <p id="_indent=force-tab"> <code class="title">--indent=force-tab / --indent=force-tab=<span class="option">#</span> / -T / -T<span class="option">#</span></code><br /> Indent using tab characters. Treat each tab as # spaces (e.g. <code>-T<span class="option">6</span></code> / <code> --indent=<span lang="en-us">force-</span>tab=<span class="option">6</span></code>). Uses tabs as indents where <code>‑‑indent=tab</code> prefers to use spaces, such as inside multi-line statements. # must be between 2 and 20. If no # is set, treats tabs as 4 spaces.</p> <p id="_default_brackets"> <code class="title">default brackets option</code><br />If no brackets option is set, the brackets will not be changed.</p> <p id="_brackets=break"> <code class="title">--brackets=break / -b</code><br />Break brackets from their pre-block statements ( e.g. Allman / ANSI style ).</p> <div class="code"> <pre>void Foo(bool isFoo) <span class="brace">{</span> if (isFoo) <span class="brace">{</span> bar(); <span class="brace">}</span> else <span class="brace">{</span> anotherBar(); <span class="brace">}</span> <span class="brace">}</span> </pre> </div> <p> </p> <p id="_brackets=attach"> <code class="title">--brackets=attach / -a</code><br />Attach brackets to their pre-block statements ( e.g. Java style ).</p> <div class="code"> <pre>void Foo(bool isFoo) <span class="brace">{</span> if (isFoo) <span class="brace">{</span> bar(); <span class="brace">}</span> else <span class="brace">{</span> anotherBar(); <span class="brace">}</span> <span class="brace">}</span> </pre> </div> <p> </p> <p id="_brackets=linux"> <code class="title">--brackets=linux / -l</code><br />Break brackets from namespace, class, and function definitions, but attach brackets to statements within a function ( e.g. K&R / Linux style ).</p> <p> With C++ files brackets are attached for function definitions within a class (inline class functions). The brackets are also attached for arrays, structs, enums, and other top level objects that are not classes or functions. This option is effective for C/C++ files only.</p> <div class="code"> <pre>void Foo(bool isFoo) <span class="brace">{</span> if (isFoo) <span class="brace">{</span> bar(); <span class="brace">}</span> else <span class="brace">{</span> anotherBar; <span class="brace">}</span> <span class="brace">}</span> </pre> </div> <p> </p> <p id="_brackets=stroustrup"> <code class="title">--brackets=stroustrup / -u</code><br />Break brackets from function definitions only. Attach brackets to namespaces, classes, and statements within a function ( e.g. Stroustrup style ).</p> <p> With C++ files brackets are attached for function definitions within a class (inline class functions). The brackets are also attached for arrays, structs, enums, and other top level objects that are not classes or functions. This option is effective for C/C++ files only.</p> <div class="code"> <pre>void Foo(bool isFoo) <span class="brace">{</span> if (isFoo) <span class="brace">{</span> bar(); <span class="brace">}</span> else <span class="brace">{</span> anotherBar; <span class="brace">}</span> <span class="brace">}</span> </pre> </div> <p> </p> <p id="_brackets=horstmann"> <code class="title">--brackets=horstmann / -g</code><br />Break brackets from their pre-block statements but allow run-in statements on the same line as an opening bracket ( e.g. Horstmann style ).</p> <div class="code"> <pre>void Foo(bool isFoo) <span class="brace">{</span> if (isFoo()) <span class="brace">{</span> bar1(); bar2(); <span class="brace">}</span> else <span class="brace">{</span> anotherBar(); <span class="brace">}</span> <span class="brace">}</span> </pre> </div> <p> </p> <hr /> <!-- * * * * * * * * * * * * * Indentation Options * * * * * * * * * * * * * --> <h3 id="_Indentation_Options"> Indentation Options</h3> <p id="_indent-classes"> <code class="title">--indent-classes / -C</code><br />Indent '<code>class</code>' and '<code>struct</code>' blocks so that the blocks '<code>public:</code>', '<code>protected:</code>' and '<code>private:</code>' are indented. The struct blocks are indented only if an access modifier is declared somewhere in the struct. The entire block is indented. This option is effective for C++ files only.</p> <div class="code"> <pre>class Foo <span class="brace">{</span> public: Foo(); virtual ~Foo(); <span class="brace">}</span>; </pre> <p class="code"> becomes:</p> <pre>class Foo <span class="brace">{</span> public: Foo(); virtual ~Foo(); <span class="brace">}</span>; </pre> </div> <p> </p> <p id="_indent-switches"> <code class="title">--indent-switches / -S</code><br />Indent '<code>switch</code>' blocks so that the '<code>case X:</code>' statements are indented in the <code>switch</code> block. The entire case block is indented.</p> <div class="code"> <pre>switch (foo) <span class="brace">{</span> case 1: a += 1; break; case 2: <span class="brace">{</span> a += 2; break; <span class="brace">}</span> <span class="brace">}</span> </pre> <p class="code"> becomes:</p> <pre>switch (foo) <span class="brace">{</span> case 1: a += 1; break; case 2: <span class="brace">{</span> a += 2; break; <span class="brace">}</span> <span class="brace">}</span> </pre> </div> <p> </p> <p id="_indent-cases"> <code class="title">--indent-cases / -K</code><br />Indent '<code>case X:</code>' blocks from the '<code>case X:</code>' headers. Case statements not enclosed in blocks are NOT indented.</p> <div class="code"> <pre>switch (foo) <span class="brace">{</span> case 1: a += 1; break; case 2: <span class="brace">{</span> a += 2; break; <span class="brace">}</span> <span class="brace">}</span> </pre> <p class="code"> becomes:</p> <pre>switch (foo) <span class="brace">{</span> case 1: a += 1; break; case 2: <span class="brace">{</span> a += 2; break; <span class="brace">}</span> <span class="brace">}</span> </pre> </div> <p> </p> <p id="_indent-brackets"> <code class="title">--indent-brackets / -B</code><br />Add extra indentation to brackets. This is the option used for Whitesmith and Banner style formatting/indenting. If both ‑‑indent‑brackets and ‑‑indent‑blocks are used the result will be ‑‑indent‑blocks. This option will be ignored if used with a predefined style.</p> <div class="code"> <pre>if (isFoo) <span class="brace">{</span> bar(); <span class="brace">}</span> else anotherBar(); </pre> <p class="code"> becomes:</p> <pre>if (isFoo) <span class="brace">{</span> bar(); <span class="brace">}</span> else anotherBar(); </pre> </div> <p> </p> <p id="_indent-blocks"> <code class="title">--indent-blocks / -G</code><br />Add extra indentation to blocks <strong>within a function</strong>. The opening bracket for namespaces, classes, and functions is not indented. This is the option used for GNU style formatting/indenting. This option will be ignored if used with a predefined style.</p> <div class="code"> <pre>if (isFoo) <span class="brace">{</span> bar(); <span class="brace">}</span> else anotherBar(); </pre> <p class="code"> becomes:</p> <pre>if (isFoo) <span class="brace">{</span> bar(); <span class="brace">}</span> else anotherBar(); </pre> </div> <p> </p> <p id="_indent-namespaces"> <code class="title">--indent-namespaces / -N</code><br />Add extra indentation to namespace blocks. This option has no effect on Java files.</p> <div class="code"> <pre>namespace foospace <span class="brace">{</span> class Foo <span class="brace">{</span> public: Foo(); virtual ~Foo(); <span class="brace">}</span>; <span class="brace">}</span> </pre> <p class="code"> becomes:</p> <pre>namespace foospace <span class="brace">{</span> class Foo <span class="brace">{</span> public: Foo(); virtual ~Foo(); <span class="brace">}</span>; <span class="brace">}</span> </pre> </div> <p> </p> <p id="_indent-labels"> <code class="title">--indent-labels / -L</code><br />Add extra indentation to labels so they appear 1 indent less than the current indentation, rather than being flushed to the left (the default).</p> <div class="code"> <pre>void Foo() <span class="brace">{</span> while (isFoo) <span class="brace">{</span> if (isFoo) goto error; ... error: ... <span class="brace">}</span> <span class="brace">}</span> </pre> <p class="code"> becomes (with indented 'error:'):</p> <pre>void Foo() <span class="brace">{</span> while (isFoo) <span class="brace">{</span> if (isFoo) goto error; ... error: ... <span class="brace">}</span> <span class="brace">}</span> </pre> </div> <p> </p> <p id="_indent-preprocessor"> <code class="title">--indent-preprocessor / -w</code><br />Indent multi-line preprocessor definitions ending with a backslash. Should be used with --convert-tabs for proper results. Does a pretty good job, but can not perform miracles in obfuscated preprocessor definitions. Without this option the preprocessor statements remain unchanged.</p> <div class="code"> <pre>#define Is_Bar(arg,a,b) \ (Is_Foo((arg), (a)) \ || Is_Foo((arg), (b))) </pre> <p class="code"> becomes:</p> <pre>#define Is_Bar(arg,a,b) \ (Is_Foo((arg), (a)) \ || Is_Foo((arg), (b))) </pre> </div> <p> </p> <p id="_indent-col1-comments"> <code class="title">--indent-col1-comments / -Y</code><br />Indent C++ comments beginning in column one. By default C++ comments beginning in column one are not indented. This option will allow the comments to be indented with the code. </p> <div class="code"> <pre>void Foo()\n" <span class="brace">{</span> // comment if (isFoo) bar(); <span class="brace">}</span> </pre> <p class="code"> becomes:</p> <pre>void Foo()\n" <span class="brace">{</span> // comment if (isFoo) bar(); <span class="brace">}</span> </pre> </div> <p> </p> <p id="_max-instatement-indent"> <code class="title">--max-instatement-indent=<span class="option">#</span> / -M<span class="option">#</span></code><br /> Indent a maximum of <span class="option">#</span> spaces in a continuous statement, relative to the previous line (e.g. ‑‑max‑instatement‑indent=40). <span class="option">#</span> must be less than <strong> 80</strong>. If no <span class="option">#</span> is set, the default value of <strong>40</strong> will be used. A maximum of less than two indent lengths will be ignored.</p> <div class="code"> <pre>fooArray[] = <span class="brace">{</span> red, green, blue <span class="brace">}</span>; fooFunction(barArg1, barArg2, barArg3); </pre> <p class="code">becomes (with larger value):</p> <pre>fooArray[] = <span class="brace">{</span> red, green, blue <span class="brace">}</span>; fooFunction(barArg1, barArg2, barArg3); </pre> </div> <p> </p> <p id="_min-conditional-indent"> <code class="title">--min-conditional-indent=<span class="option">#</span> / -m<span class="option">#</span></code><br /> Set the minimal indent that is added when a header is built of multiple-lines. This indent makes helps to easily separate the header from the command statements that follow. The value for <span class="option">#</span> must be less than <strong>40</strong>. The default setting for this option is <strong>twice the current indent</strong> (e.g. --min-conditional-indent=8).</p> <div class="code"> <pre><span class="comment">// default setting makes this non-bracketed code clear</span> if (a < b || c > d) foo++; <span class="comment">// but creates an exaggerated indent in this bracketed code</span> if (a < b || c > d) <span class="brace">{</span> foo++; <span class="brace">}</span> </pre> <p class="code"> becomes (when setting <strong><code>--min-conditional-indent=<span class="option">0</span></code></strong>):</p> <pre><span class="comment">// setting makes this non-bracketed code less clear</span> if (a < b || c > d) foo++; <span class="comment">// but makes this bracketed code clearer</span> if (a < b || c > d) <span class="brace">{</span> foo++; <span class="brace">}</span> </pre> </div> <p> </p> <hr /> <!-- * * * * * * * * * * * * * Padding Options * * * * * * * * * * * * * --> <h3 id="_Padding_Options"> Padding Options</h3> <p id="_break-blocks"> <code class="title">--break-blocks / -f</code><br />Pad empty lines around header blocks (e.g. '<code>if</code>', '<code>for</code>', '<code>while</code>'...).</p> <div class="code"> <pre>isFoo = true; if (isFoo) <span class="brace">{</span> bar(); <span class="brace">}</span> else <span class="brace">{</span> anotherBar(); <span class="brace">}</span> isBar = false; </pre> <p class="code"> becomes:</p> <pre>isFoo = true; if (isFoo) <span class="brace">{</span> bar(); <span class="brace">}</span> else <span class="brace">{</span> anotherBar(); <span class="brace">}</span> isBar = false; </pre> </div> <p> </p> <p id="_break-blocks=all"> <code class="title">--break-blocks=all / -F</code><br />Pad empty lines around header blocks (e.g. '<code>if</code>', '<code>for</code>', '<code>while</code>'...). Treat closing header blocks (e.g. '<code>else</code>', '<code>catch</code>') as stand-alone blocks.</p> <div class="code"> <pre>isFoo = true; if (isFoo) <span class="brace">{</span> bar(); <span class="brace">}</span> else <span class="brace">{</span> anotherBar(); <span class="brace">}</span> isBar = false; </pre> <p class="code"> becomes:</p> <pre>isFoo = true; if (isFoo) <span class="brace">{</span> bar(); <span class="brace">}</span> else <span class="brace">{</span> anotherBar(); <span class="brace">}</span> isBar = false; </pre> </div> <p> </p> <p id="_pad-oper"> <code class="title">--pad-oper / -p </code><br />Insert space padding around operators. Operators inside block parens [] are <strong>not</strong> padded. Any end of line comments will remain in the original column, if possible. Note that there is no option to unpad. Once padded, they stay padded.</p> <div class="code"> <pre>if (foo==2) a=bar((b-c)*a,*d--); </pre> <p class="code"> becomes:</p> <pre>if (foo == 2) a = bar((b - c) * a, * d--); </pre> </div> <p> </p> <p id="_pad-paren"> <code class="title">--pad-paren / -P </code><br />Insert space padding around parenthesis on both the <strong>outside</strong> and the <strong>inside</strong>. Any end of line comments will remain in the original column, if possible.</p> <div class="code"> <pre>if (isFoo(a, b)) bar(a, b); </pre> <p class="code"> becomes:</p> <pre>if ( isFoo ( a, b ) ) bar ( a, b ); </pre> </div> <p> </p> <p id="_pad-paren-out"> <code class="title">--pad-paren-out / -d </code><br />Insert space padding around parenthesis on the <strong>outside</strong> only. Any end of line comments will remain in the original column, if possible. This can be used with <code>unpad-paren</code> below to remove unwanted spaces.</p> <div class="code"> <pre>if (isFoo(a, b)) bar(a, b); </pre> <p class="code"> becomes:</p> <pre>if (isFoo (a, b) ) bar (a, b); </pre> </div> <p> </p> <p id="_pad-paren-in"> <code class="title">--pad-paren-in / -D </code><br />Insert space padding around parenthesis on the <strong>inside</strong> only. Any end of line comments will remain in the original column, if possible. This can be used with <code>unpad-paren</code> below to remove unwanted spaces.</p> <div class="code"> <pre>if (isFoo(a, b)) bar(a, b); </pre> <p class="code"> becomes:</p> <pre>if ( isFoo( a, b ) ) bar( a, b ); </pre> </div> <p> </p> <p id="_pad-header"> <code class="title">--pad-header / -H </code><br />Insert space padding after paren headers only (e.g. '<code>if</code>', '<code>for</code>', '<code>while</code>'...). Any end of line comments will remain in the original column, if possible. This can be used with <code>unpad-paren</code> to remove unwanted spaces.</p> <div class="code"> <pre>if(isFoo(a, b)) bar(a, b);</pre> <p class="code"> becomes:</p> <pre>if (isFoo(a, b)) bar(a, b); </pre> </div> <p> </p> <p id="_unpad-paren"> <code class="title">--unpad-paren / -U </code><br />Remove extra space padding around parenthesis on the inside and outside. Any end of line comments will remain in the original column, if possible. This option can be used in combination with the paren padding options <code>pad‑paren</code>, <code>pad‑paren‑out</code>, <code>pad‑paren‑in</code>, and <code>pad‑header</code> above. Only padding that has not been requested by other options will be removed.</p> <p> For example, if a source has parens padded on both the inside and outside, and you want inside only. You need to use <code>unpad-paren</code> to remove the outside padding, and <code>pad‑paren‑in</code> to retain the inside padding. Using only <code>pad‑paren‑in</code> would not remove the outside padding.</p> <div class="code"> <pre>if ( isFoo( a, b ) ) bar ( a, b ); </pre> <p class="code"> becomes (with no padding option requested):</p> <pre>if (isFoo(a, b)) bar(a, b); </pre> </div> <p> </p> <p id="_delete-empty-lines"> <code class="title">--delete-empty-lines / -x</code><br />Delete empty lines within a function or method. Empty lines outside of functions or methods are NOT deleted. If used with break-blocks or break-blocks=all it will delete all lines EXCEPT the lines added by the break-blocks options.</p> <div class="code"> <pre>void Foo() <span class="brace">{</span> foo1 = 1; foo2 = 2; <span class="brace">}</span> </pre> <p class="code"> becomes:</p> <pre>void Foo() <span class="brace">{</span> foo1 = 1; foo2 = 2; <span class="brace">}</span> </pre> </div> <p> </p> <p id="_fill-empty-lines"> <code class="title">--fill-empty-lines / -E</code><br />Fill empty lines with the white space of the previous line.</p> <p> </p> <hr /> <!-- * * * * * * * * * * * * * Formatting Options * * * * * * * * * * * * * --> <h3 id="_Formatting_Options"> Formatting Options</h3> <p id="_break-closing-brackets"> <code class="title">--break-closing-brackets / -y </code><br />When used with --brackets=attach, --brackets=linux, or --brackets=stroustrup, this breaks closing headers (e.g. 'else', 'catch', ...) from their immediately preceding closing brackets. Closing header brackets are always broken with broken brackets, horstmann brackets, indented blocks, and indented brackets.</p> <div class="code"> <pre>void Foo(bool isFoo) <span class="brace">{</span> if (isFoo) <span class="brace">{</span> bar(); <span class="brace">}</span> else <span class="brace">{</span> anotherBar(); <span class="brace">}</span> <span class="brace">}</span> </pre> <p class="code"> becomes (with a broken 'else'):</p> <pre>void Foo(bool isFoo) <span class="brace">{</span> if (isFoo) <span class="brace">{</span> bar(); <span class="brace">}</span> else <span class="brace">{</span> anotherBar(); <span class="brace">}</span> <span class="brace">}</span> </pre> </div> <p> </p> <p id="_break-elseifs"> <code class="title">--break-elseifs / -e</code><br />Break "else if" header combinations into separate lines. This option has no effect if keep-one-line-statements is used, the "else if" statements will remain as they are.</p> <p> If this option is NOT used, "else if" header combinations will be placed on a single line.</p> <div class="code"> <pre>if (isFoo) <span class="brace">{</span> bar(); <span class="brace">}</span> else if (isFoo1()) <span class="brace">{</span> bar1(); <span class="brace">}</span> else if (isFoo2()) <span class="brace">}</span> bar2; <span class="brace">}</span> </pre> <p class="code"> becomes:</p> <pre>if (isFoo) <span class="brace">{</span> bar(); <span class="brace">}</span> else if (isFoo1()) <span class="brace">{</span> bar1(); <span class="brace">}</span> <span class="brace"> </span> else if (isFoo2()) <span class="brace">{</span> bar2(); <span class="brace">}</span> </pre> </div> <p> </p> <p id="_add-brackets"> <code class="title">--add-brackets / -j </code><br />Add brackets to unbracketed one line conditional statements (e.g. '<code>if</code>', '<code>for</code>', '<code>while</code>'...). The statement must be on a single line. The brackets will be added according to the currently requested predefined style or bracket type. If no style or bracket type is requested the brackets will be attached. If --add-one-line-brackets is also used the result will be one line brackets.</p> <div class="code"> <pre>if (isFoo) isFoo = false; </pre> <p class="code"> becomes:</p> <pre>if (isFoo) <span class="brace">{</span> isFoo = false; <span class="brace">}</span> </pre> </div> <p> </p> <p id="_add-one-line-brackets"> <code class="title">--add-one-line-brackets / -J </code><br />Add one line brackets to unbracketed one line conditional statements (e.g. '<code>if</code>', '<code>for</code>', '<code>while</code>'...). The statement must be on a single line. The option implies --keep-one-line-blocks and will not break the one line blocks.</p> <div class="code"> <pre>if (isFoo) isFoo = false; </pre> <p class="code"> becomes:</p> <pre>if (isFoo) <span class="brace">{</span> isFoo = false; <span class="brace">}</span> </pre> </div> <p> </p> <p id="_keep-one-line-blocks"> <code class="title">--keep-one-line-blocks / -O </code><br />Don't break one-line blocks.</p> <div class="code"> <pre>if (isFoo) <span class="brace">{</span> isFoo = false; cout << isFoo << endl; <span class="brace">}</span> </pre> <p class="code"> remains unchanged.</p> </div> <p> </p> <p id="_keep-one-line-statements"> <code class="title">--keep-one-line-statements / -o </code><br />Don't break complex statements and multiple statements residing on a single line.</p> <div class="code"> <pre>if (isFoo) <span class="brace">{</span> isFoo = false; cout << isFoo << endl; <span class="brace">}</span> </pre> <p class="code"> remains unchanged.</p> <pre>if (isFoo) DoBar(); </pre> <p class="code"> remains unchanged.</p> </div> <p> </p> <p id="_convert-tabs"> <code class="title">--convert-tabs / -c</code><br />Converts tabs into spaces in the non-indentation part of the line. The number of spaces inserted will maintain the spacing of the tab. The current setting for spaces per tab is used. It may not produce the expected results if convert-tabs is used when changing spaces per tab. Tabs are not replaced in quotes.</p> <p> </p> <p id="_align-pointer"> <code class="title">--align-pointer=type / -k1<br />--align-pointer=middle / -k2<br />--align-pointer=name / -k3</code><br />Attach a pointer or reference operator (* or &) to either the variable type (left) or variable name (right), or place it between the type and name. The spacing between the type and name will be preserved, if possible. This option is effective for C/C++ files only.</p> <div class="code"> <pre>char *foo1;</pre> <p class="code"> becomes (with align-pointer=type):</p> <pre>char* foo1;</pre> </div> <div class="code"> <pre>char* foo2;</pre> <p class="code"> becomes (with align-pointer=middle):</p> <pre>char * foo2;</pre> </div> <div class="code"> <pre>char& foo3;</pre> <p class="code"> becomes (with align-pointer=name):</p> <pre>char &foo3;</pre> </div> <p> </p> <p id="_mode"> <code class="title">--mode=c</code><br /><code class="title">--mode=cs</code><br /><code class="title">--mode=java</code><br /> Indent a C/C++, C#, or Java file. The option is usually set from the file extension for each file. You can override the setting with this entry. It will be used for all files regardless of the file extension. It allows the formatter to identify language specific syntax such as C++ classes, templates, and keywords.</p> <p> </p> <hr /> <!-- * * * * * * * * * * * * * Other Options * * * * * * * * * * * * * --> <h3 id="_Other_Options"> Other Options</h3> <p id="_suffix"> <code class="title">--suffix=<span class="option">####</span></code><br />Append the suffix #### instead of '.orig' to original filename (e.g. <code>--suffix=<span class="option">.bak</span></code>). If this is to be a file extension, the dot '.' must be included. Otherwise the suffix will be appended to the current file extension.</p> <p id="_suffix=none"> <code class="title">--suffix=none / -n</code><br />Do not retain a backup of the original file. The original file is purged after it is formatted.</p> <p id="_options"> <code class="title">--options=<span class="option">####</span></code><br />Specify an options file #### to read and use.</p> <p id="_options=none"> <code class="title">--options=none</code><br />Disable the default options file. Only the command-line parameters will be used.</p> <p id="_recursive"> <code class="title">--recursive / -r / -R</code><br />For each directory in the command line, process all subdirectories recursively. When using the recursive option the file name statement should contain a wildcard. Linux users should place the filepath and name in double quotes so the shell will not resolve the wildcards (e.g. "$HOME/src/*.cpp"). Windows users should place the filepath and name in double quotes if the path or name contains spaces.</p> <p id="_exclude"> <code class="title">--exclude=<span class="option">####</span></code><br />Specify a file or sub directory #### to be excluded from processing. </p> <p> Excludes are matched from the end of the filepath. An exclude option of "templates" will exclude ALL directories named "templates". An exclude option of "cpp/templates" will exclude ALL "cpp/templates" directories. You may proceed backwards in the directory tree to exclude only the required directories.</p> <p> Specific files may be excluded in the same manner. An exclude option of "default.cpp" will exclude ALL files named "default.cpp". An exclude option of "python/default.cpp" will exclude ALL files named "default.cpp" contained in a "python" subdirectory. You may proceed backwards in the directory tree to exclude only the required files.</p> <p> Wildcards are NOT allowed. There may be more than one exclude statement. The filepath and name may be placed in double quotes (e.g. ‑‑exclude="foo bar.cpp").</p> <p id="_errors-to-stdout"> <code class="title">--errors-to-stdout / -X</code><br />Print errors to standard-output rather than to standard-error.<br /> This option should be helpful for systems/shells that do not have this option, such as in Windows95.</p> <p id="_preserve-date"> <code class="title">--preserve-date / -Z</code><br />Preserve the original file's date and time modified. The date and time modified will not be changed in the formatted file. This option is not effective if redirection is used to rename the input file.</p> <p id="_verbose"> <code class="title">--verbose / -v</code><br />Verbose display mode. Display optional information, such as release number and statistical data.</p> <p id="_formatted"> <code class="title">--formatted / -Q</code><br />Formatted files display mode. Display only the files that have been formatted. Do not display files that are unchanged.</p> <p id="_quiet"> <code class="title">--quiet / -q</code><br />Quiet display mode. Suppress all output except error messages.</p> <p id="_lineend"> <code class="title">--lineend=windows / -z1<br />--lineend=linux / -z2<br />--lineend=macold / -z3</code><br />Force use of the specified line end style. Valid options are windows (CRLF), linux (LF), and macold (CR). MacOld style is the format for OS 9 and earlier. Mac OS X uses the Linux style. If one of these options is not used the line ends will be determined automatically from the input file.</p> <p id="_version"> <code class="title">--version / -V</code><br />Print version number and quit. The short option must be by itself, it cannot be concatenated with other options.</p> <p id="_help"> <code class="title">--help / -h / -?</code><br />Print a help message and quit. The short option must be by itself, it cannot be concatenated with other options.</p> <p> </p> <hr style="margin-left: -0.4in;" /> <center class="footer"> <table width="100%"> <col width="30%" /> <col width="40%" /> <col width="30%" /> <tr><td align="left"><a href="http://www.gnu.org/copyleft/lesser.html"> <img src="http://www.gnu.org/graphics/lgplv3-88x31.png" alt="[LGPLv3]" /></a> <a href="http://www.gnu.org/licenses/gpl.html"> <img src="http://www.gnu.org/graphics/gplv3-88x31.png" alt="[GPLv3]" /></a></td> <td align="center" style="color: #0000A0; font-size: x-large; font-weight: bold;">ENJOY !!!</td> <td align="right"><a href="http://sourceforge.net/projects/astyle"> <img src="http://sflogo.sourceforge.net/sflogo.php?group_id=2319&type=11" width="120" height="30" alt="[SourceForge.net]" /></a> </td> </tr> </table> </center> <p> </p> <p> </p> <!-- CUT HERE FOR INSERTION INTO SOURCEFORGE DOC MANAGER --> </body> </html>