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 tool
00029 {
00030
00042 template <class ValueType, unsigned N,
00043 bool HexNotation, char SepNotation>
00044 struct addr
00045 {
00047 addr();
00048
00064 addr(const void* a);
00065
00076 addr(const std::string&);
00077
00087 addr(std::istream&);
00088
00093 std::istream& read(std::istream&);
00094
00096
00097 bool operator < (const addr&) const;
00098 bool operator == (const addr&) const;
00099 bool operator != (const addr&) const;
00101
00103
00104 ValueType& operator [] (unsigned);
00105 const ValueType& operator [] (unsigned) const;
00107
00109 void dump(void *) const;
00110
00112 static const addr& null();
00113
00115 static const addr& broadcast();
00116
00117 private:
00118
00119 ValueType addr_[N];
00120
00121 } __attribute__((__packed__));
00122
00124 template <class VT, unsigned N, bool HN, char SN>
00125 std::ostream&
00126 operator << (std::ostream& os, const addr<VT, N, HN, SN>& a);
00127
00129 template <class VT, unsigned N, bool HN, char SN>
00130 std::istream&
00131 operator >> (std::istream& is, addr<VT, N, HN, SN>& a);
00132
00134 template <class VT, unsigned N, bool HN, char SN>
00135 std::string
00136 make_string(const addr<VT, N, HN, SN>& a);
00137
00138 }
00139
00140 # include "addr.hxx"
00141
00142 #endif // ! TOOL_ADDR_HH_