Commit 233cd646 authored by Davis King's avatar Davis King

code cleanup

parent 62d28ae4
...@@ -225,7 +225,7 @@ namespace dlib ...@@ -225,7 +225,7 @@ namespace dlib
); );
/*! /*!
requires requires
- ip is of the form #.#.#.# (dotted quad notation) or ip == "" - is_ip_address(ip) == true or ip == ""
- is_running() == false - is_running() == false
ensures ensures
- #get_listening_ip() == ip - #get_listening_ip() == ip
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "server_kernel_abstract.h" #include "server_kernel_abstract.h"
#include "../algs.h" #include "../algs.h"
#include "../assert.h" #include "../assert.h"
#include "../sockets.h"
#include <string> #include <string>
#include <sstream> #include <sstream>
...@@ -38,15 +39,6 @@ namespace dlib ...@@ -38,15 +39,6 @@ namespace dlib
); );
private: private:
bool is_dotted_quad (
std::string ip
) const;
/*!
ensures
returns true if ip is a valid dotted quad ip address else
returns false
!*/
}; };
...@@ -133,7 +125,7 @@ namespace dlib ...@@ -133,7 +125,7 @@ namespace dlib
{ {
// make sure requires clause is not broken // make sure requires clause is not broken
DLIB_CASSERT( DLIB_CASSERT(
( ( is_dotted_quad(ip) || ip == "" ) && ( ( is_ip_address(ip) || ip == "" ) &&
this->is_running() == false ), this->is_running() == false ),
"\tvoid server::set_listening_ip" "\tvoid server::set_listening_ip"
<< "\n\tip == " << ip << "\n\tip == " << ip
...@@ -145,46 +137,6 @@ namespace dlib ...@@ -145,46 +137,6 @@ namespace dlib
server_base::set_listening_ip(ip); server_base::set_listening_ip(ip);
} }
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// private member function definitions
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template <
typename server_base
>
bool server_kernel_c<server_base>::
is_dotted_quad (
std::string ip
) const
{
int num;
char dot;
std::istringstream sin(ip);
for (int i = 0; i < 3; ++i)
{
sin >> num; if (!sin) return false;
if (num < 0 || num > 255)
return false;
sin >> dot; if (!sin) return false;
if (dot != '.')
return false;
}
sin >> num; if (!sin) return false;
if (num < 0 || num > 255)
return false;
if (sin.get() != EOF)
return false;
return true;
}
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment