asn1print.h

Go to the documentation of this file.
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 _ASN1PRINT_H_
00031 #define _ASN1PRINT_H_
00032 
00033 // ************************************************************************
00034 // included header files
00035 // + standard includes
00036 #include <deque>
00037 #include <string>
00038 
00039 // + libraries
00040 
00041 // + local headers
00042 #include "asn1fwd.h"
00043 
00044 // + class declarations
00045 namespace OSB_LIB {
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
00071     class Asn1Print {
00072     public:
00082         typedef void (*Decoder)(
00083             const Asn1Byte*    data,
00084             const size_t       size,
00085                   std::string& dest
00086         );
00087 
00089         struct Info {
00091             std::string name_;
00093             std::string des_;
00095             Decoder decoder_;
00096 
00098             Info();
00099         };                              // struct Info
00100 
00102         struct Add {
00112             Add(
00113                       Decoder decoder,
00114                 const char*   name,
00115                 const char*   des
00116             );
00117         };                              // struct Add
00118 
00120         typedef std::deque<Info> DecoderList;
00121 
00122     public:
00124         static const DecoderList& decoders();
00125 
00132         static Decoder getDecoder(const std::string& name);
00133 
00140         static const Info* findInfo(const std::string& name);
00141 
00149         static void add(
00150             const Info& info
00151         );
00152 
00154 
00155 
00156         static void prRaw(
00157             const Asn1Byte*    data,
00158             const size_t       size,
00159                   std::string& dest
00160         );
00162         static void prHex(
00163             const Asn1Byte*    data,
00164             const size_t       size,
00165                   std::string& dest
00166         );
00168         static void prInt(
00169             const Asn1Byte*    data,
00170             const size_t       size,
00171                   std::string& dest
00172         );
00174         static void prAscii(
00175             const Asn1Byte*    data,
00176             const size_t       size,
00177                   std::string& dest
00178         );
00180         static void prBcd(
00181             const Asn1Byte*    data,
00182             const size_t       size,
00183                   std::string& dest
00184         );
00186         static void prTbcd(
00187             const Asn1Byte*    data,
00188             const size_t       size,
00189                   std::string& dest
00190         );
00192 
00193     private:
00200         Asn1Print();
00201 
00208         static Info* find(const std::string& name);
00209 
00211         static DecoderList& decoderList();
00212 
00214         void add(
00215                   Decoder decoder,
00216             const char*   name,
00217             const char*   des
00218         );
00219 
00220     private:
00222         static Asn1Print* instance_;
00224         DecoderList decoders_;
00225     };                                  // class Asn1Print
00226 }                                       // namespace OSB_LIB
00227 
00228 // ************************************************************************
00229 // inline definitions
00230 namespace OSB_LIB {
00231 }                                       // namespace OSB_LIB
00232 #endif                                  // #ifndef _ASN1PRINT_H_

Generated on Sat Sep 2 14:06:31 2006 for OSB Library by  doxygen 1.4.7