base.hpp

См. документацию.
00001 /*
00002 
00003 Copyright (c) 2002-2005, Yauheni Akhotnikau
00004 All rights reserved.
00005 
00006 Redistribution and use in source and binary forms, with or without
00007 modification, are permitted provided that the following conditions are met:
00008 
00009 - Redistributions of source code must retain the above copyright notice, this
00010 list of conditions and the following disclaimer.
00011 
00012 - Redistributions in binary form must reproduce the above copyright notice, this
00013 list of conditions and the following disclaimer in the documentation and/or
00014 other materials provided with the distribution.
00015 
00016 - The name of the author may not be used to endorse or promote products derived
00017 from this software without specific prior written permission.
00018 
00019 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
00020 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00021 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
00022 EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00023 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
00024 OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00026 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
00027 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
00028 OF SUCH DAMAGE.
00029 
00030 */
00031 
00037 #if !defined( _OESS_1__TLV__BASE_HPP_ )
00038 #define _OESS_1__TLV__BASE_HPP_
00039 
00040 #include <oess_1/tlv/h/declspec.hpp>
00041 
00042 #include <oess_1/io/h/binstream.hpp>
00043 
00044 namespace oess_1
00045 {
00046 
00047 namespace tlv
00048 {
00049 
00051 
00061 typedef oess_1::uint_t  default_tag_type_t;
00062 
00063 //
00064 // tag_processor_t
00065 //
00066 
00068 
00083 class OESS_1__TLV__TYPE tag_processor_t
00084 {
00085   public :
00086     virtual ~tag_processor_t();
00087 
00090     virtual size_t
00091     tlv_tag_size() const = 0;
00092 
00094     virtual void
00095     tlv_unpack_tag(
00098       oess_1::io::ibinstream_t & s ) = 0;
00099 
00101     virtual void
00102     tlv_pack_tag(
00105       oess_1::io::obinstream_t & s ) const = 0;
00106 
00108     virtual default_tag_type_t
00109     query_tag() const = 0;
00110 
00112     virtual void
00113     set_tag( const default_tag_type_t & value ) = 0;
00114 };
00115 
00116 //
00117 // length_processor_t
00118 //
00119 
00121 
00137 class OESS_1__TLV__TYPE length_processor_t
00138 {
00139   public :
00140     virtual ~length_processor_t();
00141 
00144     virtual size_t
00145     tlv_length_size(
00147       size_t value_length ) const = 0;
00148 
00150     virtual void
00151     tlv_unpack_length(
00154       oess_1::io::ibinstream_t & s,
00156       size_t & value_length ) = 0;
00157 
00159     virtual void
00160     tlv_pack_length(
00163       oess_1::io::obinstream_t & s,
00165       size_t value_length ) const = 0;
00166 };
00167 
00168 //
00169 // tlv_base_t
00170 //
00171 
00173 class OESS_1__TLV__TYPE tlv_base_t
00174 {
00175   public :
00176     virtual ~tlv_base_t();
00177 
00179 
00190     virtual default_tag_type_t
00191     tlv_tag() const = 0;
00192 
00196 
00202     virtual size_t
00203     tlv_size() const = 0;
00204 
00206 
00210     virtual void
00211     tlv_unpack(
00214       oess_1::io::ibinstream_t & s,
00218       default_tag_type_t tag_id ) = 0;
00219 
00221 
00224     virtual void
00225     tlv_pack(
00228       oess_1::io::obinstream_t & s ) const = 0;
00229 };
00230 
00231 //
00232 // tlv_extractor_t
00233 //
00234 
00237 
00258 class  OESS_1__TLV__TYPE  tlv_extractor_t
00259 {
00260   public :
00261     inline
00262     tlv_extractor_t(
00263       const tag_processor_t & tag_processor,
00264       tlv_base_t & tlv )
00265       :
00266         m_tag_processor( tag_processor ),
00267         m_tlv( tlv )
00268     {
00269     }
00270 
00271     inline void
00272     tlv_unpack( oess_1::io::ibinstream_t & s )
00273     {
00274       m_tlv.tlv_unpack( s, m_tag_processor.query_tag() );
00275     }
00276 
00277   private :
00278     const tag_processor_t & m_tag_processor;
00279     tlv_base_t &  m_tlv;
00280 };
00281 
00283 
00287 inline oess_1::io::ibinstream_t &
00288 operator>>(
00291   oess_1::io::ibinstream_t & s,
00293   tlv_extractor_t & o )
00294 {
00295   o.tlv_unpack( s );
00296   return s;
00297 }
00298 
00300 inline oess_1::io::obinstream_t &
00301 operator<<(
00304   oess_1::io::obinstream_t & s,
00306   const tlv_base_t & o )
00307 {
00308   o.tlv_pack( s );
00309   return s;
00310 }
00311 
00312 } /* namespace tlv */
00313 
00314 } /* namespace oess_1 */
00315 
00316 #endif
00317 

Документация по ObjESSty. Последние изменения: Fri Oct 13 18:35:36 2006. Создано системой  doxygen 1.4.7
Hosted by uCoz