Expand brief documentation for classes

This commit is contained in:
Danny Robson 2011-06-23 22:06:28 +10:00
parent ea0cdb9f7b
commit 898d082fb0
4 changed files with 20 additions and 1 deletions

View File

@ -26,12 +26,18 @@
using namespace std;
/// Construct an errno_error from a given error value. The error value MUST signal an error at
/// construction time.
errno_error::errno_error (int _errno):
runtime_error (strerror (_errno)),
id (_errno)
{ ; }
{
check_hard (_errno != 0);
}
/// Construct an errno_error from the current value of errno. errno MUST signal an error at
/// construction time.
errno_error::errno_error ():
runtime_error (strerror (errno)),
id (errno)
@ -40,11 +46,13 @@ errno_error::errno_error ():
}
/// Throw an errno_error exception if errno currently signals an error.
void
errno_error::try_code ()
{ try_code (errno); }
/// Throw an errno_error exception if 'code' represents an error.
void
errno_error::try_code(int code) {
if (code != 0)

View File

@ -40,6 +40,7 @@ class unavailable_error : public std::runtime_error {
};
/// An exception class used for reporting errors signalled by errno.
class errno_error : public std::runtime_error {
public:
int id;

View File

@ -41,6 +41,7 @@ namespace json {
extern node* parse (const char *start, const char *stop);
extern node* parse (const char *start);
/// Abstract base for all JSON values
class node {
public:
virtual ~node () { ; }
@ -72,6 +73,7 @@ namespace json {
};
/// Represents a JSON object, and contains its children.
class object : public node {
protected:
std::map<std::string, node*> m_values;
@ -94,6 +96,7 @@ namespace json {
};
/// Represents a JSON array, and contains its children.
class array : public node {
protected:
std::vector<node*> m_values;
@ -126,6 +129,7 @@ namespace json {
};
/// Represents a JSON string literal.
class string : public node {
protected:
std::string m_value;
@ -146,6 +150,7 @@ namespace json {
};
/// Represents a JSON integer/float literal.
class number : public node {
protected:
double m_value;
@ -166,6 +171,7 @@ namespace json {
};
/// Represents a JSON boolean literal.
class boolean : public node {
protected:
bool m_value;
@ -183,6 +189,7 @@ namespace json {
};
/// Represents a JSON null value.
class null : public node {
public:
virtual bool is_null (void) const { return true; }
@ -193,6 +200,7 @@ namespace json {
};
/// The base class for all exceptions throw directly by the json namespace.
class error : public std::runtime_error {
public:
error (const std::string &_what):

View File

@ -98,10 +98,12 @@ size_t elems(T (&)[N])
{ return N; }
/// Convert a scalar from host byte order to network byte order
template <typename T>
T hton (T);
/// Convert a scalar from network byte order to host byte order
template <typename T>
T ntoh (T);