more/header.htm

103 lines
4.6 KiB
HTML
Raw Normal View History

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2000-07-27 22:27:00 +08:00
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Boost Header policy</title>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
2000-07-27 22:27:00 +08:00
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta name="Microsoft Border" content="none, default">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table summary="Navigational header"
border="1" bgcolor="#007F7F" cellpadding="2">
2000-07-27 22:27:00 +08:00
<tr>
<td bgcolor="#FFFFFF"><img src="../boost.png" alt="boost.png (6897 bytes)" width="277" height="86"></td>
2000-07-27 22:27:00 +08:00
<td><a href="../index.htm"><font face="Arial" color="#FFFFFF"><big>Home</big></font></a></td>
<td><a href="../libs/libraries.htm"><font face="Arial" color="#FFFFFF"><big>Libraries</big></font></a></td>
<td><a href="../people/people.htm"><font face="Arial" color="#FFFFFF"><big>People</big></font></a></td>
2000-07-27 22:27:00 +08:00
<td><a href="faq.htm"><font face="Arial" color="#FFFFFF"><big>FAQ</big></font></a></td>
<td><a href="index.htm"><font face="Arial" color="#FFFFFF"><big>More</big></font></a></td>
</tr>
</table>
<h1>Boost Header Policy</h1>
2000-07-27 22:27:00 +08:00
<p>Header files are the place where a library comes into contact with user code
and other libraries.&nbsp; To co-exist peacefully and productively, headers must
be &quot;good neighbors&quot;.</p>
<p>Here are the standards for boost headers.&nbsp;&nbsp;&nbsp; Many of
2000-07-27 22:27:00 +08:00
these are also reasonable guidelines for general use.
<ul>
<li>Header filenames should have a .hpp (lowercase) extension.&nbsp;</li>
<li>Unless multiple inclusion is intended, wrap the header in #ifndef guards.
Use a naming convention that minimizes the chance of clashes
with macro names from other's code.&nbsp; The <a href="#SampleHeader">sample
2000-07-27 22:27:00 +08:00
header</a> uses the Boost convention of all uppercase letters, with the
header name prefixed by the namespace name, and suffixed with HPP, separated
by underscores.</li>
<li>Wrap the header contents in a namespace to prevent global namespace
pollution. The namespace approach to pollution control is strongly preferred
to older approaches such as adding funny prefixes to global names.&nbsp;
Libraries which are designed to work well with other Boost libraries should
be placed in namespace <tt>boost</tt>.</li>
<li>Make sure that a translation unit consisting of just the
contents of the header file will compile successfully.</li>
2000-07-27 22:27:00 +08:00
<li>Place the header file in a sub-directory to prevent conflict with
identically named header files in other libraries.&nbsp; The parent
directory is added to the compiler's include search path.&nbsp; Then both
your code and user code specifies the sub-directory in <tt>#include</tt>
directives.&nbsp; Thus the header <a href="#SampleHeader">sample header</a>&nbsp;
2000-07-27 22:27:00 +08:00
would be included by <tt>#include &lt;boost/furball.hpp&gt;</tt></li>
<li>The preferred ordering for class definitions is public members, protected
members, and finally private members.</li>
<li>Include the boost/config.hpp <a href="../libs/config/config.htm">configuration
2000-07-27 22:27:00 +08:00
header</a> if there is a need to deal with compiler or platform
configuration issues.</li>
</ul>
<h2><a name="SampleHeader"></a>Sample Header</h2>
<pre><tt>//&nbsp; Boost general library furball.hpp header file ---------------------------//
2000-07-27 22:27:00 +08:00
&lt;<i> Copyright and license notice</i>, as indicated in the <a href="license_info.html">license page</a> &gt;
2000-07-27 22:27:00 +08:00
//&nbsp; See http://www.boost.org/ for latest version.
2000-07-27 22:27:00 +08:00
#ifndef BOOST_FURBALL_HPP
#define BOOST_FURBALL_HPP
namespace boost {
//&nbsp; Furball class declaration&nbsp; -----------------------------------------------//
&nbsp; class furball
{
public:
&nbsp; void throw_up();
private:
int whatever;
&nbsp;&nbsp;};&nbsp; // furball
} // namespace
#endif&nbsp; // include guard</tt></pre>
2000-07-27 22:27:00 +08:00
<h2>Coding Style</h2>
<p>The alert reader will have noticed that the <a href="#SampleHeader">sample
2000-07-27 22:27:00 +08:00
header</a> employs a certain coding style for indentation, positioning braces,
commenting ending braces, and similar formatting issues.&nbsp; These stylistic
issues are viewed as personal preferences and are not part of the Boost Header
Policy.</p>
<hr>
<p>Revised <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->02 October, 2003<!--webbot bot="Timestamp" endspan i-checksum="38549" --></p>
<p>&copy; Copyright Beman Dawes 1998</p>
<p>
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="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
2000-07-27 22:27:00 +08:00
</body>
</html>