-
Notifications
You must be signed in to change notification settings - Fork 7
/
style-guide.html
143 lines (142 loc) · 7.04 KB
/
style-guide.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<!DOCTYPE html>
<html lang="en">
<head>
<title>cpp-netlib: Style Guide</title>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap-theme.min.css">
<link href="static/cpp-netlib.css" rel="stylesheet">
</head>
<body data-spy="scroll" data-target="#cpp-netlib-docs-sidebar">
<div class="row" id="wrap">
<div class="container">
<nav class="navbar navbar-fixed-top navbar-inverse cpp-netlib-navbar" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">cpp-netlib</a>
</div>
<div>
<ul class="nav navbar-nav">
<li><a href="index.html">Home</a></li>
<li><a href="process.html">Development Process</a></li>
<li class="active"><a href="style-guide.html">Style Guide</a></li>
<li><a href="proposals.html">Proposals</a></li>
</ul>
</div>
</div>
</nav>
<header class="jumbotron subhead">
<h1>Style Guide</h1>
<p class="lead">How we like our code.</p>
</header>
<div class="row">
<div class="col-md-3" id="cpp-netlib-docs-sidebar" role="complimentary">
<ul class="nav list-group cpp-netlib-sidebar" data-spy="affix" data-offset-top="245">
<li class="list-group-item"><a href="#overview">Overview</a></li>
<li class="list-group-item"><a href="#formatting">Formatting</a></li>
<li class="list-group-item"><a href="#naming">Naming</a></li>
<li class="list-group-item"><a href="#features">Features</a></li>
<li class="list-group-item"><a href="#organization">Organization</a></li>
</ul>
</div>
<div class="col-md-9">
<section id="overview">
<div class="page-header">
<h1>Overview</h1>
</div>
<p>This is the style guide for the cpp-netlib project. We strive
for consistency throughout the codebase to make it easier for
developers and users to understand the code.</p>
<p>The style guide is not exhaustive and is subject to change
based on community agreement. If you have questions or
clarifications to the contents of the style guide, get involved
in the discussion at <a
href="https://groups.google.com/group/cpp-netlib"
target="_blank">https://groups.google.com/group/cpp-netlib</a>.</p>
</section>
<section id="formatting">
<div class="page-header">
<h1>Formatting</h1>
</div>
<p>We enforce the formatting rules prescribed by the Google Style
Guide as implemented by the clang-format tool.</p>
<dl>
<dt id="spaces">Spaces vs Tabs</dt>
<dd>Use spaces instead of tab characters.</dd>
<dt id="indents">Indents</dt>
<dd>Block indents two spaces, arguments to function calls indent 4 spaces from the start of the function name.</dd>
<dt id="namespaces">Namespaces</dt>
<dd>Namespaces do not start indent contexts.</dd>
<dt id="braces">Braces</dt>
<dd>Curly braces should be on the same line as function, namespace, class, enum, and loop declarations.</dd>
<dt id="parentheses">Parentheses</dt>
<dd>There should be no spaces before and after opening and closing parentheses.</dd>
<dt id="commas">Commas</dt>
<dd>There should be a space after every comma.</dd>
</dl>
</section>
<section id="naming">
<div class="page-header">
<h1>Naming</h1>
</div>
<p>We follow naming conventions used by the standard library.</p>
<dl>
<dt id="types">Types</dt>
<dd>Types should be named as nouns, are in all-lowercase characters, and have words separated by underscores.</dd>
<dt id="template-parameters">Template Parameters</dt>
<dd>Template parameter names should be general nouns, should start with an uppercase character, and have words concatenated each starting with uppercase characters.</dd>
<dt id="functions">Functions</dt>
<dd>Functions should be verbs, are in all-lowercase characters, and have words separated by underscores.</dd>
<dt id="macros">Macros</dt>
<dd>Macros should be all-uppercase characters, start with <code>NETWORK</code> and have words separated by underscores.</dd>
</dl>
</section>
<section id="features">
<div class="page-header">
<h1>Features</h1>
</div>
<p>We use all the facilities afforded us by C++. In particular, the most current C++ standard is the one we code against.</p>
</section>
<section id="organization">
<div class="page-header">
<h1>Organization</h1>
</div>
<p>We organize the whole library in namespaces, and where appropriate as macro's and static class members.</p>
<dl>
<dt id="constants">Constants</dt>
<dd>Prefer constants be defined as static class members, function-local static variables, enum classes, scoped enums, then macro's in that order.</dd>
<dt id="details">Details</dt>
<dd>Parts of the implementation considered as "implementation details" shall live in a nested namespace called <code>impl</code>.</dd>
</dl>
</section>
</div>
</div>
</div>
</div>
<footer id="footer">
<div class="container">
<p class="muted credit">Copyright 2012 Dean Michael Berris; Glyn
Matthews; Google, Inc.</p>
<p class="muted credit">Distributed under the Boost Software License,
Version 1.0. (See accompanying file <a
href="LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy at <a
href="//www.boost.org/LICENSE_1_0.txt">//www.boost.org/LICENSE_1_0.txt</a>)</p>
</div>
</footer>
<script src="//code.jquery.com/jquery-3.7.1.slim.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-19815738-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type =
'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ?
'https://ssl' : 'http://www') +
'.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>