00001 // OSB library ************************************************ -*- C++ -*- 00006 /* 00007 AUTHOR(S): Stephan Broennimann (vb) 00008 00009 RCS information 00010 $Name: OSB_060808 $ 00011 $Revision: 1.1 $ 00012 00013 License 00014 OSB rating and billing library for communication networks 00015 Copyright (C) 2004, 2005, 2006 OSB systems 00016 00017 This file may be distributed and/or modify under the terms of the 00018 GNU General Public License (GPL) as published by the Free Software 00019 Foundation which is provided in the file LICENSE.GPL included in the 00020 packaging of this file. 00021 00022 The file is distributed in the hope that it will be useful, but WITHOUT 00023 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00024 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00025 for more details. 00026 00027 Holders of a OSB Commercial License may use this file under the terms 00028 and conditions of this commercial license. 00029 */ 00030 #ifndef _ASN1ENCODE_H_ 00031 #define _ASN1ENCODE_H_ 00032 00033 // ************************************************************************ 00034 // included header files 00035 // + standard includes 00036 #include <string> 00037 00038 // + libraries 00039 00040 // + local headers 00041 #include "asn1fwd.h" 00042 00043 // + class declarations 00044 namespace OSB_LIB { 00045 class Asn1Buffer; // asn1writer.h 00046 } 00047 00048 // ************************************************************************ 00049 // namespace extensions 00050 namespace OSB_LIB { 00051 00052 // ************************************************************************ 00053 // forward declarations 00054 00055 // ************************************************************************ 00056 // type definitions 00057 00058 // ************************************************************************ 00059 // class definitions 00063 class Asn1Encoder { 00064 public: 00066 virtual ~Asn1Encoder() {} 00067 public: 00073 virtual void operator()(Asn1Buffer& dest) const = 0; 00075 virtual size_t tagValue() const = 0; 00076 }; // class Asn1Encoder 00077 00081 class Asn1DataEncoder { 00082 public: 00084 virtual ~Asn1DataEncoder() {} 00085 public: 00091 virtual void operator()(Asn1Data& dest) const = 0; 00093 virtual size_t tagValue() const = 0; 00094 }; // class Asn1DataEncoder 00095 00099 class Long2Asn1 : public Asn1DataEncoder { 00100 public: 00102 Long2Asn1( 00103 size_t tagVal, 00104 long src 00105 ) : tag_(tagVal), src_(src) {} 00106 00108 void operator()(Asn1Data& dest) const; 00109 00110 // Documentation from base class. 00111 size_t tagValue() const { return tag_; } 00112 private: 00114 size_t tag_; 00116 long src_; 00117 }; // class Long2Asn1 00118 00122 class String2Asn1 : public Asn1DataEncoder { 00123 public: 00127 String2Asn1( 00128 size_t tagVal, 00129 const std::string& src 00130 ) : tag_(tagVal), src_(src) 00131 { 00132 // empty 00133 } 00134 00136 void operator()(Asn1Data& dest) const; 00137 00138 // Documentation from base class. 00139 size_t tagValue() const { return tag_; } 00140 private: 00142 size_t tag_; 00144 std::string src_; 00145 }; // class String2Asn1 00146 00155 class Data2Asn1 : public Asn1DataEncoder { 00156 public: 00158 Data2Asn1( 00159 size_t tag, 00160 const Asn1Data& src 00161 ) : tag_(tag), src_(src) {} 00162 00164 void operator()(Asn1Data& dest) const; 00165 00167 size_t tagValue() const { return tag_; } 00168 private: 00170 size_t tag_; 00172 const Asn1Data& src_; 00173 }; 00174 } // namespace OSB_LIB 00175 00176 // ************************************************************************ 00177 // inline definitions 00178 namespace OSB_LIB { 00179 } // namespace OSB_LIB 00180 #endif // #ifndef _ASN1ENCODE_H_