MrSID Decode SDK for Raster Reference Manual  9.5.1.4427
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 
00059 #ifndef SWIG
00060 
00068    enum EncodingType { NATIVE, UTF8 };
00069    LTFileSpec(const char *p1,
00070               EncodingType encoding = NATIVE);
00071    LTFileSpec(const char *p1, const char *p2,
00072               EncodingType encoding = NATIVE);
00073    LTFileSpec(const char *p1, const char *p2, const char *p3,
00074               EncodingType encoding = NATIVE);
00075 #endif
00076 
00082    explicit LTFileSpec(const wchar_t *p1);
00083    LTFileSpec(const wchar_t *p1, const wchar_t *p2);
00084    LTFileSpec(const wchar_t *p1, const wchar_t *p2, const wchar_t *p3);
00085    
00086 #ifndef LT_OS_WIN
00087 
00091    explicit LTFileSpec(const lt_uint16 *path);
00092    LTFileSpec(const lt_uint16 *p1, const lt_uint16 *p2);
00093    LTFileSpec(const lt_uint16 *p1, const lt_uint16 *p2, const lt_uint16 *p3);
00094 #endif
00095 
00096    LTFileSpec(const LTFileSpec &p1);
00097    LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2);
00098    LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2, const LTFileSpec &p3);
00099 #ifndef SWIG
00100    LTFileSpec(const LTFileSpec &p1, const char *p2,
00101               EncodingType encoding);
00102    LTFileSpec(const LTFileSpec &p1, const char *p2, const char *p3,
00103               EncodingType encoding);
00104    LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2, const char *p3,
00105               EncodingType encoding);
00106 #endif
00107    LTFileSpec(const LTFileSpec &p1, const wchar_t *p2);
00108    LTFileSpec(const LTFileSpec &p1, const wchar_t *p2, const wchar_t *p3);
00109    LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2, const wchar_t *p3);
00110 
00111 #ifndef LT_OS_WIN
00112    LTFileSpec(const LTFileSpec &p1, const lt_uint16 *p2);
00113    LTFileSpec(const LTFileSpec &p1, const lt_uint16 *p2, const lt_uint16 *p3);
00114    LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2, const lt_uint16 *p3);
00115 #endif
00116 
00122    LTFileSpec& operator=(const LTFileSpec &that);
00123 
00127    bool operator!=(const LTFileSpec& fs) const;
00128 
00132    bool operator==(const LTFileSpec& fs) const;
00133 
00134    // is the fileSpec empty
00135    bool empty(void) const;
00136    
00140    const char *utf8(void) const;
00141    
00148    const char *n_str(void) const;
00149    
00156    const wchar_t *w_str(void) const;
00171    LTFileSpec dirname(void) const;
00172    
00187    const char *basename(void) const;
00188    
00197    const char* getSuffix() const;
00198 
00211    LTFileSpec replaceSuffix(const char* ext) const;
00212 
00223    LTFileSpec removeSuffix() const;
00224 
00228    bool absolute() const;
00229 
00230 protected:
00231    
00236    void init(const char *p1, const char *p2, const char *p3);
00237    
00238    size_t getPrefixLength(void) const;
00239 private:
00240    // using a utf8 string to hold the path because it is the easiest
00241    // to play with (we can look for bSlashs and not have to worry 
00242    // about lead btyes.
00243    char *m_path8;
00244    mutable char *m_pathA;     // this will be updated in n_str()
00245    mutable wchar_t *m_pathW;  // this will be updated in w_str()
00246 
00247 };
00248 
00249 LT_END_NAMESPACE(LizardTech)
00250 
00251 #endif // LT_FILESPEC_H