PixelLightAPI  .
FileSearch.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: FileSearch.h                                   *
00003  *
00004  *  Copyright (C) 2002-2011 The PixelLight Team (http://www.pixellight.org/)
00005  *
00006  *  This file is part of PixelLight.
00007  *
00008  *  PixelLight is free software: you can redistribute it and/or modify
00009  *  it under the terms of the GNU Lesser General Public License as published by
00010  *  the Free Software Foundation, either version 3 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  PixelLight is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  *  GNU Lesser General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU Lesser General Public License
00019  *  along with PixelLight. If not, see <http://www.gnu.org/licenses/>.
00020 \*********************************************************/
00021 
00022 
00023 #ifndef __PLCORE_FILESEARCH_H__
00024 #define __PLCORE_FILESEARCH_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include "PLCore/String/String.h"
00032 
00033 
00034 //[-------------------------------------------------------]
00035 //[ Namespace                                             ]
00036 //[-------------------------------------------------------]
00037 namespace PLCore {
00038 
00039 
00040 //[-------------------------------------------------------]
00041 //[ Forward declarations                                  ]
00042 //[-------------------------------------------------------]
00043 class Directory;
00044 class FileSearchImpl;
00045 class SearchFilter;
00046 class SearchFilterWildcard;
00047 
00048 
00049 //[-------------------------------------------------------]
00050 //[ Classes                                               ]
00051 //[-------------------------------------------------------]
00052 /**
00053 *  @brief
00054 *    Class for searching inside a directory
00055 *
00056 *  @note
00057 *    - Implementation of the bridge design pattern, this class is the abstraction
00058 */
00059 class FileSearch {
00060 
00061 
00062     //[-------------------------------------------------------]
00063     //[ Public functions                                      ]
00064     //[-------------------------------------------------------]
00065     public:
00066         /**
00067         *  @brief
00068         *    Constructor
00069         *
00070         *  @param[in] cDirectory
00071         *    Directory to search in
00072         *  @param[in] pFilter
00073         *    Search filter to use (can be a null pointer)
00074         */
00075         PLCORE_API FileSearch(const Directory &cDirectory, SearchFilter *pFilter = nullptr);
00076 
00077         /**
00078         *  @brief
00079         *    Constructor
00080         *
00081         *  @param[in] cDirectory
00082         *    Directory to search in
00083         *  @param[in] sFilter
00084         *    Wildcard search filter (e.g. "*.txt")
00085         */
00086         PLCORE_API FileSearch(const Directory &cDirectory, const String &sFilter);
00087 
00088         /**
00089         *  @brief
00090         *    Copy constructor
00091         *
00092         *  @param[in] cFileSearch
00093         *    'FileSearch' to be copied
00094         */
00095         PLCORE_API FileSearch(const FileSearch &cFileSearch);
00096 
00097         /**
00098         *  @brief
00099         *    Destructor
00100         */
00101         PLCORE_API ~FileSearch();
00102 
00103         /**
00104         *  @brief
00105         *    Copy operator
00106         *
00107         *  @param[in] cFileSearch
00108         *    'FileSearch' to be copied
00109         *
00110         *  @return
00111         *    Reference to this instance
00112         */
00113         PLCORE_API FileSearch &operator =(const FileSearch &cFileSearch);
00114 
00115         /**
00116         *  @brief
00117         *    Returns whether the file searcher has a next file
00118         *
00119         *  @return
00120         *    'true' if the file searcher has a next file, else 'false'
00121         */
00122         inline bool HasNextFile();
00123 
00124         /**
00125         *  @brief
00126         *    Returns the next filename
00127         *
00128         *  @return
00129         *    The next filename, empty on error
00130         */
00131         inline String GetNextFile();
00132 
00133 
00134     //[-------------------------------------------------------]
00135     //[ Private functions                                     ]
00136     //[-------------------------------------------------------]
00137     private:
00138         /**
00139         *  @brief
00140         *    Finds the next file (according to the filter)
00141         *
00142         *  @return
00143         *    'true' if a next file is available
00144         */
00145         PLCORE_API bool FindNextFile();
00146 
00147 
00148     //[-------------------------------------------------------]
00149     //[ Private data                                          ]
00150     //[-------------------------------------------------------]
00151     private:
00152         const Directory      *m_pDirectory;         /**< The owning directory (always valid!) */
00153         FileSearchImpl       *m_pFileSearchImpl;    /**< File searcher implementation, can be a null pointer */
00154         SearchFilterWildcard *m_pFilterWildcard;    /**< Automatically created wildcard filter, can be a null pointer */
00155         SearchFilter         *m_pFilter;            /**< Search filter, can be a null pointer */
00156         String                m_sNextFilename;      /**< Filename of next file */
00157 
00158 
00159 };
00160 
00161 
00162 //[-------------------------------------------------------]
00163 //[ Namespace                                             ]
00164 //[-------------------------------------------------------]
00165 } // PLCore
00166 
00167 
00168 //[-------------------------------------------------------]
00169 //[ Implementation                                        ]
00170 //[-------------------------------------------------------]
00171 #include "PLCore/File/FileSearch.inl"
00172 
00173 
00174 #endif // __PLCORE_FILESEARCH_H__


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:50:53
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported