1 /*
2  * Copyright (C) 2001-2004 Peter J Jones (pjones@pmade.org)
3  * All Rights Reserved
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in
13  *    the documentation and/or other materials provided with the
14  *    distribution.
15  * 3. Neither the name of the Author nor the names of its contributors
16  *    may be used to endorse or promote products derived from this software
17  *    without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22  * PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR
23  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
29  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  * SUCH DAMAGE.
31  */
32 
33 /** @file
34  * This file defines some common types for Netxx.
35 **/
36 
37 #ifndef _netxx_types_h_
38 #define _netxx_types_h_
39 
40 // standard includes
41 #include <stdexcept>
42 #include <string>
43 
44 namespace Netxx {
45 
46     /// unsigned size type (used for object sizes)
47     typedef unsigned int size_type;
48 
49     /// signed size type (used for objects with possible negative values)
50     typedef signed int signed_size_type;
51 
52     /// type for representing port numbers
53     typedef unsigned short port_type;
54 
55     /// type for representing socket file descriptors
56     typedef signed int socket_type;
57 
58     /**
59      * The Netxx::NetworkException class is used by the Netxx library to signal
60      * an error condition associated with a network issue that would not result
61      * from a bug in the calling program. It is derived from std::runtime_error
62      * which is derived from std::exception. This makes it suitable to only catch
63      * std::exception objects if you wish.
64     **/
65     struct NetworkException : public std::runtime_error {
NetworkExceptionNetworkException66 	NetworkException (const std::string &what_arg) :
67 	    std::runtime_error(what_arg) { }
68     }; // end Netxx::NetworkException
69 
70     /**
71      * The Netxx::Exception class is used by the Netxx library to signal
72      * some error condition. It is derived from std::runtime_error which is
73      * dervied from std::exception. This makes it suitable to only catch
74      * std::exception objects if you wish.
75     **/
76     struct Exception : public std::runtime_error {
ExceptionException77 	Exception (const std::string &what_arg) :
78 	    std::runtime_error(what_arg) { }
79     }; // end Netxx::Exception
80 
81 } // end Netxx namespace
82 #endif
83