Jpp  19.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
JDATABASE::JMACAddress Struct Reference

MAC address. More...

#include <JMACAddress.hh>

Inheritance diagram for JDATABASE::JMACAddress:
std::vector< unsigned char > JLANG::JEquals< JFirst_t, JSecond_t >

Public Types

enum  { NUMBER_OF_BYTES = 6 }
 

Public Member Functions

 JMACAddress ()
 Default constructor. More...
 
bool equal (const JMACAddress &address) const
 Equal method. More...
 
 ClassDefNV (JMACAddress, 1)
 

Static Public Member Functions

static const char * get_separator ()
 Get list of allowed separators. More...
 
static bool is_separator (const int c)
 Check if given character is an allowed separator. More...
 

Friends

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

Detailed Description

MAC address.

Definition at line 30 of file JMACAddress.hh.

Member Enumeration Documentation

anonymous enum
Enumerator
NUMBER_OF_BYTES 

number of bytes

Definition at line 34 of file JMACAddress.hh.

34  {
35  NUMBER_OF_BYTES = 6 //!< number of bytes
36  };

Constructor & Destructor Documentation

JDATABASE::JMACAddress::JMACAddress ( )
inline

Default constructor.

Definition at line 73 of file JMACAddress.hh.

Member Function Documentation

static const char* JDATABASE::JMACAddress::get_separator ( )
inlinestatic

Get list of allowed separators.

Returns
allowed separators

Definition at line 44 of file JMACAddress.hh.

45  {
46  return ":.-";
47  }
static bool JDATABASE::JMACAddress::is_separator ( const int  c)
inlinestatic

Check if given character is an allowed separator.

Parameters
ccharacter
Returns
true if separator; else false

Definition at line 56 of file JMACAddress.hh.

57  {
58  const std::string buffer(JMACAddress::get_separator());
59 
60  for (std::string::const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
61  if ((int) *i == c) {
62  return true;
63  }
64  }
65 
66  return false;
67  }
$WORKDIR ev_configure_dqsimulator txt echo process $DQ_SIMULATOR $i $SOURCE_HOST[$index] csh c(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&($DQ_SIMULATOR\-u\$NAME\$\-H\$SERVER\$\-M\$LOGGER\$\-d $DEBUG</dev/null > &/dev/null &))'
static const char * get_separator()
Get list of allowed separators.
Definition: JMACAddress.hh:44
bool JDATABASE::JMACAddress::equal ( const JMACAddress address) const
inline

Equal method.

Parameters
addressMAC address
Returns
true if this MAC address and given MAC address are equal; else false

Definition at line 84 of file JMACAddress.hh.

85  {
86  for (int i = 0; i != NUMBER_OF_BYTES; ++i) {
87  if ((*this)[i] != address[i]) {
88  return false;
89  }
90  }
91 
92  return true;
93  }
JDATABASE::JMACAddress::ClassDefNV ( JMACAddress  ,
 
)

Friends And Related Function Documentation

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

Read MAC address from input stream.

Parameters
ininput stream
objectMAC address
Returns
input stream

Definition at line 103 of file JMACAddress.hh.

104  {
105  using namespace std;
106 
107  object = JMACAddress();
108 
109  int c;
110 
111  if (in >> hex >> c) {
112 
113  object[0] = (unsigned char) c;
114 
115  for (int i = 1; i != NUMBER_OF_BYTES; ++i) {
116  if (is_separator(in.get()) && in >> hex >> c)
117  object[i] = (unsigned char) c;
118  else
119  in.setstate(ios::failbit);
120  }
121  }
122 
123  return in >> dec;
124  }
JMACAddress()
Default constructor.
Definition: JMACAddress.hh:73
$WORKDIR ev_configure_dqsimulator txt echo process $DQ_SIMULATOR $i $SOURCE_HOST[$index] csh c(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&($DQ_SIMULATOR\-u\$NAME\$\-H\$SERVER\$\-M\$LOGGER\$\-d $DEBUG</dev/null > &/dev/null &))'
then fatal The output file must have the wildcard in the e g root fi 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:48
static bool is_separator(const int c)
Check if given character is an allowed separator.
Definition: JMACAddress.hh:56
std::ostream& operator<< ( std::ostream &  out,
const JMACAddress object 
)
friend

Write MAC address to output stream.

Parameters
outoutput stream
objectMAC address
Returns
output stream

Definition at line 135 of file JMACAddress.hh.

136  {
137  using namespace std;
138 
139  out << setw(2) << setfill('0') << hex << (int) object[0];
140 
141  for (int i = 1; i != NUMBER_OF_BYTES; ++i) {
142  out << setw(1) << JMACAddress::get_separator()[0]
143  << setw(2) << setfill('0') << hex << (int) object[i];
144  }
145 
146  return out << setfill(' ') << dec;
147  }
static const char * get_separator()
Get list of allowed separators.
Definition: JMACAddress.hh:44

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