SMIL  1.1
Programming Style

Table of Contents

Generalities

To be done

Code Formatting

Code formatting isn't just an aesthetic issue. An homogeneous and clear presentation contributes to unambigous and easy understanding.

The code style is that proposed by LLVM with some small enhancements. And the tool is clang-format.

Formatting is done simply with the following commands, the first one just creates a backup copy before formatting, inplace, the original source code :

$ cp -p filename filename.bak
$ clang-format -i -style=file filename

Obs :

  • no problem if you don't follow this style. It's enough to run the formatter on the final version of your file, before integrating it to the master or develop branch;
  • the choosen style has minors differences from LLVM style. These differences are set at .clang-format file placed at the root of source file tree :
    AlignConsecutiveAssignments:             true
    AlignConsecutiveDeclarations:            true
    AllowShortBlocksOnASingleLine:           false
    AllowShortFunctionsOnASingleLine:        false
    AllowShortIfStatementsOnASingleLine:     false
    AlwaysBreakTemplateDeclarations:         true
    BreakBeforeBraces:                       Linux
    #BreakBeforeBraces:                      Allman
    IndentCaseLabels:                        true
    KeepEmptyLinesAtTheStartOfBlocks:        false
    NamespaceIndentation:                    All
    PenaltyBreakString:                      1000
    SortIncludes:                            false
    SortUsingDeclarations:                   false
    SpaceAfterCStyleCast:                    true
    Standard:                                Cpp11
    TabWidth:                                2
    
  • clang-format packaged as :
    • Ubuntu : clang-format
    • CentOS/RedHat/Fedora : clang
  • clang-format documentation can be found here