PixelLightAPI  .
FileAccess.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: FileAccess.h                                   *
00003  *
00004  *  Copyright (C) 2002-2012 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_FILEACCESS_H__
00024 #define __PLCORE_FILEACCESS_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include "PLCore/String/String.h"
00032 #include "PLCore/Container/HashMap.h"
00033 
00034 
00035 //[-------------------------------------------------------]
00036 //[ Namespace                                             ]
00037 //[-------------------------------------------------------]
00038 namespace PLCore {
00039 
00040 
00041 //[-------------------------------------------------------]
00042 //[ Classes                                               ]
00043 //[-------------------------------------------------------]
00044 /**
00045 *  @brief
00046 *    This class contains information about how to access a file
00047 *
00048 *  @remarks
00049 *    It can be used to supply authentication for files, e.g. username and password for a HTTP-connection
00050 *    or a password for an encrypted ZIP-file, as well as other access options.
00051 *    Please consider this information as hints that can be passed to the file-functions, it is not guaranteed
00052 *    that everything you enter here will be used! (e.g. a ZIP-file won't be open with Write-Access, regardless
00053 *    of what you pass in FlagsMask/FlagsValue)
00054 */
00055 class FileAccess {
00056 
00057 
00058     //[-------------------------------------------------------]
00059     //[ File access entry                                     ]
00060     //[-------------------------------------------------------]
00061     public:
00062         /**
00063         *  @brief
00064         *    Contains access information for a certain file/URL
00065         */
00066         class Entry {
00067 
00068 
00069             //[-------------------------------------------------------]
00070             //[ Friends                                               ]
00071             //[-------------------------------------------------------]
00072             friend class FileAccess;
00073 
00074 
00075             //[-------------------------------------------------------]
00076             //[ Public functions                                      ]
00077             //[-------------------------------------------------------]
00078             public:
00079                 /**
00080                 *  @brief
00081                 *    Constructor
00082                 */
00083                 PLCORE_API Entry();
00084 
00085                 /**
00086                 *  @brief
00087                 *    Copy constructor
00088                 *
00089                 *  @param[in] cEntry
00090                 *    Entry to copy
00091                 */
00092                 PLCORE_API Entry(const Entry &cEntry);
00093 
00094                 /**
00095                 *  @brief
00096                 *    Destructor
00097                 */
00098                 PLCORE_API ~Entry();
00099 
00100                 /**
00101                 *  @brief
00102                 *    Get ID
00103                 *
00104                 *  @return
00105                 *    Entry ID
00106                 */
00107                 PLCORE_API uint32 GetID() const;
00108 
00109                 /**
00110                 *  @brief
00111                 *    Assignment operator
00112                 *
00113                 *  @param[in] cEntry
00114                 *    Entry to copy
00115                 *
00116                 *  @return
00117                 *    Reference to this instance
00118                 */
00119                 PLCORE_API Entry &operator =(const Entry &cEntry);
00120 
00121                 /**
00122                 *  @brief
00123                 *    Comparison operator
00124                 *
00125                 *  @param[in] cEntry
00126                 *    Entry to compare to
00127                 *
00128                 *  @return
00129                 *    'true' if both entries are equal, else 'false'
00130                 */
00131                 PLCORE_API bool operator ==(const Entry &cEntry) const;
00132 
00133                 /**
00134                 *  @brief
00135                 *    Get username
00136                 *
00137                 *  @return
00138                 *    Username
00139                 */
00140                 PLCORE_API String GetUsername() const;
00141 
00142                 /**
00143                 *  @brief
00144                 *    Set username
00145                 *
00146                 *  @param[in] sUsername
00147                 *    Username
00148                 */
00149                 PLCORE_API void SetUsername(const String &sUsername);
00150 
00151                 /**
00152                 *  @brief
00153                 *    Get password
00154                 *
00155                 *  @return
00156                 *    Password
00157                 */
00158                 PLCORE_API String GetPassword() const;
00159 
00160                 /**
00161                 *  @brief
00162                 *    Set password
00163                 *
00164                 *  @param[in] sPassword
00165                 *    Password
00166                 */
00167                 PLCORE_API void SetPassword(const String &sPassword);
00168 
00169                 /**
00170                 *  @brief
00171                 *    Set username and password
00172                 *
00173                 *  @param[in] sUsername
00174                 *    Username
00175                 *  @param[in] sPassword
00176                 *    Password
00177                 */
00178                 PLCORE_API void SetAuth(const String &sUsername, const String &sPassword);
00179 
00180                 /**
00181                 *  @brief
00182                 *    Get case-sensitive
00183                 *
00184                 *  @return
00185                 *    Case-sensitive-flag
00186                 */
00187                 PLCORE_API bool GetCaseSensitive() const;
00188 
00189                 /**
00190                 *  @brief
00191                 *    Set case-sensitive
00192                 *
00193                 *  @param[in] bCaseSensitive
00194                 *    Case-sensitive-flag
00195                 */
00196                 PLCORE_API void SetCaseSensitive(bool bCaseSensitive);
00197 
00198                 /**
00199                 *  @brief
00200                 *    Get flags mask
00201                 *
00202                 *  @return
00203                 *    Flags mask
00204                 */
00205                 PLCORE_API uint32 GetFlagsMask() const;
00206 
00207                 /**
00208                 *  @brief
00209                 *    Set flags mask
00210                 *
00211                 *  @param[in] nFlagsMask
00212                 *    Flags mask
00213                 */
00214                 PLCORE_API void SetFlagsMask(uint32 nFlagsMask);
00215 
00216                 /**
00217                 *  @brief
00218                 *    Get flags value
00219                 *
00220                 *  @return
00221                 *    Flags value
00222                 */
00223                 PLCORE_API uint32 GetFlagsValue() const;
00224 
00225                 /**
00226                 *  @brief
00227                 *    Set flags value
00228                 *
00229                 *  @param[in] nFlagsValue
00230                 *    Flags value
00231                 */
00232                 PLCORE_API void SetFlagsValue(uint32 nFlagsValue);
00233 
00234                 /**
00235                 *  @brief
00236                 *    Get user flags
00237                 *
00238                 *  @return
00239                 *    User flags
00240                 */
00241                 PLCORE_API uint32 GetUserFlags() const;
00242 
00243                 /**
00244                 *  @brief
00245                 *    Set user flags
00246                 *
00247                 *  @param[in] nUserFlags
00248                 *    User flags
00249                 */
00250                 PLCORE_API void SetUserFlags(uint32 nUserFlags);
00251 
00252                 /**
00253                 *  @brief
00254                 *    Get user data
00255                 *
00256                 *  @return
00257                 *    User data, can be a null pointer
00258                 */
00259                 PLCORE_API void *GetUserData() const;
00260 
00261                 /**
00262                 *  @brief
00263                 *    Set user data
00264                 *
00265                 *  @param[in] pUserData
00266                 *    User data, can be a null pointer
00267                 */
00268                 PLCORE_API void SetUserData(void *pUserData);
00269 
00270                 /**
00271                 *  @brief
00272                 *    Get user info
00273                 *
00274                 *  @return
00275                 *    User info
00276                 */
00277                 PLCORE_API String GetUserInfo() const;
00278 
00279                 /**
00280                 *  @brief
00281                 *    Set user info
00282                 *
00283                 *  @param[in] sUserInfo
00284                 *    User info
00285                 */
00286                 PLCORE_API void SetUserInfo(const String &sUserInfo);
00287 
00288 
00289             //[-------------------------------------------------------]
00290             //[ Private data                                          ]
00291             //[-------------------------------------------------------]
00292             private:
00293                 uint32  m_nID;              /**< Unique entry ID */
00294                 String  m_sUsername;        /**< Username for restricted access */
00295                 String  m_sPassword;        /**< Password for restricted access */
00296                 bool    m_bCaseSensitive;   /**< Case sensitivity */
00297                 uint32  m_nFlagsMask;       /**< Mask of file-flags (see File::EAccess) */
00298                 uint32  m_nFlagsValue;      /**< Values of file-flags (see File::EAccess) */
00299                 uint32  m_nUserFlags;       /**< User defined flags */
00300                 void   *m_pUserData;        /**< User defined data, can be a null pointer */
00301                 String  m_sUserInfo;        /**< USer defined string */
00302 
00303 
00304         };
00305 
00306 
00307     //[-------------------------------------------------------]
00308     //[ Public static data                                    ]
00309     //[-------------------------------------------------------]
00310     public:
00311         static const Entry NullEntry;   /**< Empty entry */
00312 
00313 
00314     //[-------------------------------------------------------]
00315     //[ Public functions                                      ]
00316     //[-------------------------------------------------------]
00317     public:
00318         /**
00319         *  @brief
00320         *    Constructor
00321         */
00322         PLCORE_API FileAccess();
00323 
00324         /**
00325         *  @brief
00326         *    Copy constructor
00327         *
00328         *  @param[in] cFileAccess
00329         *    FileAccess object to copy
00330         */
00331         PLCORE_API FileAccess(const FileAccess &cFileAccess);
00332 
00333         /**
00334         *  @brief
00335         *    Destructor
00336         */
00337         PLCORE_API ~FileAccess();
00338 
00339         /**
00340         *  @brief
00341         *    Assignment operator
00342         *
00343         *  @param[in] cFileAccess
00344         *    'FileAccess' object to copy
00345         *
00346         *  @return
00347         *    Reference to this instance
00348         */
00349         PLCORE_API FileAccess &operator =(const FileAccess &cFileAccess);
00350 
00351         /**
00352         *  @brief
00353         *    Check if an entry with a given name is available
00354         *
00355         *  @param[in] sName
00356         *    Name of the entry
00357         *
00358         *  @return
00359         *    'true' if the entry is set, else 'false'
00360         */
00361         PLCORE_API bool HasEntry(const String &sName) const;
00362 
00363         /**
00364         *  @brief
00365         *    Returns an entry with a given name
00366         *
00367         *  @param[in] sName
00368         *    Name of the entry
00369         *
00370         *  @return
00371         *    Reference to that entry if it exists, else 'NullEntry'
00372         */
00373         PLCORE_API const Entry &GetEntry(const String &sName) const;
00374         PLCORE_API const Entry &operator [](const String &sName) const;
00375 
00376         /**
00377         *  @brief
00378         *    Returns an entry with a given name
00379         *
00380         *  @param[in] sName
00381         *    Name of the entry
00382         *
00383         *  @return
00384         *    Reference to that entry, creates a new entry if it didn't exist before
00385         */
00386         PLCORE_API Entry &GetEntry(const String &sName);
00387         PLCORE_API Entry &operator [](const String &sName);
00388 
00389 
00390     //[-------------------------------------------------------]
00391     //[ Private data                                          ]
00392     //[-------------------------------------------------------]
00393     private:
00394         HashMap<String, Entry>  m_mapEntries;   /**< List of FileAccess entries */
00395         uint32                  m_nNextID;      /**< ID counter for entries */
00396 
00397 
00398 };
00399 
00400 
00401 //[-------------------------------------------------------]
00402 //[ Namespace                                             ]
00403 //[-------------------------------------------------------]
00404 } // PLCore
00405 
00406 
00407 #endif // __PLCORE_FILEACCESS_H__


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:08:53
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported