-
Notifications
You must be signed in to change notification settings - Fork 0
Style Guide
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.
Document v0.1
Tab character MUST NOT be used, except within quoted strings or characters.
Indent unit (i.e. tab size) of 4 characters is REQUIRED
Curly brace SHOULD appear on next line. Exceptions include:
- Scenario where opening and close curly brace comfortably fit on one line
- Namespace curly braces MUST appear on the same line
These guidelines apply to core library conventions under our complete control, with only minor influence from 3rd parties:
class and struct MUST be pascal case, unless an inner class or struct.
class HelloWorld {};
inner class or struct SHOULD be pascal case, otherwise MUST be snake case.
struct HelloWorld
{
struct how_are_you {};
};
functions (excluding constructors and destructors) MUST be snake case.
struct HelloWorld
{
HelloWorld() {}
void how_are_you() {}
};
enum names SHOULD be pascal case, otherwise MUST be snake case.
non-class enum enumerator MUST be CAPS case.
class enum enumerator SHOULD be snake case and MUST use the same case for each enumerator.
enum Enum1
{
ENUM1_MY_VALUE1,
ENUM1_MY_VALUE2
};
enum class Enum2
{
my_value1,
my_value2
};
typedef/using MUST be either snake case or pascal case
using HelloPlanet = HelloWorld;
typedef HelloWorld hello_planet;
namespace MUST be snake case and shorter than 15 characters
namespace my_namespace { namespace inner {
}}
These guidelines modify 2.2.1. to accommodate 3rd party code, such as wrapper code.
Term | Context | Description |
---|---|---|
CAPS case | My unofficial term for Screaming snake case | |
Camel case | [1] | All words except first capitalized i.e. helloWorld
|
Kebab case | [1] | All words lowercase, separated by hyphen i.e. hello-world
|
Pascal case | [1] | All words capitalized i.e. HelloWorld
|
Screaming snake case | [1] | All words uppercase, separated by underscore i.e. HELLO_WORLD
|
Snake case | [1] | All words lowercase, separated by underscore i.e. hello_world
|