@page Guides @subpage CodingStyleGuide @page CodingStyleGuide Coding Style Guide @tableofcontents
@page CodingStyleGuide @subpage Introduction @page Introduction Introduction
A style guide should make things easier and more consistent.
Coding style tips
refer to various books and other style guides
@page CodingStyleGuide @subpage CppVersion @page CppVersion C++ Version
Code can assume a minimum of C++11, and may be some C++14 features. C++17 may be used provided compatibility with older version can be provided.
@page CodingStyleGuide @subpage Layout @page Layout Layout
Header File Layout
Example ClassName.h:
// BlockyFroggy
// Copyright © 2017 John Ryland.
// All rights reserved.
#pragma once
#ifndef CLASS_NAME_H
#define CLASS_NAME_H
#include "Base.h"
//! NameSpace description
namespace NameSpace
{
//! Class description
class ClassName : public Base
{
public:
//! Member function description
//! @param a_arg is an integer
//! @return some integer value
int memberFunction(int a_arg);
private:
int m_memberVariable;
};
} // namespace NameSpace
#endif // CLASS_NAME_H
Source File Layout
Example ClassName.cpp:
// BlockyFroggy
// Copyright © 2017 John Ryland.
// All rights reserved.
#include "ClassName.h"
namespace NameSpace {
int ClassName::memberFunction(int a_arg)
{
if (someFunction())
{
m_memberVariable = 1;
return 1;
}
return 0;
}
} // namespace NameSpace
// Unit Tests
#if ENABLE_UNIT_TESTS
DECLARE_UNIT_TEST(ClassNameTest)
{
NameSpace::ClassName example;
CHECK(example.memberFunction(10) == 0);
}
#endif // ENABLE_UNIT_TESTS
@page CodingStyleGuide @subpage CopyrightHeaders @page CopyrightHeaders Copyright Headers
All files should contain a copyright header with the following fields:
@page CodingStyleGuide @subpage Headers @page Headers Header Files
Code can use #pragma once. If want to use #ifndef #define #endif, this can optionally be done also.
@page CodingStyleGuide @subpage Namespaces @page Namespaces Namespaces