Jpp  18.0.0-rc.3
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
JNET::JHostname Struct Reference

Auxiliary data structure for hostname and port number. More...

#include <JHostname.hh>

Inheritance diagram for JNET::JHostname:
KM3NETDAQ::JDAQProcess

Public Member Functions

 JHostname ()
 Default constructor. More...
 
 JHostname (const std::string &buffer)
 Constructor. More...
 
 JHostname (const std::string &hostname, const int port)
 Constructor. More...
 
void set (const std::string &buffer)
 Set hostname and port number. More...
 

Public Attributes

std::string hostname
 
int port
 

Static Public Attributes

static const char SEPARATOR = ':'
 Separation character between hostname and port number. More...
 

Friends

std::istream & operator>> (std::istream &in, JHostname &object)
 Read hostname from input stream. More...
 
std::ostream & operator<< (std::ostream &out, const JHostname &object)
 Write hostname to output stream. More...
 

Detailed Description

Auxiliary data structure for hostname and port number.

Definition at line 30 of file JHostname.hh.

Constructor & Destructor Documentation

JNET::JHostname::JHostname ( )
inline

Default constructor.

Definition at line 41 of file JHostname.hh.

41  :
42  hostname(""),
43  port(-1)
44  {}
std::string hostname
Definition: JHostname.hh:154
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
bufferhost name and optional port number

Definition at line 57 of file JHostname.hh.

58  {
59  set(buffer);
60  }
void set(const std::string &buffer)
Set hostname and port number.
Definition: JHostname.hh:87
JNET::JHostname::JHostname ( const std::string hostname,
const int  port 
)
inline

Constructor.

Parameters
hostnamehostname
portport number

Definition at line 69 of file JHostname.hh.

71  {
72  this->hostname = hostname;
73  this->port = port;
74  }
std::string hostname
Definition: JHostname.hh:154

Member Function Documentation

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
bufferhost name and optional port number

Definition at line 87 of file JHostname.hh.

88  {
89  using namespace std;
90 
91  const string::size_type pos = buffer.find(SEPARATOR);
92 
93  if (pos != string::npos) {
94 
95  this->hostname = buffer.substr(0, pos);
96 
97  istringstream(buffer.substr(pos + 1)) >> this->port;
98 
99  } else {
100 
101  bool is_number = true;
102 
103  for (string::const_iterator i = buffer.begin(); is_number && i != buffer.end(); ++i) {
104  is_number &= isdigit(*i);
105  }
106 
107  if (is_number) {
108 
109  this->hostname = "";
110 
111  istringstream(buffer) >> this->port;
112 
113  } else {
114 
115  this->hostname = buffer;
116  this->port = DISPATCH_PORT;
117  }
118  }
119  }
static const int DISPATCH_PORT
Default ControlHost port.
Definition: JHostname.hh:24
std::string hostname
Definition: JHostname.hh:154
static const char SEPARATOR
Separation character between hostname and port number.
Definition: JHostname.hh:35

Friends And Related Function Documentation

std::istream& operator>> ( std::istream &  in,
JHostname object 
)
friend

Read hostname from input stream.

Parameters
ininput stream
objecthostname
Returns
input stream

Definition at line 129 of file JHostname.hh.

130  {
131  std::string buffer;
132 
133  if (in >> buffer) {
134  object.set(buffer);
135  }
136 
137  return in;
138  }
then awk string
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
std::ostream& operator<< ( std::ostream &  out,
const JHostname object 
)
friend

Write hostname to output stream.

Parameters
outoutput stream
objecthostname
Returns
output stream

Definition at line 148 of file JHostname.hh.

149  {
150  return out << object.hostname << SEPARATOR << object.port;
151  }
static const char SEPARATOR
Separation character between hostname and port number.
Definition: JHostname.hh:35

Member Data Documentation

const char JNET::JHostname::SEPARATOR = ':'
static

Separation character between hostname and port number.

Definition at line 35 of file JHostname.hh.

std::string JNET::JHostname::hostname

Definition at line 154 of file JHostname.hh.

int JNET::JHostname::port

Definition at line 155 of file JHostname.hh.


The documentation for this struct was generated from the following file: