win32/nhostaddress.h

Go to the documentation of this file.
00001 // LICENSE: (Please see the file COPYING for details)
00002 //
00003 // NUS - Nemesis Utilities System: A C++ application development framework 
00004 // Copyright (C) 2006, 2008 Otavio Rodolfo Piske
00005 //
00006 //  This file is part of NUS
00007 //
00008 //  This library is free software; you can redistribute it and/or
00009 //  modify it under the terms of the GNU Lesser General Public
00010 //  License as published by the Free Software Foundation version 2.1
00011 //  of the License.
00012 //
00013 //  This library is distributed in the hope that it will be useful,
00014 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 //  Lesser General Public License for more details.
00017 //
00018 //  You should have received a copy of the GNU Lesser General Public
00019 //  License along with this library; if not, write to the Free Software
00020 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00021 //
00022 #ifndef NHOSTADDRESS_H
00023 #define NHOSTADDRESS_H
00024 
00025 
00033 #ifndef WIN32_LEAN_AND_MEAN
00034 #define WIN32_LEAN_AND_MEAN
00035 #endif
00036 #include <winsock2.h>
00037 
00038 #include "ndefs.h"
00039 #include "nobject.h"
00040 #include "nstring.h"
00041 #include "nlist.h"
00042 #include "nbaseexceptions.h"
00043 #include "nnetworkexceptions.h"
00044 #include "nsignal.h"
00045 
00049 class DllDeclSpec NHostAddress: public NObject {
00050       public:
00054             NHostAddress(void);
00055 
00060             NHostAddress(const NString &addr);
00061 
00067             NHostAddress(const NHostAddress &addr);
00068 
00073             NHostAddress(const sockaddr *addr);
00074 
00078             void clear(void);
00079 
00086             void setAddress(nuint32 ip);
00087 
00093             void setAddress(const NString &addr);
00094 
00101             void setAddress(const sockaddr *sock);
00102 
00113             nuint32 resolve(void) const;
00114 
00119             NString toString(void) const;
00120             
00126             static NString toString(nuint32 ip);
00127 
00132             NString address(void) const;
00133 
00138             NList<NString> aliases(void);
00139 
00146             NList<nuint32> addresses(void);
00147             
00152             bool isNull(void) const;
00153 
00158             bool isLocalhost(void) const;
00159 
00165             NHostAddress &operator=(const NHostAddress &rhs);
00166 
00172             NHostAddress &operator=(const NString &rhs);
00173 
00174       private:
00175             NString m_addr;
00176             mutable struct hostent m_host;
00177             
00178             void throwErrorByCode(int herr) const;
00179             
00180 };
00181 
00182 #endif // NHOSTADDRESS_H

Generated on Wed Mar 5 23:10:35 2008 for NemesisUtilitiesSystem by  doxygen 1.5.4