coding style adherence

- markup codingStyleGuide.org examples so they actually indent correctly

- use 'Info<<' as per codingStyleGuide instead of 'Info <<'
This commit is contained in:
Mark Olesen
2009-11-27 15:39:14 +01:00
parent 51bdcca506
commit fa93ce8cd7
235 changed files with 702 additions and 634 deletions

View File

@ -108,8 +108,7 @@ int main()
Info<< " badName(die) => " << findEtcFile("badName", true) << nl Info<< " badName(die) => " << findEtcFile("badName", true) << nl
<< endl; << endl;
Info<< "\nEnd" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -95,8 +95,7 @@ int main(int argc, char *argv[])
printCleaning(pathName); printCleaning(pathName);
} }
Info<< "\nEnd" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -102,8 +102,7 @@ int main(int argc, char *argv[])
Info<< "Ostream<< >" << s2 << "<\n"; Info<< "Ostream<< >" << s2 << "<\n";
Info<< "hash:" << hex << string::hash()(s2) << endl; Info<< "hash:" << hex << string::hash()(s2) << endl;
Info << "End\n" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -131,8 +131,7 @@ int main(int argc, char *argv[])
psf.write(); psf.write();
Info << nl << "End" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -661,8 +661,7 @@ int main(int argc, char *argv[])
} }
Info << nl << "End" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -355,8 +355,7 @@ int main(int argc, char *argv[])
<< nl << endl; << nl << endl;
} }
Info << nl << "End" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -1356,7 +1356,7 @@ int main(int argc, char *argv[])
mesh.write(); mesh.write();
Info<< nl << "End" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -1729,7 +1729,7 @@ int main(int argc, char *argv[])
} }
} }
Info<< nl << "End" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -867,7 +867,7 @@ int main(int argc, char *argv[])
Info<< "Writing polyMesh" << endl; Info<< "Writing polyMesh" << endl;
pShapeMesh.write(); pShapeMesh.write();
Info<< nl << "End" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -64,7 +64,7 @@ int main(int argc, char *argv[])
Info<< "Writing mesh" << endl; Info<< "Writing mesh" << endl;
makeMesh.writeMesh(); makeMesh.writeMesh();
Info<< nl << "End" << nl << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -64,7 +64,7 @@ int main(int argc, char *argv[])
Info<< "Writing mesh" << endl; Info<< "Writing mesh" << endl;
makeMesh.writeMesh(); makeMesh.writeMesh();
Info<< nl << "End" << nl << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -382,7 +382,7 @@ int main(int argc, char *argv[])
} }
} }
Info<< nl << "End" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -189,7 +189,7 @@ int main(int argc, char *argv[])
currentSet.write(); currentSet.write();
} }
Info << nl << "End" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -189,7 +189,7 @@ int main(int argc, char *argv[])
currentSet.write(); currentSet.write();
} }
Info << nl << "End" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -77,7 +77,7 @@ int main(int argc, char *argv[])
masterMesh.merge(); masterMesh.merge();
masterMesh.polyMesh::write(); masterMesh.polyMesh::write();
Info << nl << "End" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -189,7 +189,7 @@ int main(int argc, char *argv[])
currentSet.write(); currentSet.write();
} }
Info << nl << "End" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -992,7 +992,7 @@ int main(int argc, char *argv[])
delete fileStreamPtr; delete fileStreamPtr;
} }
Pout<< "\nEnd" << endl; Pout<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -341,7 +341,7 @@ int main(int argc, char *argv[])
<< exit(FatalError); << exit(FatalError);
} }
Info<< nl << "End" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -439,7 +439,7 @@ int main(int argc, char *argv[])
} }
Info << nl << "End" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -83,7 +83,7 @@ int main(int argc, char *argv[])
Info<< "\nVmax = " << Vmax; Info<< "\nVmax = " << Vmax;
Info<< ", Vmin = " << Vmin << endl; Info<< ", Vmin = " << Vmin << endl;
Info<< "Vmax/Vmin = " << Vmax/Vmin << endl; Info<< "Vmax/Vmin = " << Vmax/Vmin << endl;
Info<< "\nEnd" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -90,7 +90,7 @@ int main(int argc, char *argv[])
# include "collapse.H" # include "collapse.H"
} }
Info<< "\nEnd" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -101,7 +101,7 @@ int main(int argc, char *argv[])
} }
} }
Info<< "\nEnd" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -89,7 +89,7 @@ int main(int argc, char *argv[])
Info<< nl << "ClockTime = " << runTime.elapsedClockTime() << " s" Info<< nl << "ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl; << nl << endl;
Info << nl << "End\n" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -235,7 +235,7 @@ int main(int argc, char *argv[])
); );
} }
Info<< "\nEnd" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -41,8 +41,7 @@ int main(int argc, char *argv[])
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info << "End\n" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -12,27 +12,36 @@
+ 80 character lines max + 80 character lines max
+ The body of control statements (eg, if, else, while, etc). + The body of control statements (eg, if, else, while, etc).
always delineated with brace brackets always delineated with brace brackets
+ Use spaces for indentation, not tab characters.
+ The normal indentation is 4 spaces per logical level.
+ Avoid trailing whitespace.
+ stream output + stream output
<< is always four characters after the start of the stream, so that the << << is always four characters after the start of the stream,
symbols align, i.e. so that the << symbols align, i.e.
Info<<
os <<
#+BEGIN_EXAMPLE
Info<< ...
os << ...
#+END_EXAMPLE
so so
#+BEGIN_EXAMPLE
WarningIn("className::functionName()") WarningIn("className::functionName()")
<< "Warning message" << "Warning message"
#+END_EXAMPLE
NOT NOT
#+BEGIN_EXAMPLE
WarningIn("className::functionName()") WarningIn("className::functionName()")
<< "Warning message" << "Warning message"
#+END_EXAMPLE
+ no unnecessary class section headers, i.e. remove + no unnecessary class section headers, i.e. remove
#+BEGIN_EXAMPLE
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Check // Check
@ -40,20 +49,25 @@
// Edit // Edit
// Write // Write
#+END_EXAMPLE
if they contain nothing, even if planned for 'future use' if they contain nothing, even if planned for 'future use'
+ class titles are centred + class titles are centred
#+BEGIN_EXAMPLE
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class exampleClass Declaration Class exampleClass Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#+END_EXAMPLE
NOT NOT
#+BEGIN_EXAMPLE
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class exampleClass Declaration Class exampleClass Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#+END_EXAMPLE
*** .H Files *** .H Files
+ header file spacing + header file spacing
@ -64,20 +78,25 @@
+ destructor + destructor
If adding a comment to the destructor - use //- and code as a normal function: If adding a comment to the destructor - use //- and code as a normal function:
#+BEGIN_EXAMPLE
//- Destructor //- Destructor
~className(); ~className();
#+END_EXAMPLE
+ inline functions + inline functions
Use inline functions where appropriate in a separate classNameI.H file. Use inline functions where appropriate in a separate classNameI.H file.
Do not clutter up the header file with function bodies Avoid cluttering the header file with function bodies.
*** .C Files *** .C Files
+ Do not open/close namespaces in a .C file + Do not open/close namespaces in a .C file
Fully scope the function name, i.e. Fully scope the function name, i.e.
#+BEGIN_EXAMPLE
Foam::returnType Foam::className::functionName() Foam::returnType Foam::className::functionName()
#+END_EXAMPLE
NOT NOT
#+BEGIN_EXAMPLE
namespace Foam namespace Foam
{ {
... ...
@ -86,12 +105,14 @@
... ...
} }
#+END_EXAMPLE
EXCEPTION EXCEPTION
When there are multiple levels of namespace, they may be used in the .C When there are multiple levels of namespace, they may be used in the .C
file, i.e. file, i.e.
#+BEGIN_EXAMPLE
namespace Foam namespace Foam
{ {
namespace compressible namespace compressible
@ -104,33 +125,41 @@
} // End namespace RASModels } // End namespace RASModels
} // End namespace compressible } // End namespace compressible
} // End namespace Foam } // End namespace Foam
#+END_EXAMPLE
+ Use two empty lines between functions + Use two empty lines between functions
*** Coding Practise *** Coding Practise
+ passing data as arguments or return + passing data as arguments or return
Pass label and scalar as copy, anything bigger by reference Pass bool, label and scalar as copy, anything larger by reference.
+ const + const
Use everywhere it is applicable. Use everywhere it is applicable.
+ variable initialisation using "=" + variable initialisation using "="
#+BEGIN_EXAMPLE
const className& variableName = otherClass.data(); const className& variableName = otherClass.data();
#+END_EXAMPLE
NOT NOT
#+BEGIN_EXAMPLE
const className& variableName(otherClass.data()); const className& variableName(otherClass.data());
#+END_EXAMPLE
+ virtual functions + virtual functions
If a class is virtual - make all derived classes virtual. If a class is virtual - make all derived classes virtual.
*** Conditional Statements *** Conditional Statements
#+BEGIN_EXAMPLE
if (condition) if (condition)
{ {
code; code;
} }
#+END_EXAMPLE
OR OR
#+BEGIN_EXAMPLE
if if
( (
long condition long condition
@ -138,22 +167,28 @@
{ {
code; code;
} }
#+END_EXAMPLE
NOT (no space between "if" and "(") NOT (no space between "if" and "(")
#+BEGIN_EXAMPLE
if(condition) if(condition)
{ {
code; code;
} }
#+END_EXAMPLE
*** `for' Loops *** `for' Loops
#+BEGIN_EXAMPLE
for (i = 0; i < maxI; i++) for (i = 0; i < maxI; i++)
{ {
code; code;
} }
#+END_EXAMPLE
OR OR
#+BEGIN_EXAMPLE
for for
( (
i = 0; i = 0;
@ -163,86 +198,111 @@
{ {
code; code;
} }
#+END_EXAMPLE
NOT (no space between "for" and "(") NOT (no space between "for" and "(")
#+BEGIN_EXAMPLE
for(i = 0; i < maxI; i++) for(i = 0; i < maxI; i++)
{ {
code; code;
} }
#+END_EXAMPLE
*** `forAll' loops *** `forAll' loops
like for loops, but like for loops, but
#+BEGIN_EXAMPLE
forAll( forAll(
#+END_EXAMPLE
NOT NOT
#+BEGIN_EXAMPLE
forAll ( forAll (
#+END_EXAMPLE
*** Splitting Over Multiple Lines *** Splitting Over Multiple Lines
+ splitting return type and function name + splitting return type and function name
+ split initially after the function return type and left align + split initially after the function return type and left align
+ do not put "const" onto it's own line - use a split to keep it with the + do not put "const" onto its own line - use a split to keep it with the
function name and arguments. function name and arguments.
so: so:
#+BEGIN_EXAMPLE
const Foam::longReturnTypeName& const Foam::longReturnTypeName&
Foam::longClassName::longFunctionName const Foam::longClassName::longFunctionName const
#+END_EXAMPLE
NOT NOT
#+BEGIN_EXAMPLE
const Foam::longReturnTypeName& const Foam::longReturnTypeName&
Foam::longClassName::longFunctionName const Foam::longClassName::longFunctionName const
#+END_EXAMPLE
NOR NOR
#+BEGIN_EXAMPLE
const Foam::longReturnTypeName& Foam::longClassName::longFunctionName const Foam::longReturnTypeName& Foam::longClassName::longFunctionName
const const
#+END_EXAMPLE
NOR NOR
#+BEGIN_EXAMPLE
const Foam::longReturnTypeName& Foam::longClassName:: const Foam::longReturnTypeName& Foam::longClassName::
longFunctionName const longFunctionName const
#+END_EXAMPLE
+ if need to split again, split at the function name (leaving behind the + if need to split again, split at the function name (leaving behind the
preceding scoping "::"'s), and again, left align, i.e. preceding scoping "::"s), and again, left align, i.e.
#+BEGIN_EXAMPLE
const Foam::longReturnTypeName& const Foam::longReturnTypeName&
Foam::veryveryveryverylongClassName:: Foam::veryveryveryverylongClassName::
veryveryveryverylongFunctionName const veryveryveryverylongFunctionName const
#+END_EXAMPLE
+ splitting long lines at an "=" + splitting long lines at an "="
Indent after split Indent after split
#+BEGIN_EXAMPLE
variableName = variableName =
longClassName.longFunctionName(longArgument); longClassName.longFunctionName(longArgument);
#+END_EXAMPLE
OR (where necessary) OR (where necessary)
#+BEGIN_EXAMPLE
variableName = variableName =
longClassName.longFunctionName longClassName.longFunctionName
( (
longArgument1, longArgument1,
longArgument2 longArgument2
); );
#+END_EXAMPLE
NOT NOT
#+BEGIN_EXAMPLE
variableName = variableName =
longClassName.longFunctionName(longArgument); longClassName.longFunctionName(longArgument);
#+END_EXAMPLE
NOR NOR
#+BEGIN_EXAMPLE
variableName = longClassName.longFunctionName variableName = longClassName.longFunctionName
( (
longArgument1, longArgument1,
longArgument2 longArgument2
); );
#+END_EXAMPLE
*** Maths and Logic *** Maths and Logic
+ operator spacing + operator spacing
@ -258,18 +318,34 @@
with the operator on the lower line. Align operator so that first with the operator on the lower line. Align operator so that first
variable, function or bracket on the next line is 4 spaces indented i.e. variable, function or bracket on the next line is 4 spaces indented i.e.
#+BEGIN_EXAMPLE
variableName = variableName =
a * (a + b) a * (a + b)
- exp(c/d) - exp(c/d)
* (k + t);
#+END_EXAMPLE
This is sometime more legible when surrounded by extra parentheses:
#+BEGIN_EXAMPLE
variableName =
(
a * (a + b)
- exp(c/d)
* (k + t) * (k + t)
);
#+END_EXAMPLE
+ splitting logical tests over several lines + splitting logical tests over several lines
indent operator so that the next variable to test is aligned with the outdent the operator so that the next variable to test is aligned with
four space indentation, i.e. the four space indentation, i.e.
#+BEGIN_EXAMPLE
if if
( (
a == true a == true
&& b == c && b == c
) )
#+END_EXAMPLE

View File

@ -39,7 +39,7 @@ Foam::dictionaryEntry::dictionaryEntry
Istream& is Istream& is
) )
: :
entry(is), entry(keyType(is)),
dictionary(parentDict, is) dictionary(parentDict, is)
{ {
is.fatalCheck is.fatalCheck

View File

@ -38,7 +38,6 @@ Foam::entry::entry(const keyType& keyword)
Foam::entry::entry(const entry& e) Foam::entry::entry(const entry& e)
: :
IDLList<entry>::link(),
keyword_(e.keyword_) keyword_(e.keyword_)
{} {}

View File

@ -77,7 +77,7 @@ class entry
// Private Member Functions // Private Member Functions
//- Get the next valid keyword otherwise return false //- Get the next valid keyword otherwise return false
static bool getKeyword(keyType& keyword, Istream& is); static bool getKeyword(keyType&, Istream&);
public: public:
@ -85,7 +85,7 @@ public:
// Constructors // Constructors
//- Construct from keyword //- Construct from keyword
entry(const keyType& keyword); entry(const keyType&);
//- Construct as copy //- Construct as copy
entry(const entry&); entry(const entry&);
@ -102,7 +102,7 @@ public:
virtual autoPtr<entry> clone() const; virtual autoPtr<entry> clone() const;
//- Construct from Istream and insert into dictionary //- Construct from Istream and insert into dictionary
static bool New(dictionary& parentDict, Istream& is); static bool New(dictionary& parentDict, Istream&);
//- Construct on freestore from Istream and return //- Construct on freestore from Istream and return
static autoPtr<entry> New(Istream& is); static autoPtr<entry> New(Istream& is);