QuantLib Style Guidelines
The standard style for QuantLib code is shown in the following
listing. You can write in your own style if you don't feel
comfortable with this one; however, keep in mind that consistency
would enhance readability for developers accustomed to the existing
body of code. Also, there should be no real tabs in the code; four
spaces should be used instead. If you don't follow this convention,
other developers are likely to see your code with the wrong
indentation.
#define SOME_MACRO
typedef double SomeType;
class SomeClass {
public:
void method();
Real anotherMethod(Real x,
Real y) const;
Real member() const;
void setMember(Real);
private:
Real member_;
Integer anotherMember_;
};
struct SomeStruct {
Real foo;
Integer bar;
};
class SomeOtherClass {
public:
typedef Real* iterator;
typedef const Real* const_iterator;
};
Size someFunction(Real parameter,
Real anotherParameter) {
Real localVariable = 0.0;
if (condition) {
localVariable += 3.14159;
} else {
localVariable -= 2.71828;
}
return 42;
}