X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FParseInt.hh;h=0d4f4f349bdfd677fa6e2488e6a25d41ae3f537d;hb=9a988902090d28007578e93bffd809f6bd913155;hp=1207eafe915550dd31c3c3125e71d1698ce5583f;hpb=c52cd7d87dbb525c1267aad27391b8b7365dbb57;p=senf.git diff --git a/Packets/ParseInt.hh b/Packets/ParseInt.hh index 1207eaf..0d4f4f3 100644 --- a/Packets/ParseInt.hh +++ b/Packets/ParseInt.hh @@ -1,6 +1,6 @@ // $Id$ // -// Copyright (C) 2006 +// Copyright (C) 2006 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) // Kompetenzzentrum fuer Satelitenkommunikation (SatCom) // Stefan Bund @@ -24,6 +24,7 @@ #define HH_ParseInt_ 1 // Custom includes +#include #include "ParserBase.hh" #include #include @@ -33,14 +34,14 @@ ///////////////////////////////hh.p//////////////////////////////////////// #include "ParseInt.ih" -namespace satcom { -namespace pkf { +namespace senf { + template struct Parse_Int8 - : public impl::ParseIntOps,boost::int8_t>, + : public impl::ParseIntOps,boost::int8_t>, public ParserBase - { + { template struct rebind { typedef Parse_Int8 parser; }; typedef Iterator byte_iterator; @@ -58,10 +59,13 @@ namespace pkf { void value(value_type v) { this->i()[0] = v; } Parse_Int8 const & operator= (value_type other) { value(other); return *this; } }; + template + std::ostream & operator<<(std::ostream & os, Parse_Int8 const & i) + { os << i.value(); return os; } template struct Parse_UInt8 - : public impl::ParseIntOps,boost::uint8_t>, + : public impl::ParseIntOps,boost::uint8_t>, public ParserBase { template @@ -69,7 +73,7 @@ namespace pkf { typedef Iterator byte_iterator; static unsigned bytes() { return 1; } - + Parse_UInt8() {} explicit Parse_UInt8(Iterator const & i) : ParserBase(i) {} @@ -81,10 +85,13 @@ namespace pkf { void value(value_type v) { this->i()[0] = v; } Parse_UInt8 const & operator= (value_type other) { value(other); return *this; } }; + template + std::ostream & operator<<(std::ostream & os, Parse_UInt8 const & i) + { os << i.value(); return os; } template struct Parse_Int16 - : public impl::ParseIntOps,boost::int16_t>, + : public impl::ParseIntOps,boost::int16_t>, public ParserBase { template @@ -104,10 +111,13 @@ namespace pkf { void value(value_type v) { impl::write_uint16(this->i(),v); } Parse_Int16 const & operator= (value_type other) { value(other); return *this; } }; + template + std::ostream & operator<<(std::ostream & os, Parse_Int16 const & i) + { os << i.value(); return os; } template struct Parse_UInt16 - : public impl::ParseIntOps,boost::uint16_t>, + : public impl::ParseIntOps,boost::uint16_t>, public ParserBase { template @@ -127,10 +137,13 @@ namespace pkf { void value(value_type v) { impl::write_uint16(this->i(),v); } Parse_UInt16 const & operator= (value_type other) { value(other); return *this; } }; + template + std::ostream & operator<<(std::ostream & os, Parse_UInt16 const & i) + { os << i.value(); return os; } template struct Parse_Int24 - : public impl::ParseIntOps,boost::int32_t>, + : public impl::ParseIntOps,boost::int32_t>, public ParserBase { template @@ -146,15 +159,18 @@ namespace pkf { typedef boost::int32_t value_type; - value_type value() const { + value_type value() const { value_type v (impl::parse_uint24(this->i())); return v&0x800000 ? v|0xff000000 : v; } void value(value_type v) { impl::write_uint24(this->i(),v); } Parse_Int24 const & operator= (value_type other) { value(other); return *this; } }; + template + std::ostream & operator<<(std::ostream & os, Parse_Int24 const & i) + { os << i.value(); return os; } template struct Parse_UInt24 - : public impl::ParseIntOps,boost::uint32_t>, + : public impl::ParseIntOps,boost::uint32_t>, public ParserBase { template @@ -174,10 +190,13 @@ namespace pkf { void value(value_type v) { impl::write_uint24(this->i(),v); } Parse_UInt24 const & operator= (value_type other) { value(other); return *this; } }; + template + std::ostream & operator<<(std::ostream & os, Parse_UInt24 const & i) + { os << i.value(); return os; } template struct Parse_Int32 - : public impl::ParseIntOps,boost::int32_t>, + : public impl::ParseIntOps,boost::int32_t>, public ParserBase { template @@ -197,10 +216,13 @@ namespace pkf { void value(value_type v) { impl::write_uint32(this->i(),v); } Parse_Int32 const & operator= (value_type other) { value(other); return *this; } }; + template + std::ostream & operator<<(std::ostream & os, Parse_Int32 const & i) + { os << i.value(); return os; } template struct Parse_UInt32 - : public impl::ParseIntOps,boost::uint32_t>, + : public impl::ParseIntOps,boost::uint32_t>, public ParserBase { template @@ -220,10 +242,13 @@ namespace pkf { void value(value_type v) { impl::write_uint32(this->i(),v); } Parse_UInt32 const & operator= (value_type other) { value(other); return *this; } }; + template + std::ostream & operator<<(std::ostream & os, Parse_UInt32 const & i) + { os << i.value(); return os; } template struct Parse_IntField - : public impl::ParseIntOps,boost::int32_t>, + : public impl::ParseIntOps,boost::int32_t>, public ParserBase { template @@ -239,7 +264,7 @@ namespace pkf { typedef boost::int32_t value_type; - value_type value() const { + value_type value() const { value_type v (impl::parse_bitfield::parse(this->i())); return v&boost::high_bit_mask_t::high_bit ? v | ~boost::low_bits_mask_t::sig_bits : v; @@ -251,10 +276,13 @@ namespace pkf { BOOST_STATIC_ASSERT( start + std::ostream & operator<<(std::ostream & os, Parse_IntField const & i) + { os << i.value(); return os; } template struct Parse_UIntField - : public impl::ParseIntOps,boost::uint32_t>, + : public impl::ParseIntOps,boost::uint32_t>, public ParserBase { template @@ -278,10 +306,13 @@ namespace pkf { BOOST_STATIC_ASSERT( start + std::ostream & operator<<(std::ostream & os, Parse_UIntField const & i) + { os << i.value(); return os; } template struct Parse_Flag - : public impl::ParseIntOps,bool>, + : public impl::ParseIntOps,bool>, public ParserBase { template @@ -298,14 +329,17 @@ namespace pkf { typedef bool value_type; value_type value() const { return this->i()[bit/8] & (1<<(7-(bit%8))); } - void value(value_type v) { + void value(value_type v) { if (v) this->i()[0] |= 1<<(7-(bit%8)); else this->i()[0] &= ~(1<<(7-(bit%8))); } Parse_Flag const & operator= (value_type other) { value(other); return *this; } }; + template + std::ostream & operator<<(std::ostream & os, Parse_Flag const & i) + { os << i.value(); return os; } -}} +} ///////////////////////////////hh.e//////////////////////////////////////// //#include "ParseInt.cci" @@ -316,5 +350,8 @@ namespace pkf { // Local Variables: // mode: c++ -// c-file-style: "satcom" +// fill-column: 100 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" // End: