diff options
author | Jon Atack <jon@atack.com> | 2021-05-12 16:28:46 +0200 |
---|---|---|
committer | Jon Atack <jon@atack.com> | 2021-07-13 21:22:24 +0200 |
commit | 77f37f58ad2f349cecb2eda28b415267d3d7d76e (patch) | |
tree | 75c811def8bf322c6940de5611e531fe77bd4ebd | |
parent | d8f1e1327f9c2f9fcc804468f6a981580acdf30a (diff) | |
download | bitcoin-77f37f58ad2f349cecb2eda28b415267d3d7d76e.tar.xz |
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.
-rw-r--r-- | doc/developer-notes.md | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/doc/developer-notes.md b/doc/developer-notes.md index 583c50a763..3e13adeec0 100644 --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -89,6 +89,10 @@ code. - Class member variables have a `m_` prefix. - Global variables have a `g_` prefix. - Constant names are all uppercase, and use `_` to separate words. + - Enumerator constants may be `snake_case`, `PascalCase` or `ALL_CAPS`. + This is a more tolerant policy than the [C++ Core + Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Renum-caps), + which recommend using `snake_case`. Please use what seems appropriate. - Class names, function names, and method names are UpperCamelCase (PascalCase). Do not prefix class names with `C`. - Test suite naming convention: The Boost test suite in file @@ -669,19 +673,19 @@ Foo(vec); ```cpp enum class Tabs { - INFO, - CONSOLE, - GRAPH, - PEERS + info, + console, + network_graph, + peers }; int GetInt(Tabs tab) { switch (tab) { - case Tabs::INFO: return 0; - case Tabs::CONSOLE: return 1; - case Tabs::GRAPH: return 2; - case Tabs::PEERS: return 3; + case Tabs::info: return 0; + case Tabs::console: return 1; + case Tabs::network_graph: return 2; + case Tabs::peers: return 3; } // no default case, so the compiler can warn about missing cases assert(false); } |