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
<< endl;
Info<< "\nEnd" << endl;
Info<< "\nEnd\n" << endl;
return 0;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -12,27 +12,36 @@
+ 80 character lines max
+ The body of control statements (eg, if, else, while, etc).
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
<< is always four characters after the start of the stream, so that the <<
symbols align, i.e.
Info<<
os <<
<< is always four characters after the start of the stream,
so that the << symbols align, i.e.
#+BEGIN_EXAMPLE
Info<< ...
os << ...
#+END_EXAMPLE
so
#+BEGIN_EXAMPLE
WarningIn("className::functionName()")
<< "Warning message"
#+END_EXAMPLE
NOT
#+BEGIN_EXAMPLE
WarningIn("className::functionName()")
<< "Warning message"
#+END_EXAMPLE
+ no unnecessary class section headers, i.e. remove
#+BEGIN_EXAMPLE
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Check
@ -40,20 +49,25 @@
// Edit
// Write
#+END_EXAMPLE
if they contain nothing, even if planned for 'future use'
+ class titles are centred
#+BEGIN_EXAMPLE
/*---------------------------------------------------------------------------*\
Class exampleClass Declaration
\*---------------------------------------------------------------------------*/
#+END_EXAMPLE
NOT
#+BEGIN_EXAMPLE
/*---------------------------------------------------------------------------*\
Class exampleClass Declaration
\*---------------------------------------------------------------------------*/
#+END_EXAMPLE
*** .H Files
+ header file spacing
@ -64,20 +78,25 @@
+ destructor
If adding a comment to the destructor - use //- and code as a normal function:
#+BEGIN_EXAMPLE
//- Destructor
~className();
#+END_EXAMPLE
+ inline functions
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
+ Do not open/close namespaces in a .C file
Fully scope the function name, i.e.
#+BEGIN_EXAMPLE
Foam::returnType Foam::className::functionName()
#+END_EXAMPLE
NOT
#+BEGIN_EXAMPLE
namespace Foam
{
...
@ -86,12 +105,14 @@
...
}
#+END_EXAMPLE
EXCEPTION
When there are multiple levels of namespace, they may be used in the .C
file, i.e.
#+BEGIN_EXAMPLE
namespace Foam
{
namespace compressible
@ -104,33 +125,41 @@
} // End namespace RASModels
} // End namespace compressible
} // End namespace Foam
#+END_EXAMPLE
+ Use two empty lines between functions
*** Coding Practise
+ 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
Use everywhere it is applicable.
+ variable initialisation using "="
#+BEGIN_EXAMPLE
const className& variableName = otherClass.data();
#+END_EXAMPLE
NOT
#+BEGIN_EXAMPLE
const className& variableName(otherClass.data());
#+END_EXAMPLE
+ virtual functions
If a class is virtual - make all derived classes virtual.
*** Conditional Statements
#+BEGIN_EXAMPLE
if (condition)
{
code;
}
#+END_EXAMPLE
OR
#+BEGIN_EXAMPLE
if
(
long condition
@ -138,22 +167,28 @@
{
code;
}
#+END_EXAMPLE
NOT (no space between "if" and "(")
#+BEGIN_EXAMPLE
if(condition)
{
code;
}
#+END_EXAMPLE
*** `for' Loops
#+BEGIN_EXAMPLE
for (i = 0; i < maxI; i++)
{
code;
}
#+END_EXAMPLE
OR
#+BEGIN_EXAMPLE
for
(
i = 0;
@ -163,86 +198,111 @@
{
code;
}
#+END_EXAMPLE
NOT (no space between "for" and "(")
#+BEGIN_EXAMPLE
for(i = 0; i < maxI; i++)
{
code;
}
#+END_EXAMPLE
*** `forAll' loops
like for loops, but
#+BEGIN_EXAMPLE
forAll(
#+END_EXAMPLE
NOT
#+BEGIN_EXAMPLE
forAll (
#+END_EXAMPLE
*** Splitting Over Multiple Lines
+ splitting return type and function name
+ 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.
so:
#+BEGIN_EXAMPLE
const Foam::longReturnTypeName&
Foam::longClassName::longFunctionName const
#+END_EXAMPLE
NOT
#+BEGIN_EXAMPLE
const Foam::longReturnTypeName&
Foam::longClassName::longFunctionName const
#+END_EXAMPLE
NOR
#+BEGIN_EXAMPLE
const Foam::longReturnTypeName& Foam::longClassName::longFunctionName
const
#+END_EXAMPLE
NOR
#+BEGIN_EXAMPLE
const Foam::longReturnTypeName& Foam::longClassName::
longFunctionName const
#+END_EXAMPLE
+ 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&
Foam::veryveryveryverylongClassName::
veryveryveryverylongFunctionName const
#+END_EXAMPLE
+ splitting long lines at an "="
Indent after split
#+BEGIN_EXAMPLE
variableName =
longClassName.longFunctionName(longArgument);
#+END_EXAMPLE
OR (where necessary)
#+BEGIN_EXAMPLE
variableName =
longClassName.longFunctionName
(
longArgument1,
longArgument2
);
#+END_EXAMPLE
NOT
#+BEGIN_EXAMPLE
variableName =
longClassName.longFunctionName(longArgument);
#+END_EXAMPLE
NOR
#+BEGIN_EXAMPLE
variableName = longClassName.longFunctionName
(
longArgument1,
longArgument2
);
#+END_EXAMPLE
*** Maths and Logic
+ operator spacing
@ -258,18 +318,34 @@
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.
#+BEGIN_EXAMPLE
variableName =
a * (a + b)
- 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)
);
#+END_EXAMPLE
+ splitting logical tests over several lines
indent operator so that the next variable to test is aligned with the
four space indentation, i.e.
outdent the operator so that the next variable to test is aligned with
the four space indentation, i.e.
#+BEGIN_EXAMPLE
if
(
a == true
&& b == c
)
#+END_EXAMPLE

View File

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

View File

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

View File

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