| | 1 | = Coding Style = |
| | 2 | |
| | 3 | = General rules = |
| | 4 | |
| | 5 | - Code lines should not be longer than 80 characters |
| | 6 | - The formatting in general should be something similar to that Emacs C++-mode does by default. I.e. |
| | 7 | - use two spaces for indenting. |
| | 8 | |
| | 9 | == Naming Conventions == |
| | 10 | |
| | 11 | In order to make development easier we have made some conventions |
| | 12 | according to coding style. These include names of types, classes, |
| | 13 | functions, variables, constants and exceptions. If these conventions |
| | 14 | are met in one's code then it is easier to read and maintain |
| | 15 | it. Please comply with these conventions if you want to contribute |
| | 16 | developing LEMON library. |
| | 17 | |
| | 18 | '''Note:''' When the coding style requires the capitalization of an abbreviation, |
| | 19 | only the first letter should be upper case. |
| | 20 | |
| | 21 | {{{ |
| | 22 | #!cpp |
| | 23 | XmlReader |
| | 24 | }}} |
| | 25 | |
| | 26 | |
| | 27 | '''Warning:''' In some cases we diverge from these rules. |
| | 28 | This is primary done because STL uses different naming convention and |
| | 29 | in certain cases |
| | 30 | it is beneficial to provide STL compatible interface. |
| | 31 | |
| | 32 | === File names === |
| | 33 | |
| | 34 | The header file names should look like the following. |
| | 35 | |
| | 36 | {{{ |
| | 37 | #!cpp |
| | 38 | header_file.h |
| | 39 | }}} |
| | 40 | |
| | 41 | Note that all standard LEMON headers are located in the {{{lemon}}} subdirectory, |
| | 42 | so you should include them from C++ source like this: |
| | 43 | |
| | 44 | {{{ |
| | 45 | #!cpp |
| | 46 | #include <lemon/header_file.h> |
| | 47 | }}} |
| | 48 | |
| | 49 | The source code files use the same style and they have '.cc' extension. |
| | 50 | |
| | 51 | {{{ |
| | 52 | #!cpp |
| | 53 | source_code.cc |
| | 54 | }}} |
| | 55 | |
| | 56 | === Classes and other types === |
| | 57 | |
| | 58 | The name of a class or any type should look like the following. |
| | 59 | |
| | 60 | {{{ |
| | 61 | #!cpp |
| | 62 | AllWordsCapitalizedWithoutUnderscores |
| | 63 | }}} |
| | 64 | |
| | 65 | === Methods and other functions === |
| | 66 | |
| | 67 | The name of a function should look like the following. |
| | 68 | |
| | 69 | {{{ |
| | 70 | #!cpp |
| | 71 | firstWordLowerCaseRestCapitalizedWithoutUnderscores |
| | 72 | }}} |
| | 73 | |
| | 74 | === Constants and macros === |
| | 75 | |
| | 76 | The names of constants and macros should look like the following. |
| | 77 | |
| | 78 | {{{ |
| | 79 | #!cpp |
| | 80 | ALL_UPPER_CASE_WITH_UNDERSCORES |
| | 81 | }}} |
| | 82 | |
| | 83 | === Class and instance member variables, auto variables === |
| | 84 | |
| | 85 | The names of class and instance member variables and auto variables (=variables used locally in methods) should look like the following. |
| | 86 | |
| | 87 | {{{ |
| | 88 | #!cpp |
| | 89 | all_lower_case_with_underscores |
| | 90 | }}} |
| | 91 | |
| | 92 | === Private member variables === |
| | 93 | |
| | 94 | Private member variables should start with underscore |
| | 95 | |
| | 96 | {{{ |
| | 97 | #!cpp |
| | 98 | _start_with_underscores |
| | 99 | }}} |
| | 100 | |
| | 101 | === Exceptions === |
| | 102 | |
| | 103 | When writing exceptions please comply the following naming conventions. |
| | 104 | |
| | 105 | {{{ |
| | 106 | #!cpp |
| | 107 | ClassNameEndsWithException |
| | 108 | }}} |
| | 109 | |
| | 110 | or |
| | 111 | |
| | 112 | {{{ |
| | 113 | #!cpp |
| | 114 | ClassNameEndsWithError |
| | 115 | }}} |
| | 116 | |
| | 117 | == Template header file == |
| | 118 | |
| | 119 | Each LEMON header file should look like this: |
| | 120 | |
| | 121 | {{{ |
| | 122 | #!cpp |
| | 123 | /* -*- C++ -*- |
| | 124 | * |
| | 125 | * This file is a part of LEMON, a generic C++ optimization library |
| | 126 | * |
| | 127 | * Copyright (C) 2003-2008 |
| | 128 | * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
| | 129 | * (Egervary Research Group on Combinatorial Optimization, EGRES). |
| | 130 | * |
| | 131 | * Permission to use, modify and distribute this software is granted |
| | 132 | * provided that this copyright notice appears in all copies. For |
| | 133 | * precise terms see the accompanying LICENSE file. |
| | 134 | * |
| | 135 | * This software is provided "AS IS" with no warranty of any kind, |
| | 136 | * express or implied, and with no claim as to its suitability for any |
| | 137 | * purpose. |
| | 138 | * |
| | 139 | */ |
| | 140 | |
| | 141 | #ifndef LEMON_TEMPLATE_H |
| | 142 | #define LEMON_TEMPLATE_H |
| | 143 | |
| | 144 | #endif // LEMON_TEMPLATE_H |
| | 145 | }}} |