Warning, /pim/kalarm/CODING_STYLE is written in an unsupported language. File is not indexed.
0001 KAlarm coding style 0002 =================== 0003 0004 KAlarm code should adhere to the following stylistic rules. 0005 0006 SPACING 0007 0008 - No tabs. 0009 - Indent with 4 spaces. 0010 - No spaces inside round or square brackets. 0011 - No space between a function name and the bracket following. 0012 - Place '*' and '&' immediately after the type in declarations, followed by a 0013 space, e.g. "const QString& from", "char* str". 0014 - Normally two spaces on each side of "&&" and "||" in "if"/"while"/"for" 0015 statements. 0016 - Indent "case" within "switch" statements. 0017 0018 BRACES 0019 0020 - Opening brace on a new line. 0021 - No braces are used when only a single statement follows 'if', 'for' etc. 0022 0023 SPLITTING LINES 0024 0025 - There is in general no need to split lines less than 120 characters. Beyond 0026 that length, it's at the coder's discretion. 0027 - Conditional statements occupying line lengths less than 120 characters may be 0028 split for clarity. 0029 - Long "for" statements should be split before each clause at least. 0030 - If a function call or declaration has to be split over more than one line, 0031 indent to after the opening bracket if possible. 0032 - If splitting lines containing expressions, always split BEFORE an operator 0033 ("+", "-", "&&" etc.) so that the operator starts the next continuation line. 0034 - In split conditional expressions, position the leading "&&" or "||" before 0035 its enclosing bracket, so that the following expression aligns after the 0036 opening bracket. 0037 0038 NAMING 0039 0040 - Classes, enums, functions and variable names are in camel case (i.e. 0041 separate multiple words by upper-casing each word after the first). Only 0042 use underscores for special purposes. 0043 - Classes and enum names start with an upper case letter. 0044 - Function and variable names start with a lower case letter. 0045 - Enum values are either all upper case with words separated by underscores, or 0046 camel case starting with an upper case letter. 0047 - Constants are all upper case, with words separated by underscores. 0048 - Class member variable names start with "m" followed by a upper case letter. 0049 0050 EXAMPLE 0051 0052 Animal ZooCage::releaseAnimal(const QString& name, Species species, 0053 int arrivalNumber) const 0054 { 0055 if (!name.isEmpty() 0056 && (arrivalNumber > mMinimumSpeciesCount && arrivalNumber < mMaximumSpeciesCount) 0057 || !arrivalNumber) 0058 { 0059 mLastReleased = Animal(species, name, arrivalNumber); 0060 return mAnimals[name][arrivalNumber]; 0061 } 0062 if (name.isEmpty() || mUnclassifiedAnimals.contains(name)) 0063 return mUnclassifiedAnimalTypes[species]; 0064 return Animal(); 0065 }