[29] | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
---|
| 2 | <html> |
---|
| 3 | |
---|
| 4 | <head> |
---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
---|
| 6 | <title>Boost Header policy</title> |
---|
| 7 | <meta name="GENERATOR" content="Microsoft FrontPage 5.0"> |
---|
| 8 | <meta name="ProgId" content="FrontPage.Editor.Document"> |
---|
| 9 | <meta name="Microsoft Border" content="none, default"> |
---|
| 10 | </head> |
---|
| 11 | |
---|
| 12 | <body bgcolor="#FFFFFF" text="#000000"> |
---|
| 13 | |
---|
| 14 | <table summary="Navigational header" |
---|
| 15 | border="1" bgcolor="#007F7F" cellpadding="2"> |
---|
| 16 | <tr> |
---|
| 17 | <td bgcolor="#FFFFFF"><img src="../boost.png" alt="boost.png (6897 bytes)" width="277" height="86"></td> |
---|
| 18 | <td><a href="../index.htm"><font face="Arial" color="#FFFFFF"><big>Home</big></font></a></td> |
---|
| 19 | <td><a href="../libs/libraries.htm"><font face="Arial" color="#FFFFFF"><big>Libraries</big></font></a></td> |
---|
| 20 | <td><a href="../people/people.htm"><font face="Arial" color="#FFFFFF"><big>People</big></font></a></td> |
---|
| 21 | <td><a href="faq.htm"><font face="Arial" color="#FFFFFF"><big>FAQ</big></font></a></td> |
---|
| 22 | <td><a href="index.htm"><font face="Arial" color="#FFFFFF"><big>More</big></font></a></td> |
---|
| 23 | </tr> |
---|
| 24 | </table> |
---|
| 25 | <h1>Boost Header Policy</h1> |
---|
| 26 | <p>Header files are the place where a library comes into contact with user code |
---|
| 27 | and other libraries. To co-exist peacefully and productively, headers must |
---|
| 28 | be "good neighbors".</p> |
---|
| 29 | <p>Here are the standards for boost headers. Many of |
---|
| 30 | these are also reasonable guidelines for general use. |
---|
| 31 | <ul> |
---|
| 32 | <li>Header filenames should have a .hpp (lowercase) extension. </li> |
---|
| 33 | <li>Unless multiple inclusion is intended, wrap the header in #ifndef guards. |
---|
| 34 | Use a naming convention that minimizes the chance of clashes |
---|
| 35 | with macro names from other's code. The <a href="#SampleHeader">sample |
---|
| 36 | header</a> uses the Boost convention of all uppercase letters, with the |
---|
| 37 | header name prefixed by the namespace name, and suffixed with HPP, separated |
---|
| 38 | by underscores.</li> |
---|
| 39 | <li>Wrap the header contents in a namespace to prevent global namespace |
---|
| 40 | pollution. The namespace approach to pollution control is strongly preferred |
---|
| 41 | to older approaches such as adding funny prefixes to global names. |
---|
| 42 | Libraries which are designed to work well with other Boost libraries should |
---|
| 43 | be placed in namespace <tt>boost</tt>.</li> |
---|
| 44 | |
---|
| 45 | <li>Make sure that a translation unit consisting of just the |
---|
| 46 | contents of the header file will compile successfully.</li> |
---|
| 47 | |
---|
| 48 | <li>Place the header file in a sub-directory to prevent conflict with |
---|
| 49 | identically named header files in other libraries. The parent |
---|
| 50 | directory is added to the compiler's include search path. Then both |
---|
| 51 | your code and user code specifies the sub-directory in <tt>#include</tt> |
---|
| 52 | directives. Thus the header <a href="#SampleHeader">sample header</a> |
---|
| 53 | would be included by <tt>#include <boost/furball.hpp></tt></li> |
---|
| 54 | <li>The preferred ordering for class definitions is public members, protected |
---|
| 55 | members, and finally private members.</li> |
---|
| 56 | <li>Include the boost/config.hpp <a href="../libs/config/config.htm">configuration |
---|
| 57 | header</a> if there is a need to deal with compiler or platform |
---|
| 58 | configuration issues.</li> |
---|
| 59 | </ul> |
---|
| 60 | <h2><a name="SampleHeader"></a>Sample Header</h2> |
---|
| 61 | <pre><tt>// Boost general library furball.hpp header file ---------------------------// |
---|
| 62 | |
---|
| 63 | <<i> Copyright and license notice</i>, as indicated in the <a href="license_info.html">license page</a> > |
---|
| 64 | |
---|
| 65 | // See http://www.boost.org/ for latest version. |
---|
| 66 | |
---|
| 67 | #ifndef BOOST_FURBALL_HPP |
---|
| 68 | #define BOOST_FURBALL_HPP |
---|
| 69 | |
---|
| 70 | namespace boost { |
---|
| 71 | |
---|
| 72 | // Furball class declaration -----------------------------------------------// |
---|
| 73 | |
---|
| 74 | class furball |
---|
| 75 | { |
---|
| 76 | public: |
---|
| 77 | void throw_up(); |
---|
| 78 | private: |
---|
| 79 | int whatever; |
---|
| 80 | }; // furball |
---|
| 81 | |
---|
| 82 | } // namespace |
---|
| 83 | |
---|
| 84 | #endif // include guard</tt></pre> |
---|
| 85 | <h2>Coding Style</h2> |
---|
| 86 | <p>The alert reader will have noticed that the <a href="#SampleHeader">sample |
---|
| 87 | header</a> employs a certain coding style for indentation, positioning braces, |
---|
| 88 | commenting ending braces, and similar formatting issues. These stylistic |
---|
| 89 | issues are viewed as personal preferences and are not part of the Boost Header |
---|
| 90 | Policy.</p> |
---|
| 91 | <hr> |
---|
| 92 | <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> |
---|
| 93 | |
---|
| 94 | <p>© Copyright Beman Dawes 1998</p> |
---|
| 95 | <p> |
---|
| 96 | Distributed under the Boost Software License, Version 1.0. (See |
---|
| 97 | accompanying file <a href="../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy |
---|
| 98 | at <a href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>) |
---|
| 99 | </p> |
---|
| 100 | |
---|
| 101 | </body> |
---|
| 102 | |
---|
| 103 | </html> |
---|