DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
...
Code indentation and formatting was completely standardized prior to open sourcing the Apache Traffic Server code. The command Command line tool indent did most of the heavy lifting.
...
This document relies on code samples which are below to demonstrate most of the rules used on the Apache Traffic Server project.
| Code Block | ||||
|---|---|---|---|---|
| ||||
#include <iostream>
using namespace std;
namespace ts
{
/**
* @brief Demonstrates how to format code
* This class demonstrates to developers how we should structure code
*/
class Counter
{
public:
Counter():_count(0), _totalCount(0) { }
/**
* @brief Increments the count by one or an optional value
* @param delta The amount to increment the count, default is 1
*/
void increment(int delta = 1) {
_count += delta;
}
/**
* @brief Returns the count value
* @return Count value
*/
int getCount() const { // try to use const as much as possible
return _count;
}
private: // try to hide data
void _helpers() { _foo++; }
int _count; /// if there is something special to say
int _totalCount;
protected:
void _anotherHelper() { _foo++; }
int _foo;
};
}
/**
* @brief This is the main function for the program
*/
int
main()
{
ts::Counter x;
if (x.getCount() == 0) {
x.increment();
} else {
// make sure to always use braces for conditionals
}
// increment the counter 10 times
for (int i = 0; i < 10; ++i) {
x.increment();
}
cout << x.getCount() << endl;
}
|
...