MrSID Decode SDK for Raster Reference Manual  9.0.0.3864
lt_fileSpec.h
Go to the documentation of this file.
00001 /* $Id$ */
00002 /* //////////////////////////////////////////////////////////////////////////
00003 //                                                                         //
00004 // This code is Copyright (c) 2004 LizardTech, Inc, 1008 Western Avenue,   //
00005 // Suite 200, Seattle, WA 98104.  Unauthorized use or distribution         //
00006 // prohibited.  Access to and use of this code is permitted only under     //
00007 // license from LizardTech, Inc.  Portions of the code are protected by    //
00008 // US and foreign patents and other filings. All Rights Reserved.          //
00009 //                                                                         //
00011 /* PUBLIC */
00012 
00013 #ifndef LT_FILESPEC_H
00014 #define LT_FILESPEC_H
00015 
00016 // lt_lib_base
00017 #include "lt_base.h"
00018 #include "lt_system.h"
00019 
00020 LT_BEGIN_NAMESPACE(LizardTech)
00024 #ifdef LT_OS_WIN
00025 #define LT_UTIL_MAX_PATH _MAX_PATH
00026 #else
00027 #define LT_UTIL_MAX_PATH 2048
00028 #endif
00029 
00033 class LTFileSpec
00034 {
00035 public:
00036    enum
00037    {
00038       fSlash = '/',
00039       bSlash = '\\',
00040 #ifdef LT_OS_WIN
00041       platformSlash = '\\'
00042 #else
00043       platformSlash = '/'
00044 #endif
00045    };
00046 
00047 
00048 public:
00052    LTFileSpec(void);
00053 
00057    ~LTFileSpec(void);
00058 
00067    enum EncodingType { NATIVE, UTF8 };
00068    LTFileSpec(const char *p1,
00069               EncodingType encoding = NATIVE);
00070    LTFileSpec(const char *p1, const char *p2,
00071               EncodingType encoding = NATIVE);
00072    LTFileSpec(const char *p1, const char *p2, const char *p3,
00073               EncodingType encoding = NATIVE);
00074 
00075    
00081    explicit LTFileSpec(const wchar_t *p1);
00082    LTFileSpec(const wchar_t *p1, const wchar_t *p2);
00083    LTFileSpec(const wchar_t *p1, const wchar_t *p2, const wchar_t *p3);
00084    
00085 #ifndef LT_OS_WIN
00086 
00090    explicit LTFileSpec(const lt_uint16 *path);
00091    LTFileSpec(const lt_uint16 *p1, const lt_uint16 *p2);
00092    LTFileSpec(const lt_uint16 *p1, const lt_uint16 *p2, const lt_uint16 *p3);
00093 #endif
00094 
00095    LTFileSpec(const LTFileSpec &p1);
00096    LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2);
00097    LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2, const LTFileSpec &p3);
00098 
00099    LTFileSpec(const LTFileSpec &p1, const char *p2,
00100               EncodingType encoding);
00101    LTFileSpec(const LTFileSpec &p1, const char *p2, const char *p3,
00102               EncodingType encoding);
00103    LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2, const char *p3,
00104               EncodingType encoding);
00105 
00106    LTFileSpec(const LTFileSpec &p1, const wchar_t *p2);
00107    LTFileSpec(const LTFileSpec &p1, const wchar_t *p2, const wchar_t *p3);
00108    LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2, const wchar_t *p3);
00109 
00110 #ifndef LT_OS_WIN
00111    LTFileSpec(const LTFileSpec &p1, const lt_uint16 *p2);
00112    LTFileSpec(const LTFileSpec &p1, const lt_uint16 *p2, const lt_uint16 *p3);
00113    LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2, const lt_uint16 *p3);
00114 #endif
00115 
00121    LTFileSpec& operator=(const LTFileSpec &that);
00122 
00126    bool operator!=(const LTFileSpec& fs) const;
00127 
00131    bool operator==(const LTFileSpec& fs) const;
00132 
00133    // is the fileSpec empty
00134    bool empty(void) const;
00135    
00139    const char *utf8(void) const;
00140    
00147    const char *n_str(void) const;
00148    
00155    const wchar_t *w_str(void) const;
00170    LTFileSpec dirname(void) const;
00171    
00186    const char *basename(void) const;
00187    
00196    const char* getSuffix() const;
00197 
00210    LTFileSpec replaceSuffix(const char* ext) const;
00211 
00222    LTFileSpec removeSuffix() const;
00223 
00227    bool absolute() const;
00228 
00229 protected:
00230    
00235    void init(const char *p1, const char *p2, const char *p3);
00236    
00237    size_t getPrefixLength(void) const;
00238 private:
00239    // using a utf8 string to hold the path because it is the easiest
00240    // to play with (we can look for bSlashs and not have to worry 
00241    // about lead btyes.
00242    char *m_path8;
00243    mutable char *m_pathA;     // this will be updated in n_str()
00244    mutable wchar_t *m_pathW;  // this will be updated in w_str()
00245 
00246 };
00247 
00248 LT_END_NAMESPACE(LizardTech)
00249 
00250 #endif // LT_FILESPEC_H