removed some errors, added basic unit tests
[senf.git] / Socket / Protocols / UN / UNAddress.hh
1 // $Id$
2 //
3 // Copyright (C) 2007 
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the
17 // Free Software Foundation, Inc.,
18 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
20 /** \file
21     \brief UNAddress public header */
22
23 #ifndef HH_UNAddress_
24 #define HH_UNAddress_ 1
25
26 // Custom includes
27 #include <string>
28 #include <boost/operators.hpp>
29 #include <boost/filesystem/path.hpp>
30 #include "../../../Utils/SafeBool.hh"
31
32 //#include "UNAddress.mpp"
33 ///////////////////////////////hh.p////////////////////////////////////////
34 namespace senf {
35     /** \brief Unix domain address
36         
37         UNAddress represents a simple unix domain address which is given by a path to a socket. 
38         It is modelled as a boost::filesystem::path.
39
40         \ingroup addr_group
41       */
42     class UNAddress 
43         : public boost::filesystem::path,
44           public ComparableSafeBool<UNAddress>
45     {   
46     public: 
47         UNAddress(); ///< Construct an empty address
48         explicit UNAddress(boost::filesystem::path);///< Construct an address constant from given path
49         static UNAddress fromString(std::string & s); ///< Convert string to address by interpreting the string as path
50         static UNAddress fromPath(boost::filesystem::path & p);///< Convert path to address 
51         UNAddress clone(); ///< Clone object 
52         std::string pathString() const; ///< Return the path of the address as string
53
54         /** \brief Base-class for UNAddress exceptions */
55         struct AddressException : public std::exception {}; 
56
57     private:
58         boost::filesystem::path path;
59     };
60
61 std::ostream & operator<<(std::ostream & os, UNAddress const & addr);
62 }
63
64 ///////////////////////////////hh.e////////////////////////////////////////
65 //#include "UNAddress.cci"
66 //#include "UNAddress.ct"
67 //#include "UNAddress.cti"
68 #endif
69
70 \f
71 // Local Variables:
72 // mode: c++
73 // fill-column: 100
74 // comment-column: 40
75 // c-file-style: "senf"
76 // indent-tabs-mode: nil
77 // ispell-local-dictionary: "american"
78 // compile-command: "scons -u test"
79 // End: