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

Schema.h

Go to the documentation of this file.
00001 //
00002 // Schema.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_SCHEMA_H__D6D5E129_7D37_4FBB_BBEA_320E4659D76D__INCLUDED_)
00023 #define AFX_SCHEMA_H__D6D5E129_7D37_4FBB_BBEA_320E4659D76D__INCLUDED_
00024 
00025 #pragma once
00026 
00027 #include "SchemaMember.h"
00028 
00029 class CSchema;
00030 class CSchemaMember;
00031 class CSchemaChild;
00032 class CXMLElement;
00033 
00034 
00035 class CSchema  
00036 {
00037 // Construction
00038 public:
00039         CSchema();
00040         virtual ~CSchema();
00041         
00042 // Attributes
00043 public:
00044         int                     m_nType;
00045         CString         m_sTitle;
00046         CString         m_sURI;
00047         CString         m_sPlural;
00048         CString         m_sSingular;
00049         int                     m_nAvailability;
00050         BOOL            m_bPrivate;
00051         CString         m_sDonkeyType;
00052 public:
00053         CPtrList        m_pMembers;
00054         CStringList     m_pExtends;
00055         CPtrList        m_pContains;
00056         CString         m_sDefaultColumns;
00057         CString         m_sTypeFilter;
00058         CPtrList        m_pBitziMap;
00059         CString         m_sBitziTest;
00060         CString         m_sLibraryView;
00061         CString         m_sHeaderTitle;
00062         CString         m_sHeaderSubtitle;
00063         CString         m_sTileLine1;
00064         CString         m_sTileLine2;
00065 public:
00066         CString         m_sIcon;
00067         int                     m_nIcon16;
00068         int                     m_nIcon32;
00069         int                     m_nIcon48;
00070         
00071         enum { stFile, stFolder };
00072         enum { saDefault, saAdvanced, saSystem, saMax };
00073         
00074 // Operations
00075 public:
00076         POSITION                GetMemberIterator() const;
00077         CSchemaMember*  GetNextMember(POSITION& pos) const;
00078         CSchemaMember*  GetMember(LPCTSTR pszName) const;
00079         int                             GetMemberCount() const;
00080         CString                 GetFirstMemberName() const;
00081         void                    Clear();
00082         BOOL                    Load(LPCTSTR pszName);
00083         CSchemaChild*   GetContained(LPCTSTR pszURI) const;
00084         CString                 GetContainedURI(int nType) const;
00085         CXMLElement*    Instantiate(BOOL bNamespace = FALSE) const;
00086         BOOL                    Validate(CXMLElement* pXML, BOOL bFix);
00087         CString                 GetIndexedWords(CXMLElement* pXML) const;
00088         void                    ResolveTokens(CString& str, CXMLElement* pXML) const;
00089 protected:
00090         BOOL                    LoadSchema(LPCTSTR pszFile);
00091         BOOL                    LoadPrimary(CXMLElement* pRoot, CXMLElement* pType);
00092         CXMLElement*    GetType(CXMLElement* pRoot, LPCTSTR pszName);
00093         BOOL                    LoadDescriptor(LPCTSTR pszFile);
00094         void                    LoadDescriptorTitles(CXMLElement* pElement);
00095         void                    LoadDescriptorIcons(CXMLElement* pElement);
00096         void                    LoadDescriptorMembers(CXMLElement* pElement);
00097         void                    LoadDescriptorTypeFilter(CXMLElement* pElement);
00098         void                    LoadDescriptorExtends(CXMLElement* pElement);
00099         void                    LoadDescriptorContains(CXMLElement* pElement);
00100         void                    LoadDescriptorBitziImport(CXMLElement* pElement);
00101         void                    LoadDescriptorHeaderContent(CXMLElement* pElement);
00102         void                    LoadDescriptorViewContent(CXMLElement* pElement);
00103         BOOL                    LoadIcon();
00104 
00105 // Inlines
00106 public:
00107         inline BOOL Equals(CSchema* pSchema) const
00108         {
00109                 if ( ! pSchema ) return FALSE;
00110                 if ( this == pSchema ) return TRUE;
00111                 
00112                 for ( POSITION pos = m_pExtends.GetHeadPosition() ; pos ; )
00113                 {
00114                         CString strURI = m_pExtends.GetNext( pos );
00115                         if ( strURI.CompareNoCase( pSchema->m_sURI ) == 0 ) return TRUE;
00116                 }
00117                 
00118                 return FALSE;
00119         }
00120 
00121         inline BOOL CheckURI(LPCTSTR pszURI) const
00122         {
00123                 if ( ! pszURI || ! this ) return FALSE;
00124                 if ( m_sURI.CompareNoCase( pszURI ) == 0 ) return TRUE;
00125                 
00126                 for ( POSITION pos = m_pExtends.GetHeadPosition() ; pos ; )
00127                 {
00128                         CString strURI = m_pExtends.GetNext( pos );
00129                         if ( strURI.CompareNoCase( pszURI ) == 0 ) return TRUE;
00130                 }
00131                 
00132                 return FALSE;
00133         }
00134 
00135         inline BOOL FilterType(LPCTSTR pszFile, BOOL bDefault = FALSE) const
00136         {
00137                 if ( m_sTypeFilter.IsEmpty() ) return bDefault;
00138 
00139                 LPCTSTR pszExt = _tcsrchr( pszFile, '.' );
00140                 if ( pszExt == NULL ) return FALSE;
00141 
00142                 CString strExt = _T("|");
00143                 strExt += pszExt;
00144                 strExt += '|';
00145                 CharLower( strExt.GetBuffer() );
00146                 strExt.ReleaseBuffer();
00147 
00148                 return m_sTypeFilter.Find( strExt ) >= 0;
00149         }
00150 
00151 
00152 // Common Schemas
00153 public:
00154         static LPCTSTR  uriApplication;
00155         static LPCTSTR  uriAudio;
00156         static LPCTSTR  uriBook;
00157         static LPCTSTR  uriImage;
00158         static LPCTSTR  uriVideo;
00159         static LPCTSTR  uriROM;
00160         static LPCTSTR  uriDocument;
00161         static LPCTSTR  uriSpreadsheet;
00162         static LPCTSTR  uriPresentation;
00163 public:
00164         static LPCTSTR  uriLibrary;
00165         static LPCTSTR  uriFolder;
00166         static LPCTSTR  uriCollectionsFolder;
00167         static LPCTSTR  uriFavouritesFolder;
00168         static LPCTSTR  uriSearchFolder;
00169         static LPCTSTR  uriAllFiles;
00170         static LPCTSTR  uriApplicationRoot;
00171         static LPCTSTR  uriApplicationAll;
00172         static LPCTSTR  uriBookRoot;
00173         static LPCTSTR  uriBookAll;
00174         static LPCTSTR  uriImageRoot;
00175         static LPCTSTR  uriImageAll;
00176         static LPCTSTR  uriImageAlbum;
00177         static LPCTSTR  uriMusicRoot;
00178         static LPCTSTR  uriMusicAll;
00179         static LPCTSTR  uriMusicAlbumCollection;
00180         static LPCTSTR  uriMusicArtistCollection;
00181         static LPCTSTR  uriMusicGenreCollection;
00182         static LPCTSTR  uriMusicAlbum;
00183         static LPCTSTR  uriMusicArtist;
00184         static LPCTSTR  uriMusicGenre;
00185         static LPCTSTR  uriVideoRoot;
00186         static LPCTSTR  uriVideoAll;
00187         static LPCTSTR  uriVideoSeriesCollection;
00188         static LPCTSTR  uriVideoSeries;
00189         static LPCTSTR  uriVideoFilmCollection;
00190         static LPCTSTR  uriVideoFilm;
00191         static LPCTSTR  uriVideoMusicCollection;
00192         static LPCTSTR  uriDocumentRoot;
00193         static LPCTSTR  uriDocumentAll;
00194         
00195         friend class CSchemaMember;
00196 };
00197 
00198 
00199 class CSchemaBitzi
00200 {
00201 public:
00202         CString         m_sFrom;
00203         CString         m_sTo;
00204         double          m_nFactor;
00205 public:
00206         BOOL            Load(CXMLElement* pXML);
00207 };
00208 
00209 #endif // !defined(AFX_SCHEMA_H__D6D5E129_7D37_4FBB_BBEA_320E4659D76D__INCLUDED_)

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