Skip to content
Snippets Groups Projects
Commit 0313acf3 authored by g0dil's avatar g0dil
Browse files

Utils: Fix documentation

parent cf33f7b0
No related branches found
No related tags found
No related merge requests found
...@@ -35,6 +35,40 @@ ...@@ -35,6 +35,40 @@
//#include "Exception.mpp" //#include "Exception.mpp"
///////////////////////////////hh.p//////////////////////////////////////// ///////////////////////////////hh.p////////////////////////////////////////
/** \defgroup exception System exceptions
The senf::SystemException class and it's derived class template senf::ErrnoException are used to
signal generic system failures based on \c errno codes.
senf::SystemException is a generic \c errno based exception which carries an error number and
origin information. senf::ErrnoException is a derived class specialized for a specific error
code. This simplifies managing error conditions:
\code
try {
something.open(path);
// ...
}
catch (senf::ErrnoException<ENOFILE> & e) {
// Create new file
}
catch (senf::SystemException & e) {
// Catch all other system exceptions
std::cerr << "Error accessing '" << path << "': " << e.what() << std::endl;
}
\endcode
This exception is normally thrown using the senf::throwErrno() helper:
\code
if ((fd = ::open(path.c_str(), O_RDWR)) < 0)
senf::throwErrno("::open()");
\endcode
The senf::throwErrno() helper will throw the correct exception class based on some \c errno
value.
*/
namespace senf { namespace senf {
/** \brief Exception handling standard UNIX errors (errno) /** \brief Exception handling standard UNIX errors (errno)
...@@ -47,6 +81,7 @@ namespace senf { ...@@ -47,6 +81,7 @@ namespace senf {
be thrown via one of the senf::throwErrno() helpers. be thrown via one of the senf::throwErrno() helpers.
\see ErrnoException \see ErrnoException
\ingroup exception
*/ */
class SystemException : public std::exception class SystemException : public std::exception
{ {
...@@ -100,6 +135,7 @@ namespace senf { ...@@ -100,6 +135,7 @@ namespace senf {
if ((fd = ::open(filename, O_RDWR)) < 0) if ((fd = ::open(filename, O_RDWR)) < 0)
senf::throwErrno("open()"); senf::throwErrno("open()");
\endcode \endcode
\ingroup exception
*/ */
template <int Code> template <int Code>
class ErrnoException : public SystemException class ErrnoException : public SystemException
...@@ -114,22 +150,22 @@ namespace senf { ...@@ -114,22 +150,22 @@ namespace senf {
/** \brief Throw ErrnoException based on current \c errno value /** \brief Throw ErrnoException based on current \c errno value
\related ErrnoException \ingroup exception
*/ */
void throwErrno(); void throwErrno();
/** \brief Throw ErrnoException based on current \c errno value (with location info) /** \brief Throw ErrnoException based on current \c errno value (with location info)
\related ErrnoException \ingroup exception
*/ */
void throwErrno(char const * where); void throwErrno(char const * where);
/** \brief Throw ErrnoException based on given \c errno value /** \brief Throw ErrnoException based on given \c errno value
\related ErrnoException \ingroup exception
*/ */
void throwErrno(int code); void throwErrno(int code);
/** \brief Throw ErrnoException based on given \c errno value (with location info) /** \brief Throw ErrnoException based on given \c errno value (with location info)
\related ErrnoException \ingroup exception
*/ */
void throwErrno(char const * where, int code); void throwErrno(char const * where, int code);
......
...@@ -58,9 +58,7 @@ namespace senf { ...@@ -58,9 +58,7 @@ namespace senf {
\section miscstuff Miscellaneous \section miscstuff Miscellaneous
<table class="listing"> <table class="listing">
<tr><td>\ref SystemException</td><td>standard exception for system errors (errno)</td></tr> <tr><td>\ref exception</td><td>standard exception for system errors (errno)</td></tr>
<tr><td>\ref process</td><td>Some simple process management and daemon helpers</td></tr>
<tr><td>\ref hexdump</td><td>a simple but usefull function to write binary data in in <tr><td>\ref hexdump</td><td>a simple but usefull function to write binary data in in
hexadecimal format.</td></tr> hexadecimal format.</td></tr>
......
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
unit tests. If the available Boost version is 1.34, this file will automatically take care of unit tests. If the available Boost version is 1.34, this file will automatically take care of
any necessary workarounds. any necessary workarounds.
So, instead of <tt>#include <boost/test/auto_unit_test.hpp></tt>, you should always write So, instead of <tt>\#include <boost/test/auto_unit_test.hpp></tt>, you should always write
<tt>#include "../Utils/auto_unit_test.hh"<tt> (with possibliy adjusted path). <tt>\#include "../Utils/auto_unit_test.hh"<tt> (with possibliy adjusted path).
*/ */
#ifndef HH_auto_unit_test_ #ifndef HH_auto_unit_test_
......
...@@ -105,8 +105,8 @@ namespace mpl { ...@@ -105,8 +105,8 @@ namespace mpl {
never called. never called.
This number is than forwarded as template argument to \c select which is specialized for This number is than forwarded as template argument to \c select which is specialized for
each case. Therefore, <tt>choice<A></tt> has a \c frobble() member whereas each case. Therefore, <tt>choice\<A\></tt> has a \c frobble() member whereas
<tt>choice<B></tt> has a \c dazzle() member. <tt>choice\<B\></tt> has a \c dazzle() member.
\see \ref SENF_MPL_RV \see \ref SENF_MPL_RV
\ingroup senfmpl \ingroup senfmpl
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment