Auxiliary data structure for hostname and port number.  
 More...
#include <JHostname.hh>
 | 
| static const char  | SEPARATOR = ':' | 
|   | Separation character between hostname and port number.  
  | 
|   | 
 | 
| std::istream &  | operator>> (std::istream &in, JHostname &object) | 
|   | Read hostname from input stream.  
  | 
|   | 
| std::ostream &  | operator<< (std::ostream &out, const JHostname &object) | 
|   | Write hostname to output stream.  
  | 
|   | 
Auxiliary data structure for hostname and port number. 
Definition at line 33 of file JHostname.hh.
 
◆ JHostname() [1/3]
  
  
      
        
          | JNET::JHostname::JHostname  | 
          ( | 
           | ) | 
           | 
         
       
   | 
  
inline   | 
  
 
 
◆ JHostname() [2/3]
  
  
      
        
          | JNET::JHostname::JHostname  | 
          ( | 
          const std::string & |           buffer | ) | 
           | 
         
       
   | 
  
inline   | 
  
 
Constructor. 
The argument correponds to the hostname and an optional port number of the server. The syntax is hostname[:port]. The default port number is DISPATCH_PORT. If the complete buffer corresponds to an integer value, it is interpreted as the port number.
- Parameters
 - 
  
    | buffer | host name and optional port number  | 
  
   
Definition at line 61 of file JHostname.hh.
   62    {
   64    }
void set(const std::string &buffer)
Set hostname and port number.
 
 
 
 
◆ JHostname() [3/3]
  
  
      
        
          | JNET::JHostname::JHostname  | 
          ( | 
          const std::string & |           hostname,  | 
         
        
           | 
           | 
          const int |           port ) | 
         
       
   | 
  
inline   | 
  
 
Constructor. 
- Parameters
 - 
  
    | hostname | hostname  | 
    | port | port number  | 
  
   
Definition at line 73 of file JHostname.hh.
 
 
◆ equals()
  
  
      
        
          | bool JNET::JHostname::equals  | 
          ( | 
          const JHostname & |           hostname | ) | 
           const | 
         
       
   | 
  
inline   | 
  
 
Equal method. 
- Parameters
 - 
  
    | hostname | host name and port  | 
  
   
- Returns
 - true if this host name and port is equal to given host name and port; else false 
 
Definition at line 87 of file JHostname.hh.
 
 
◆ set()
  
  
      
        
          | void JNET::JHostname::set  | 
          ( | 
          const std::string & |           buffer | ) | 
           | 
         
       
   | 
  
inline   | 
  
 
Set hostname and port number. 
The argument correponds to the hostname and an optional port number of the server.
The syntax is hostname[:port]. The default port number is DISPATCH_PORT.
If the complete buffer corresponds to an integer value, it is interpreted as the port number.
- Parameters
 - 
  
    | buffer | host name and optional port number  | 
  
   
Definition at line 104 of file JHostname.hh.
  105    {
  107 
  108      const string::size_type pos = buffer.find(
SEPARATOR);
 
  109 
  110      if (pos != string::npos) {
  111 
  112        this->
hostname = buffer.substr(0, pos);
 
  113 
  114        istringstream(buffer.substr(pos + 1)) >> this->
port;
 
  115 
  116      } else {
  117 
  118        bool is_number = true;
  119 
  120        for (string::const_iterator i = buffer.begin(); is_number && i != buffer.end(); ++i) {
  121          is_number &= isdigit(*i);
  122        }
  123 
  124        if (is_number) {
  125 
  127 
  128          istringstream(buffer) >> this->
port;
 
  129 
  130        } else {
  131 
  134        }
  135      }
  136    }
static const int DISPATCH_PORT
Default ControlHost port.
 
static const char SEPARATOR
Separation character between hostname and port number.
 
 
 
 
◆ operator>>
  
  
      
        
          | std::istream & operator>>  | 
          ( | 
          std::istream & |           in,  | 
         
        
           | 
           | 
          JHostname & |           object ) | 
         
       
   | 
  
friend   | 
  
 
Read hostname from input stream. 
- Parameters
 - 
  
    | in | input stream  | 
    | object | hostname  | 
  
   
- Returns
 - input stream 
 
Definition at line 146 of file JHostname.hh.
  147    {
  148      std::string buffer;
  149 
  150      if (in >> buffer) {
  151        object.set(buffer);
  152      }
  153 
  154      return in;
  155    }
 
 
 
◆ operator<<
  
  
      
        
          | std::ostream & operator<<  | 
          ( | 
          std::ostream & |           out,  | 
         
        
           | 
           | 
          const JHostname & |           object ) | 
         
       
   | 
  
friend   | 
  
 
Write hostname to output stream. 
- Parameters
 - 
  
    | out | output stream  | 
    | object | hostname  | 
  
   
- Returns
 - output stream 
 
Definition at line 165 of file JHostname.hh.
  166    {
  167      return out << 
object.hostname << 
SEPARATOR << 
object.port;
 
  168    }
 
 
 
◆ SEPARATOR
  
  
      
        
          | const char JNET::JHostname::SEPARATOR = ':' | 
         
       
   | 
  
static   | 
  
 
Separation character between hostname and port number. 
Definition at line 39 of file JHostname.hh.
 
 
◆ hostname
      
        
          | std::string JNET::JHostname::hostname | 
        
      
 
 
◆ port
      
        
          | int JNET::JHostname::port | 
        
      
 
 
The documentation for this struct was generated from the following file: