libDwm-0.6.0
DwmMacAddress.hh
Go to the documentation of this file.
1 //===========================================================================
2 // @(#) $DwmPath: dwm/libDwm/tags/libDwm-0.6.0/include/DwmMacAddress.hh 8401 $
3 // @(#) $Id: DwmMacAddress.hh 8401 2016-04-17 06:44:31Z dwm $
4 //===========================================================================
5 // Copyright (c) Daniel W. McRobb 2007
6 // All rights reserved.
7 //
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions
10 // are met:
11 //
12 // 1. Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 // 2. Redistributions in binary form must reproduce the above copyright
15 // notice, this list of conditions and the following disclaimer in the
16 // documentation and/or other materials provided with the distribution.
17 // 3. The names of the authors and copyright holders may not be used to
18 // endorse or promote products derived from this software without
19 // specific prior written permission.
20 //
21 // IN NO EVENT SHALL DANIEL W. MCROBB BE LIABLE TO ANY PARTY FOR
22 // DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
23 // INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE,
24 // EVEN IF DANIEL W. MCROBB HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
25 // DAMAGE.
26 //
27 // THE SOFTWARE PROVIDED HEREIN IS ON AN "AS IS" BASIS, AND
28 // DANIEL W. MCROBB HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
29 // UPDATES, ENHANCEMENTS, OR MODIFICATIONS. DANIEL W. MCROBB MAKES NO
30 // REPRESENTATIONS AND EXTENDS NO WARRANTIES OF ANY KIND, EITHER
31 // IMPLIED OR EXPRESS, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
32 // WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE,
33 // OR THAT THE USE OF THIS SOFTWARE WILL NOT INFRINGE ANY PATENT,
34 // TRADEMARK OR OTHER RIGHTS.
35 //===========================================================================
36 
37 //---------------------------------------------------------------------------
40 //---------------------------------------------------------------------------
41 
42 #ifndef _DWMMACADDRESS_HH_
43 #define _DWMMACADDRESS_HH_
44 
45 #include "DwmBZ2Readable.hh"
46 #include "DwmBZ2Writable.hh"
47 #include "DwmGZReadable.hh"
48 #include "DwmGZWritable.hh"
49 #include "DwmReadable.hh"
50 #include "DwmWritable.hh"
51 
52 namespace Dwm {
53 
54  //--------------------------------------------------------------------------
56  //--------------------------------------------------------------------------
57  class MacAddress
58  : public Readable, public Writable,
59  public GZReadable, public GZWritable,
60  public BZ2Readable, public BZ2Writable
61  {
62  public:
63  //------------------------------------------------------------------------
65  //------------------------------------------------------------------------
66  MacAddress();
67 
68  //------------------------------------------------------------------------
70  //------------------------------------------------------------------------
71  MacAddress(const std::string & s);
72 
73  //------------------------------------------------------------------------
75  //------------------------------------------------------------------------
76  MacAddress(const MacAddress & addr);
77 
78  //------------------------------------------------------------------------
80  //------------------------------------------------------------------------
81  MacAddress & operator = (const MacAddress & addr);
82 
83  //------------------------------------------------------------------------
85  //------------------------------------------------------------------------
86  bool operator == (const MacAddress & addr) const;
87 
88  //------------------------------------------------------------------------
90  //------------------------------------------------------------------------
91  std::istream & Read(std::istream & is);
92 
93  //------------------------------------------------------------------------
95  //------------------------------------------------------------------------
96  std::ostream & Write(std::ostream & os) const;
97 
98  //------------------------------------------------------------------------
101  //------------------------------------------------------------------------
102  ssize_t Read(int fd);
103 
104  //------------------------------------------------------------------------
107  //------------------------------------------------------------------------
108  ssize_t Write(int fd) const;
109 
110  //------------------------------------------------------------------------
113  //------------------------------------------------------------------------
114  size_t Read(FILE *f);
115 
116  //------------------------------------------------------------------------
119  //------------------------------------------------------------------------
120  size_t Write(FILE *f) const;
121 
122  //------------------------------------------------------------------------
125  //------------------------------------------------------------------------
126  int Read(gzFile gzf);
127 
128  //------------------------------------------------------------------------
131  //------------------------------------------------------------------------
132  int Write(gzFile gzf) const;
133 
134  //------------------------------------------------------------------------
137  //------------------------------------------------------------------------
138  int BZRead(BZFILE *bzf);
139 
140  //------------------------------------------------------------------------
143  //------------------------------------------------------------------------
144  int BZWrite(BZFILE *bzf) const;
145 
146  //------------------------------------------------------------------------
149  //------------------------------------------------------------------------
150  uint32_t StreamedLength() const;
151 
152  //------------------------------------------------------------------------
154  //------------------------------------------------------------------------
155  friend std::ostream &
156  operator << (std::ostream & os, const MacAddress & addr);
157 
158  //------------------------------------------------------------------------
160  //------------------------------------------------------------------------
161  friend std::istream &
162  operator >> (std::istream & is, MacAddress & addr);
163 
164  protected:
165  uint8_t _addr[6];
166  };
167 
168 } // namespace Dwm
169 
170 #endif // _DWMMACADDRESS_HH_
171 
172 //---------------------------- emacs settings -----------------------------
173 // Local Variables:
174 // mode: C++/la
175 // tab-width: 2
176 // indent-tabs-mode: nil
177 // c-basic-offset: 2
178 // End:
179 //-------------------------------------------------------------------------
friend std::ostream & operator<<(std::ostream &os, const MacAddress &addr)
Prints to an ostream in &#39;xx:xx:xx:xx:xx:xx&#39; format.
friend std::istream & operator>>(std::istream &is, MacAddress &addr)
Reads from an istream in &#39;xx:xx:xx:xx:xx:xx&#39; format.
This class is a pure virtual class, defining an interface for classes that can write their contents t...
Definition: DwmGZWritable.hh:57
Dwm::Writable pure virtual class definition.
Dwm::BZ2Readable pure virtual class definition.
Dwm::GZReadable pure virtual class definition.
bool operator==(const MacAddress &addr) const
operator ==
int BZRead(BZFILE *bzf)
Reads the MAC address from a BZFILE.
Dwm::Readable pure virtual class definition.
MacAddress & operator=(const MacAddress &addr)
operator =
MacAddress()
Constructor. Sets the address to 00:00:00:00:00:00.
Encapsulates a 6-byte MAC address.
Definition: DwmMacAddress.hh:57
This class is a pure virtual class, defining an interface for classes that can read their contents fr...
Definition: DwmBZ2Readable.hh:57
int BZWrite(BZFILE *bzf) const
Writes the MAC address to a BZFILE.
Dwm::BZ2Writable pure virtual class definition.
Definition: DwmBZ2IO.hh:67
This class is a pure virtual class, defining an interface for classes that can read their contents fr...
Definition: DwmGZReadable.hh:57
std::ostream & Write(std::ostream &os) const
Writes the MAC address to an ostream. Returns the ostream.
This class defines an interface for classes that can write their contents to an ostream, file descriptor or FILE pointer.
Definition: DwmWritable.hh:58
This class is a pure virtual class, defining an interface for classes that can write their contents t...
Definition: DwmBZ2Writable.hh:57
Dwm::GZWritable pure virtual class definition.
This class defines an interface for classes that can read their contents from an istream, file descriptor or FILE pointer.
Definition: DwmReadable.hh:58
uint32_t StreamedLength() const
Returns the number of bytes that should be written if we call one of the Write() members.
std::istream & Read(std::istream &is)
Reads the MAC address from an istream. Returns the istream.