Skip to content

Commit 77f37f5

Browse files
committed
doc: update enum naming in developer notes
- Update the enumerator examples to snake_case per CPP Core Guidelines https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Renum-caps - Clarify that in this project enumerators may be snake_case, PascalCase, or ALL_CAPS, and to use what is seems appropriate.
1 parent d8f1e13 commit 77f37f5

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

doc/developer-notes.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ code.
8989
- Class member variables have a `m_` prefix.
9090
- Global variables have a `g_` prefix.
9191
- Constant names are all uppercase, and use `_` to separate words.
92+
- Enumerator constants may be `snake_case`, `PascalCase` or `ALL_CAPS`.
93+
This is a more tolerant policy than the [C++ Core
94+
Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Renum-caps),
95+
which recommend using `snake_case`. Please use what seems appropriate.
9296
- Class names, function names, and method names are UpperCamelCase
9397
(PascalCase). Do not prefix class names with `C`.
9498
- Test suite naming convention: The Boost test suite in file
@@ -669,19 +673,19 @@ Foo(vec);
669673

670674
```cpp
671675
enum class Tabs {
672-
INFO,
673-
CONSOLE,
674-
GRAPH,
675-
PEERS
676+
info,
677+
console,
678+
network_graph,
679+
peers
676680
};
677681

678682
int GetInt(Tabs tab)
679683
{
680684
switch (tab) {
681-
case Tabs::INFO: return 0;
682-
case Tabs::CONSOLE: return 1;
683-
case Tabs::GRAPH: return 2;
684-
case Tabs::PEERS: return 3;
685+
case Tabs::info: return 0;
686+
case Tabs::console: return 1;
687+
case Tabs::network_graph: return 2;
688+
case Tabs::peers: return 3;
685689
} // no default case, so the compiler can warn about missing cases
686690
assert(false);
687691
}

0 commit comments

Comments
 (0)