4 KAlarm code should adhere to the following stylistic rules.
9 - Indent with 4 spaces.
10 - No spaces inside round or square brackets.
11 - No space between a function name and the bracket following.
12 - Place '*' and '&' immediately after the type in declarations, followed by a
13 space, e.g. "const QString& from", "char* str".
14 - Normally two spaces on each side of "&&" and "||" in "if"/"while"/"for"
16 - Indent "case" within "switch" statements.
20 - Opening brace on a new line.
21 - No braces are used when only a single statement follows 'if', 'for' etc.
25 - There is in general no need to split lines less than 120 characters. Beyond
26 that length, it's at the coder's discretion.
27 - Conditional statements occupying line lengths less than 120 characters may be
29 - Long "for" statements should be split before each clause at least.
30 - If a function call or declaration has to be split over more than one line,
31 indent to after the opening bracket if possible.
32 - If splitting lines containing expressions, always split BEFORE an operator
33 ("+", "-", "&&" etc.) so that the operator starts the next continuation line.
34 - In split conditional expressions, position the leading "&&" or "||" before
35 its enclosing bracket, so that the following expression aligns after the
40 - Classes, enums, functions and variable names are in camel case (i.e.
41 separate multiple words by upper-casing each word after the first). Only
42 use underscores for special purposes.
43 - Classes and enum names start with an upper case letter.
44 - Function and variable names start with a lower case letter.
45 - Enum values are either all upper case with words separated by underscores, or
46 camel case starting with an upper case letter.
47 - Constants are all upper case, with words separated by underscores.
48 - Class member variable names start with "m" followed by a upper case letter.
52 Animal ZooCage::releaseAnimal(const QString& name, Species species,
53 int arrivalNumber) const
56 && (arrivalNumber > mMinimumSpeciesCount && arrivalNumber < mMaximumSpeciesCount)
59 mLastReleased = Animal(species, name, arrivalNumber);
60 return mAnimals[name][arrivalNumber];
62 if (name.isEmpty() || mUnclassifiedAnimals.contains(name))
63 return mUnclassifiedAnimalTypes[species];