Jpp  17.1.1
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 28 of file JMACAddress.hh.

Member Enumeration Documentation

anonymous enum
Enumerator
NUMBER_OF_BYTES 

number of bytes

Definition at line 32 of file JMACAddress.hh.

32  {
33  NUMBER_OF_BYTES = 6 //!< number of bytes
34  };

Constructor & Destructor Documentation

JDATABASE::JMACAddress::JMACAddress ( )
inline

Default constructor.

Definition at line 71 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 42 of file JMACAddress.hh.

43  {
44  return ":.-";
45  }
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 54 of file JMACAddress.hh.

55  {
56  const std::string buffer(JMACAddress::get_separator());
57 
58  for (std::string::const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
59  if ((int) *i == c) {
60  return true;
61  }
62  }
63 
64  return false;
65  }
static const char * get_separator()
Get list of allowed separators.
Definition: JMACAddress.hh:42
$WORKDIR ev_configure_domsimulator txt echo process $DOM_SIMULATOR $i $SOURCE_HOST[$index] csh c(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&($DOM_SIMULATOR\-u\$NAME\$\-H\$SERVER\$\-M\$LOGGER\$\-d $DEBUG</dev/null > &/dev/null &))'
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 82 of file JMACAddress.hh.

83  {
84  for (int i = 0; i != NUMBER_OF_BYTES; ++i) {
85  if ((*this)[i] != address[i]) {
86  return false;
87  }
88  }
89 
90  return true;
91  }
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 101 of file JMACAddress.hh.

102  {
103  using namespace std;
104 
105  object = JMACAddress();
106 
107  int c;
108 
109  if (in >> hex >> c) {
110 
111  object[0] = (unsigned char) c;
112 
113  for (int i = 1; i != NUMBER_OF_BYTES; ++i) {
114  if (is_separator(in.get()) && in >> hex >> c)
115  object[i] = (unsigned char) c;
116  else
117  in.setstate(ios::failbit);
118  }
119  }
120 
121  return in >> dec;
122  }
JMACAddress()
Default constructor.
Definition: JMACAddress.hh:71
static bool is_separator(const int c)
Check if given character is an allowed separator.
Definition: JMACAddress.hh:54
$WORKDIR ev_configure_domsimulator txt echo process $DOM_SIMULATOR $i $SOURCE_HOST[$index] csh c(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&($DOM_SIMULATOR\-u\$NAME\$\-H\$SERVER\$\-M\$LOGGER\$\-d $DEBUG</dev/null > &/dev/null &))'
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 JMACAddress object 
)
friend

Write MAC address to output stream.

Parameters
outoutput stream
objectMAC address
Returns
output stream

Definition at line 133 of file JMACAddress.hh.

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

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