Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

SchemaCache.h

Go to the documentation of this file.
00001 //
00002 // SchemaCache.h
00003 //
00004 // Copyright (c) Shareaza Development Team, 2002-2005.
00005 // This file is part of SHAREAZA (www.shareaza.com)
00006 //
00007 // Shareaza is free software; you can redistribute it
00008 // and/or modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2 of
00010 // the License, or (at your option) any later version.
00011 //
00012 // Shareaza is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with Shareaza; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 //
00021 
00022 #if !defined(AFX_SCHEMACACHE_H__45A0432F_B5D1_4196_BCDC_BC0AF9B2296A__INCLUDED_)
00023 #define AFX_SCHEMACACHE_H__45A0432F_B5D1_4196_BCDC_BC0AF9B2296A__INCLUDED_
00024 
00025 #pragma once
00026 
00027 class CSchema;
00028 
00029 
00030 class CSchemaCache
00031 {
00032 // Construction
00033 public:
00034         CSchemaCache();
00035         virtual ~CSchemaCache();
00036 
00037 // Attributes
00038 protected:
00039         CMapStringToPtr m_pURIs;
00040         CMapStringToPtr m_pNames;
00041 
00042 // Operations
00043 public:
00044         BOOL            Load();
00045         void            Clear();
00046 
00047 // Inlines
00048 public:
00049         POSITION GetIterator() const
00050         {
00051                 return m_pURIs.GetStartPosition();
00052         }
00053         
00054         CSchema* GetNext(POSITION& pos) const
00055         {
00056                 CSchema* pSchema = NULL;
00057                 CString strURI;
00058                 m_pURIs.GetNextAssoc( pos, strURI, (void*&)pSchema );
00059                 return pSchema;
00060         }
00061         
00062         CSchema* Get(LPCTSTR pszURI) const
00063         {
00064                 if ( ! pszURI || ! *pszURI ) return NULL;
00065                 CString strURI( pszURI );
00066                 CharLower( strURI.GetBuffer() );
00067                 strURI.ReleaseBuffer();
00068                 CSchema* pSchema = NULL;
00069                 return ( m_pURIs.Lookup( strURI, (void*&)pSchema ) ) ? pSchema : NULL;
00070         }
00071         
00072         CSchema* Guess(LPCTSTR pszName) const
00073         {
00074                 if ( ! pszName || ! *pszName ) return NULL;
00075                 CString strName( pszName );
00076                 CharLower( strName.GetBuffer() );
00077                 strName.ReleaseBuffer();
00078                 CSchema* pSchema = NULL;
00079                 return m_pNames.Lookup( strName, (void*&)pSchema ) ? pSchema : NULL;
00080         }
00081 
00082 };
00083 
00084 extern CSchemaCache     SchemaCache;
00085 
00086 #endif // !defined(AFX_SCHEMACACHE_H__45A0432F_B5D1_4196_BCDC_BC0AF9B2296A__INCLUDED_)

Generated on Thu Dec 15 10:39:47 2005 for Shareaza 2.2.1.0 by  doxygen 1.4.2