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

MIME.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (c) 2003-2005 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED,
00008 //  AS TO THE CORRECTNESS OF THIS CODE OR ANY DERIVATIVE
00009 //  WORKS WHICH INCORPORATE IT.
00010 //
00011 //  AUTODESK PROVIDES THE CODE ON AN "AS-IS" BASIS
00012 //  AND EXPLICITLY DISCLAIMS ANY LIABILITY, INCLUDING
00013 //  CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00014 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00015 //
00016 //  Use, duplication, or disclosure by the U.S. Government is subject to
00017 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00018 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00019 //  Data and Computer Software), as applicable.
00020 //
00021 
00022 #ifndef _DWFCORE_MIME_H
00023 #define _DWFCORE_MIME_H
00024 
00029 
00030 
00031 #include "dwfcore/Core.h"
00032 #include "dwfcore/STL.h"
00033 #include "dwfcore/Pointer.h"
00034 #include "dwfcore/Iterator.h"
00035 #include "dwfcore/SkipList.h"
00036 
00037 
00038 
00039 namespace DWFCore
00040 {
00041 
00047 class DWFMIME   : public DWFCoreMemory
00048 {
00049 
00050 public:
00051 
00055     static const wchar_t* const kzMIMEType_DWF1;
00059     static const wchar_t* const kzMIMEType_DWF2;
00063     static const wchar_t* const kzMIMEType_DWF3;
00067     static const wchar_t* const kzMIMEType_W2D;
00071     static const wchar_t* const kzMIMEType_W3D;
00075     static const wchar_t* const kzMIMEType_DSD;
00079     static const wchar_t* const kzMIMEType_PIA;
00083     static const wchar_t* const kzMIMEType_PNG;
00087     static const wchar_t* const kzMIMEType_JPG;
00091     static const wchar_t* const kzMIMEType_TXT;
00095     static const wchar_t* const kzMIMEType_XML;
00099     static const wchar_t* const kzMIMEType_FONT;
00100 
00104     static const wchar_t* const kzExtension_DWF;
00108     static const wchar_t* const kzExtension_W2D;
00112     static const wchar_t* const kzExtension_W3D;
00116     static const wchar_t* const kzExtension_DSD;
00120     static const wchar_t* const kzExtension_PNG;
00124     static const wchar_t* const kzExtension_PIA;
00128     static const wchar_t* const kzExtension_JPG;
00132     static const wchar_t* const kzExtension_TXT;
00136     static const wchar_t* const kzExtension_XML;
00140     static const wchar_t* const kzExtension_FONT;
00141 
00142 public:
00143 
00153     _DWFCORE_API 
00154     static DWFIterator<const wchar_t* const>* GetMIMEType( const wchar_t* const zExtension )
00155         throw( DWFException );
00156 
00164     _DWFCORE_API
00165     static const wchar_t* const GetExtension( const wchar_t* const zMIMEType )
00166         throw( DWFException );
00167 
00168 private:
00169 
00170     //
00171     // Constructor
00172     //
00173     DWFMIME()
00174         throw();
00175 
00176     //
00177     //
00178     //
00179     static void _Build()
00180         throw( DWFException );
00181 
00182 private:
00183 
00184     typedef DWFWCharKeySkipList<const wchar_t*>                             _tList;
00185     typedef multimap<const wchar_t*, const wchar_t*, tDWFWCharCompareLess>  _tMultiMap;
00186 
00187     static DWFPointer<_tList>       _kapTypeMap;         // MIME -> extension
00188     static DWFPointer<_tMultiMap>   _kapExtensionMap;    // extension -> MIME
00189 
00190 private:
00191 
00192     //
00193     //
00194     //
00195     class _Iterator : public DWFIterator<const wchar_t* const>
00196     {
00197 
00198     public:
00199 
00200         //
00201         // Constructor
00202         //
00203         _Iterator( _tMultiMap::iterator iBegin,
00204                    _tMultiMap::iterator iEnd )
00205             throw()
00206             : _iBegin( iBegin )
00207             , _iEnd( iEnd )
00208             , _iCurrent( iBegin )
00209         {;}
00210 
00211         //
00212         // Copy Constructor
00213         //
00214         _Iterator( const _Iterator& i )
00215             throw()
00216             : _iBegin( i._iBegin )
00217             , _iEnd( i._iEnd )
00218             , _iCurrent( i._iCurrent )
00219         {;}
00220 
00221         //
00222         // Assignment
00223         //
00224         _Iterator& operator=( const _Iterator& i )
00225             throw()
00226         {
00227             _iBegin = i._iBegin;
00228             _iEnd = i._iEnd;
00229             _iCurrent = i._iCurrent;
00230 
00231             return *this;
00232         }
00233 
00234         //
00235         // Destructor
00236         //
00237         virtual ~_Iterator()
00238             throw()
00239         {;}
00240 
00241         //
00242         // Reset the iterator back to its initial position
00243         //
00244         void reset()
00245             throw()
00246         {
00247             _iCurrent = _iBegin;
00248         }
00249 
00250         //
00251         // Returns true if the iterator points to a valid element
00252         //
00253         bool valid()
00254             throw()
00255         {
00256             return (_iCurrent != _iEnd);
00257         }
00258 
00259         //
00260         // Move the iterator forward one element
00261         // Returns true if the iterator points to a valid element
00262         //      or false if the end of the iterator has been reached
00263         //
00264         bool next()
00265             throw()
00266         {
00267             if (valid())
00268             {
00269                 _iCurrent++;
00270                 return valid();
00271             }
00272             else
00273             {
00274                 return false;
00275             }
00276         }
00277 
00278         //
00279         // Returns the current element or throws an exception
00280         //  if the end of the iterator has been reached
00281         //
00282         const wchar_t* const& get()
00283             throw( DWFException )
00284         {
00285             if (valid())
00286             {
00287                 return _iCurrent->second;
00288             }
00289             else
00290             {
00291                 _DWFCORE_THROW( DWFDoesNotExistException, L"No more elements" );
00292             }
00293         }
00294 
00295     private:
00296 
00297         _tMultiMap::iterator _iBegin;
00298         _tMultiMap::iterator _iEnd;
00299         _tMultiMap::iterator _iCurrent;
00300     };
00301 
00302 private:
00303 
00304     //
00305     // Unimplemented
00306     //
00307     DWFMIME( const DWFMIME& );
00308     DWFMIME& operator=( const DWFMIME& );
00309 };
00310 
00311 
00312 #ifndef _DWFCORE_DEFINE_FOR_DOXYGEN_ONLY
00313 
00314     //
00315     // required for win32 dll external linkage
00316     //
00317 #ifdef  _DWFCORE_WIN32_SYSTEM
00318 #ifndef DWFCORE_STATIC
00319 
00320 _declspec(selectany) const wchar_t* const DWFMIME::kzMIMEType_DWF1 =     L"model/vnd.dwf";
00321 _declspec(selectany) const wchar_t* const DWFMIME::kzMIMEType_DWF2 =     L"application/x-dwf";
00322 _declspec(selectany) const wchar_t* const DWFMIME::kzMIMEType_DWF3 =     L"drawing/x-dwf";
00323 _declspec(selectany) const wchar_t* const DWFMIME::kzMIMEType_W2D =      L"application/x-w2d";
00324 _declspec(selectany) const wchar_t* const DWFMIME::kzMIMEType_W3D =      L"application/x-w3d";
00325 _declspec(selectany) const wchar_t* const DWFMIME::kzMIMEType_DSD =      L"application/x-dsd";
00326 _declspec(selectany) const wchar_t* const DWFMIME::kzMIMEType_PIA =      L"application/x-dwg-state";
00327 _declspec(selectany) const wchar_t* const DWFMIME::kzMIMEType_PNG =      L"image/png";
00328 _declspec(selectany) const wchar_t* const DWFMIME::kzMIMEType_JPG =      L"image/jpeg";
00329 _declspec(selectany) const wchar_t* const DWFMIME::kzMIMEType_TXT =      L"text/plain";
00330 _declspec(selectany) const wchar_t* const DWFMIME::kzMIMEType_XML =      L"text/xml";
00331 _declspec(selectany) const wchar_t* const DWFMIME::kzMIMEType_FONT =     L"application/x-font";
00332 
00333 _declspec(selectany) const wchar_t* const DWFMIME::kzExtension_DWF =     L"dwf";
00334 _declspec(selectany) const wchar_t* const DWFMIME::kzExtension_W2D =     L"w2d";
00335 _declspec(selectany) const wchar_t* const DWFMIME::kzExtension_W3D =     L"w3d";
00336 _declspec(selectany) const wchar_t* const DWFMIME::kzExtension_DSD =     L"dsd";
00337 _declspec(selectany) const wchar_t* const DWFMIME::kzExtension_PIA =     L"pia";
00338 _declspec(selectany) const wchar_t* const DWFMIME::kzExtension_PNG =     L"png";
00339 _declspec(selectany) const wchar_t* const DWFMIME::kzExtension_JPG =     L"jpg";
00340 _declspec(selectany) const wchar_t* const DWFMIME::kzExtension_TXT =     L"txt";
00341 _declspec(selectany) const wchar_t* const DWFMIME::kzExtension_XML =     L"xml";
00342 _declspec(selectany) const wchar_t* const DWFMIME::kzExtension_FONT =    L"ef_";
00343 
00344 #endif
00345 #endif
00346 #endif
00347 
00348 
00349 }
00350 
00351 #endif

Generated on Tue May 17 12:05:10 2005 for Autodesk DWF Core Library by  doxygen 1.4.1