Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Base.h

00001 /*
00002  * Copyright 2003 Michael A. Marsh, Cornell University. All rights reserved.
00003  * This software is released under the modified BSD license.
00004  * See the file LICENSE in the top-level directory for details.
00005  */
00006 //
00007 // $Id: Base.h,v 1.4 2005/01/21 19:44:15 mmarsh Exp $
00008 //
00009 // $Log: Base.h,v $
00010 // Revision 1.4  2005/01/21 19:44:15  mmarsh
00011 // Updated for compatibility with Doxygen 1.4.1
00012 //
00013 // Revision 1.3  2004/05/19 15:56:37  mmarsh
00014 // Added copyright and license statements.
00015 //
00016 // Revision 1.2  2003/11/04 22:31:46  mmarsh
00017 // *** empty log message ***
00018 //
00019 //
00020 
00021 #ifndef __CODEX_ASN1_BASE_H__
00022 #define __CODEX_ASN1_BASE_H__
00023 
00024 
00025 #include <openssl/asn1.h>
00026 #include <openssl/asn1_mac.h>
00027 #include <openssl/err.h>
00028 #include <string>
00029 #include <iostream>
00030 #include "config.h"
00031 
00032 #ifdef NEED_CHAR_TRAITS_UCHAR
00033 namespace std {
00034    template<>
00035    struct char_traits<unsigned char>
00036    {
00037          typedef unsigned char     char_type;
00038          typedef unsigned int      int_type;
00039          typedef streampos         pos_type;
00040          typedef streamoff         off_type;
00041          typedef mbstate_t         state_type;
00042 
00043          static void 
00044          assign(char_type& __c1, const char_type& __c2)
00045          { __c1 = __c2; }
00046 
00047          static bool 
00048          eq(const char_type& __c1, const char_type& __c2)
00049          { return __c1 == __c2; }
00050 
00051          static bool 
00052          lt(const char_type& __c1, const char_type& __c2)
00053          { return __c1 < __c2; }
00054 
00055          static int 
00056          compare(const char_type* __s1, const char_type* __s2, size_t __n)
00057          { return memcmp(__s1, __s2, __n); }
00058 
00059          static size_t
00060          length(const char_type* __s)
00061          { return strlen((const char*)__s); }
00062 
00063          static const char_type* 
00064          find(const char_type* __s, size_t __n, const char_type& __a)
00065          { return static_cast<const char_type*>(memchr(__s, __a, __n)); }
00066 
00067          static char_type* 
00068          move(char_type* __s1, const char_type* __s2, size_t __n)
00069          { return static_cast<char_type*>(memmove(__s1, __s2, __n)); }
00070 
00071          static char_type* 
00072          copy(char_type* __s1, const char_type* __s2, size_t __n)
00073          {  return static_cast<char_type*>(memcpy(__s1, __s2, __n)); }
00074 
00075          static char_type* 
00076          assign(char_type* __s, size_t __n, char_type __a)
00077          { return static_cast<char_type*>(memset(__s, __a, __n)); }
00078 
00079          static char_type 
00080          to_char_type(const int_type& __c)
00081          { return static_cast<char_type>(__c); }
00082 
00083          // To keep both the byte 0xff and the eof symbol 0xffffffff
00084          // from ending up as 0xffffffff.
00085          static int_type 
00086          to_int_type(const char_type& __c)
00087          { return static_cast<int_type>(static_cast<unsigned char>(__c)); }
00088 
00089          static bool 
00090          eq_int_type(const int_type& __c1, const int_type& __c2)
00091          { return __c1 == __c2; }
00092 
00093          static int_type 
00094          eof() { return static_cast<int_type>(EOF); }
00095 
00096          static int_type 
00097          not_eof(const int_type& __c)
00098          { return (__c == eof()) ? 0 : __c; }
00099    };
00100 }
00101 #endif /* NEED_CHAR_TRAITS_UCHAR */
00102 
00103 using namespace std;
00104 
00135 namespace CODEX_ASN1
00136 {
00138    typedef basic_string< unsigned char > ustring;
00139 
00142    class Base
00143    {
00144       public :
00146          Base( bool initialized );
00148          virtual ~Base();
00149 
00157          virtual int marshal( unsigned char ** pp ) const = 0;
00158 
00168          virtual void* unmarshal( void* bogus,
00169                                   unsigned char** pp,
00170                                   long length ) = 0;
00171 
00175          bool initialized() const { return m_initialized; }
00176 
00177       protected :
00179          bool m_initialized;
00180 
00181       private :
00182          void operator=( const Base& ); // stop default
00183    };
00184 
00185 }
00186 
00187 #endif /* __CODEX_ASN1_BASE_H__ */

Generated on Fri May 6 17:38:34 2005 for COrnell Data EXchange (CODEX) by  doxygen 1.4.1