Here are some examples from the actual code.
In this case, values of some sort are being returned. The first is a cast of a set of enums into a single enum value. The second is a function call that returns a value and has enough parameters that it must be wrapped.
// Cast a set of bit mapped enums flags
tCIDLib::eFooSet eSet = tCIDLib::eFooSet
(
tCIDLib::eFooSet_Flag1
| tCIDLib::eFooSet_Flag2
| tCIDLib::eFooSet_Flag3
);
tCIDLib::TFloat8 f8Tmp = 0.5 - _f8Noise
(
f8X * 4 * f8Freq
, f8Y * 4 * f8Freq
, f8Z * 4 * f8Freq
);
In this case, when some kind of operator is used in a compound statement
and it cannot be put on one line without violating the column widget rules, it
will be wrapped so that the logical operators are under the if and the
indentation of the parts of the statement indicate the nesting.
if ((f8NoiseVal >.= pbandCur->f8StartVal)
&& (f8NoiseVal <.= pbandCur->f8EndVal))
{
blah blah blah
}
Note that those methods below that have parameters are wrapped around somewhat
like an if statement. They use leading commas and everything is
columnarized exactly the same.
class TWndBorder : public TCIDObject, public MDuplicable
{
public :
// ------------------------------------------------------
// Constructors and Destructors
// ------------------------------------------------------
TWndBorder();
TWndBorder
(
const TWndBorder& wbordToCopy
);
~TWndBorder();
// ------------------------------------------------------
// Public, virtual methods
// ------------------------------------------------------
virtual tCIDLib::TCard4 c4Width() const = 0;
virtual tCIDLib::TVoid Depress() = 0;
virtual tCIDLib::TVoid DrawBorder
(
const TWindow& wndTarget
, TPaintBrush& ptbToUse
, const TArea& areaBorder
) = 0;
virtual tCIDLib::TVoid Raise() = 0;
};
This case shows how class initializers are wrapped in the constructors for
all classes. They are always wrapped even if they could possibly fit onto
the same line as the function parameters. The parameters are strictly
columnarized, and both the parameters and the initializers use the leading
style commas.
TBandItem::TBandItem( const tCIDLib::TFloat8 f8End
, const tCIDLib::TFloat8 f8Start
, const TFRGBClr& frgbEnd
, const TFRGBClr& frgbStart) :
f8EndVal(f8End)
, f8StartVal(f8Start)
, frgbEndClr(frgbEnd)
, frgbStartClr(frgbStart)
{
}
* Note that the naming conventions for the files that make up a facility (a Dll or Exe) are convered in a separate section since they are a subject unto themselves. This section just covers the contents of those files.
//
// Enum type names are plural, and the values themselves
// use a singular version (though sometimes abbreviated) of
// the name as a prefix.
//
enum eFooCounters
{
eFooCounter_Burgers
, eFooCounter_Chips
, eFooCounter_Coke
};
//
// Here are some standard CIDLib classes used to create some
// legally named objects.
//
TArea areaWindow;
TPoint pntOrigin;
TBag_T<.TPoint>. colOfPoints;
// Create a class derived from the base object and a mixin
class TFoo : public TCIDObject, public MStreamable
{
// blah blah blah
};
I call it a 'family prefix' because generally all classes derived from some basic class will use the base class' prefix (because all classes derived from it are really just variations of that basic type.) For instance, all windows use 'wnd' and call graphics bundles use 'gbun' etc...
Here are some examples:
tCIDLib::TCard4 c4FooCount;
tCIDLib::eMonths eThisMonth(tCIDLib::eMonth_January);
TArea areaOfFoo(10, 10, 100, 200);
Unless there is a major justification to do so, all data members are to be private. The only exception is that it is acceptible to have public const static data members (unless you with to hide the representation of that member of course.) Very occasionally protected members might be used so that derived classes have high speed access to the data.
Order of Declaration
Class members are always in the same order. The order of the implementation within the Cpp files follows the same ordering as the order of declaration within the Hpp file. There might always be the occasional special case that is not covered here.
- Public Section
- Public, class specific types
- Public static data members.
- Public constructors and destructors
- Public operators
- Public, inherited methods
- Public, virtual methods
- Public, non-virtual methods
- Protected Section
- Friends and protected class specific types
- Hidden constructors and operators
- Protected, inherited methods
- Protected, virtual methods
- Protected, non-virtual methods
- Protected data members (should be rare)
- Private Section
- Unimplemented constructors and operators
- Private, inherited methods
- Private, virtual methods
- Private, non-virtual methods
- Private data members
Naming Conventions
Class members have slightly different naming conventions that other nameable entities, because of their special place in our hearts :-)
- Public methods and members have no special naming conventions. They just follow the normal variable naming conventions.
- Protected methods and members have a single underscore, unless they cannot have one due to conflicts with the languge (such as hidden constructors and operators.)
- Private members have two leading underscores.
- The 'virtual' keyword is applied only to a method when it is 'first' declared, i.e. in the lowest level class that implements it. When a class overrides a method, it is put into the section that denotes it is an inherited method, but it is not given the virtual keyword explicitly.
* This was not historically observed in CIDLib and is currently being rectified in the remaining places its not done this way.
File Header// // NAME: // // DESCRIPTION: // // // AUTHOR: // // CREATE DATE: // // COPYRIGHT: 1992..1996, // // CAVEATS/GOTCHAS: // // MODIFICATION LOG: //Function/Method Header// // FUNCTION/METHOD NAME: // // DESCRIPTION: // // --------------------------------------- // INPUT: None // // OUTPUT: None // // RETURN: None //Class Header// ------------------------------------------------------------------- // CLASS: // PREFIX: // -------------------------------------------------------------------