MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ipaddress.h
1 // © Copyright 2010 - 2014 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 
41 #ifdef MEZZNETWORK
42 
43 #ifndef _networkipaddress_h
44 #define _networkipaddress_h
45 
46 #include "datatypes.h"
47 
48 namespace Mezzanine
49 {
50  namespace Network
51  {
52  ///////////////////////////////////////////////////////////////////////////////
53  /// @class IPAddress
54  /// @headerfile networkipaddress.h
55  /// @brief
56  /// @details
57  ///////////////////////////////////////
58  class MEZZ_LIB IPAddress
59  {
60  public:
61  /// @enum IPVersion
62  /// @brief Specifies the version of IP this class encapsulates.
63  enum IPVersion
64  {
65  IP_v4,
66  IP_v6
67  };
68  protected:
69  String HostName;
70  //String SocAddress;
71  virtual bool VerifyAddress(const String& Addr) = 0;
72  public:
73  /// @brief Class Constructor.
74  IPAddress();
75  /// @brief Class Destructor.
76  virtual ~IPAddress();
77  /// @brief Sets the address via string.
78  /// @param Address A string containing the address to be set.
79  virtual void SetAddress(const String& Address);
80  /// @brief Gets the address as a string.
81  /// @return Returns a string containing the address.
82  virtual String GetAddressAsString() const;
83  /// @brief Gets the address as a c-style string.
84  /// @return Returns a C string containing the address.
85  virtual char* GetAddressAsCString() const;
86  /// @brief Gets the hostname of this address if one was set.
87  /// @remarks This class does not do DNS lookup's on it's own. If you want that then
88  /// look to utilities on the NetworkManager. If those utilities were used then the
89  /// original hostname that was used to search with will be set, and you can retrieve it
90  /// using this function.
91  /// @return Returns a String containing the hostname associated with this address, or an empty string if one wasn't set.
92  virtual const String& GetHostName() const;
93  /// @brief Gets which version of IP this class is encapsulating.
94  /// @return Returns an IPVersion enum value indicating which version of IP this class is using.
95  virtual IPAddress::IPVersion GetVersion() const = 0;
96  };//IPAddress
97 
98  ///////////////////////////////////////////////////////////////////////////////
99  /// @class IPAddress_4
100  /// @headerfile networkipaddress.h
101  /// @brief
102  /// @details
103  ///////////////////////////////////////
104  class MEZZ_LIB IPAddress_4 : public IPAddress
105  {
106  protected:
107  //UInt32 SocAddress;
108  virtual bool VerifyAddress(const String& Addr);
109  public:
110  /// @brief Class Constructor.
111  IPAddress_4();
112  /// @brief Class Destructor.
113  virtual ~IPAddress_4();
114  /*/// @brief Sets the Address via a 32-bit int.
115  /// @param Address A 32-bit unsigned int representing the IPv4 address.
116  virtual void SetAddress(const UInt32& Address);// */
117  /// @copydoc IPAddress::GetVersion()
118  virtual IPAddress::IPVersion GetVersion() const;
119  };//IPAddress_4
120 
121  ///////////////////////////////////////////////////////////////////////////////
122  /// @class IPAddress_6
123  /// @headerfile networkipaddress.h
124  /// @brief
125  /// @details
126  ///////////////////////////////////////
127  class MEZZ_LIB IPAddress_6 : public IPAddress
128  {
129  protected:
130  //UInt8 SocAddress[16];
131  virtual bool VerifyAddress(const String& Addr);
132  public:
133  /// @brief Class Constructor.
134  IPAddress_6();
135  /// @brief Class Destructor.
136  virtual ~IPAddress_6();
137  /// @copydoc IPAddress::GetVersion()
138  virtual IPAddress::IPVersion GetVersion() const;
139  };//IPAddress_6
140  }//Network
141 }//Mezzanine
142 
143 #endif
144 
145 #endif //MEZZNETWORK