00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef TOOL_ADDR_HH_
00023 # define TOOL_ADDR_HH_
00024
00025 # include <string>
00026 # include <ostream>
00027
00028 namespace wpl
00029 {
00030
00031 namespace tool
00032 {
00033
00045 template <class ValueType, unsigned N,
00046 bool HexNotation, char SepNotation>
00047 struct addr
00048 {
00050 addr();
00051
00067 addr(const void* a);
00068
00079 addr(const std::string&);
00080
00090 addr(std::istream&);
00091
00096 std::istream& read(std::istream&);
00097
00099
00100 bool operator < (const addr&) const;
00101 bool operator == (const addr&) const;
00102 bool operator != (const addr&) const;
00104
00106
00107 ValueType& operator [] (unsigned);
00108 const ValueType& operator [] (unsigned) const;
00110
00112 void dump(void *) const;
00113
00115 static const addr& null();
00116
00118 static const addr& broadcast();
00119
00129 size_t size() const;
00130
00131 private:
00132
00133 ValueType addr_[N];
00134
00135 } __attribute__((__packed__));
00136
00138 template <class VT, unsigned N, bool HN, char SN>
00139 std::ostream&
00140 operator << (std::ostream& os, const addr<VT, N, HN, SN>& a);
00141
00143 template <class VT, unsigned N, bool HN, char SN>
00144 std::istream&
00145 operator >> (std::istream& is, addr<VT, N, HN, SN>& a);
00146
00148 template <class VT, unsigned N, bool HN, char SN>
00149 std::string
00150 make_string(const addr<VT, N, HN, SN>& a);
00151
00152 }
00153
00154 }
00155
00156 # include "addr.hxx"
00157
00158 #endif // ! TOOL_ADDR_HH_