/*
 *
 *
 *    unixaddress.h
 *
 *    C++ header file for class 'unixaddress.'
 *
 *    =========================================================================
 *
 *    Copyright (C) 2001-2003 by Matt Roberts, KK5JY.
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License as published by the Free Software Foundation; either
 *    version 2.1 of the License, or (at your option) any later version.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 *    =========================================================================
 *
 *
 */


#ifndef __UNIXADDRESS_H
#define __UNIXADDRESS_H

	#include <my++/socket.h>
	#include <sys/un.h>
	#include <string>

	namespace my {

		/*
		 *
		 *    address
		 *
		 */

		class unixaddress : public socket::address {
			private:
				std::string sa_address;

			public: /* from socket::address */
				void to_sockaddr (sockaddr *sa) const;
				void from_sockaddr (const sockaddr *sa);

				my::socket::address & parse (const std::string &s);
				std::string & to_string (std::string &s) const;
				std::string   to_string (void) const;

			public:
				unixaddress (void) { };
				unixaddress (const std::string &a) : sa_address(a) { /* noop */ };
				unixaddress (const unixaddress &a) : sa_address(a.sa_address) { /* noop */ };
				~unixaddress (void) { /* noop */ };

				const unixaddress &operator = (const sockaddr_un &sa) { from_sockaddr(&sa); return (*this); };

				// these complement virtual functions from base class
				void to_sockaddr (sockaddr_un *sa) const   { to_sockaddr  ((sockaddr*)(sa)); };
				void from_sockaddr (const sockaddr_un *sa) { from_sockaddr((const sockaddr*)(sa)); };
		};
	}

#endif /* __UNIXADDRESS_H */

