MrSID Decode SDK for Raster Reference Manual 9.5.5.5244
lt_fileSpec.h
Go to the documentation of this file.
1//
2// This code is property of Celartem, Inc dba Extensis.
3// Copyright (c) 1995-2023. All rights reserved.
4// Use permitted only under license from Extensis.
5//
6
7#ifndef LT_FILESPEC_H
8#define LT_FILESPEC_H
9
10// lt_lib_base
11#include "lt_base.h"
12#include "lt_system.h"
13
14LT_BEGIN_LIZARDTECH_NAMESPACE
18#ifdef LT_OS_WIN
19#define LT_UTIL_MAX_PATH _MAX_PATH
20#else
21#define LT_UTIL_MAX_PATH 2048
22#endif
23
24#if defined(LT_OS_WIN) && !defined(_NATIVE_WCHAR_T_DEFINED) && !defined (SWIG)
25// Work within projects whether using native wchar_t or not ("/Zc:wchar_t-").
26#define WCHAR_INTERNAL __wchar_t
27#else
28#define WCHAR_INTERNAL wchar_t
29#endif
30
35{
36public:
37 enum
38 {
39 fSlash = '/',
40 bSlash = '\\',
41#ifdef LT_OS_WIN
42 platformSlash = '\\'
43#else
44 platformSlash = '/'
45#endif
46 };
47
48
49public:
54
59
60#ifndef SWIG
70 LTFileSpec(const char *p1,
71 EncodingType encoding = NATIVE);
72 LTFileSpec(const char *p1, const char *p2,
73 EncodingType encoding = NATIVE);
74 LTFileSpec(const char *p1, const char *p2, const char *p3,
75 EncodingType encoding = NATIVE);
76#endif
77
83 explicit LTFileSpec(const WCHAR_INTERNAL *p1);
85 LTFileSpec(const WCHAR_INTERNAL *p1, const WCHAR_INTERNAL *p2, const WCHAR_INTERNAL *p3);
86
87#ifndef SWIG
92 explicit LTFileSpec(const lt_uint16 *path);
93 LTFileSpec(const lt_uint16 *p1, const lt_uint16 *p2);
94 LTFileSpec(const lt_uint16 *p1, const lt_uint16 *p2, const lt_uint16 *p3);
95#endif
96
98 LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2);
99 LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2, const LTFileSpec &p3);
100#ifndef SWIG
101 LTFileSpec(const LTFileSpec &p1, const char *p2,
102 EncodingType encoding);
103 LTFileSpec(const LTFileSpec &p1, const char *p2, const char *p3,
104 EncodingType encoding);
105 LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2, const char *p3,
106 EncodingType encoding);
107#endif
108 LTFileSpec(const LTFileSpec &p1, const WCHAR_INTERNAL *p2);
109 LTFileSpec(const LTFileSpec &p1, const WCHAR_INTERNAL *p2, const WCHAR_INTERNAL *p3);
110 LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2, const WCHAR_INTERNAL *p3);
111
112#ifndef SWIG
113 LTFileSpec(const LTFileSpec &p1, const lt_uint16 *p2);
114 LTFileSpec(const LTFileSpec &p1, const lt_uint16 *p2, const lt_uint16 *p3);
115 LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2, const lt_uint16 *p3);
116#endif
117
124
128 bool operator!=(const LTFileSpec& fs) const;
129
133 bool operator==(const LTFileSpec& fs) const;
134
135 bool operator<(const LTFileSpec& fs) const;
136 bool operator<=(const LTFileSpec& fs) const;
137 bool operator>(const LTFileSpec& fs) const;
138 bool operator>=(const LTFileSpec& fs) const;
139
140 // is the fileSpec empty
141 bool empty(void) const;
142
146 const char *utf8(void) const;
147
154 const char *n_str(void) const;
155
162 const WCHAR_INTERNAL *w_str(void) const;
163
178 LTFileSpec dirname(void) const;
179
194 const char *basename(void) const;
195
204 const char* getSuffix() const;
205
218 LTFileSpec replaceSuffix(const char* ext) const;
219
231
235 bool absolute() const;
236
237protected:
238
243 void init(const char *p1, const char *p2, const char *p3);
244
245 size_t getPrefixLength(void) const;
246private:
247 // using a utf8 string to hold the path because it is the easiest
248 // to play with (null and backslash searching, no lead bytes).
249 char *m_path8;
250 mutable char *m_pathA; // this will be updated in n_str()
251 mutable WCHAR_INTERNAL *m_pathW; // this will be updated in w_str()
252
253};
254
255LT_END_LIZARDTECH_NAMESPACE
256
257#undef WCHAR_INTERNAL
258#endif // LT_FILESPEC_H
Include file for all LizardTech sources.
#define WCHAR_INTERNAL
Definition: lt_fileSpec.h:28
Declaration of standard system headers in a C-interface.
unsigned short lt_uint16
unsigned 16-bit integer
Definition: lt_types.h:40
Represents a file or directory path.
Definition: lt_fileSpec.h:35
~LTFileSpec(void)
destructor
size_t getPrefixLength(void) const
bool absolute() const
returns true if path is absolute, false if relative
LTFileSpec(const wchar_t *p1, const wchar_t *p2, const wchar_t *p3)
bool operator>(const LTFileSpec &fs) const
LTFileSpec & operator=(const LTFileSpec &that)
assignment operator
LTFileSpec(const char *p1, EncodingType encoding=NATIVE)
LTFileSpec(const wchar_t *p1)
wchar constructor
LTFileSpec(const lt_uint16 *p1, const lt_uint16 *p2, const lt_uint16 *p3)
LTFileSpec(const LTFileSpec &p1, const char *p2, const char *p3, EncodingType encoding)
const wchar_t * w_str(void) const
Function to convert the path to Wide format.
LTFileSpec(const char *p1, const char *p2, const char *p3, EncodingType encoding=NATIVE)
LTFileSpec(const LTFileSpec &p1, const wchar_t *p2, const wchar_t *p3)
bool operator==(const LTFileSpec &fs) const
equality operator
bool operator!=(const LTFileSpec &fs) const
inequality operator
LTFileSpec(const lt_uint16 *p1, const lt_uint16 *p2)
LTFileSpec(const LTFileSpec &p1, const char *p2, EncodingType encoding)
bool operator>=(const LTFileSpec &fs) const
LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2, const char *p3, EncodingType encoding)
bool operator<(const LTFileSpec &fs) const
LTFileSpec replaceSuffix(const char *ext) const
replaces suffix (extension)
LTFileSpec(void)
default constructor
LTFileSpec removeSuffix() const
remove the suffix (extension)
const char * utf8(void) const
Function to convert the path to a UTF8 format.
void init(const char *p1, const char *p2, const char *p3)
Initialization from UTF8 strings.
LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2, const wchar_t *p3)
LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2, const LTFileSpec &p3)
LTFileSpec(const wchar_t *p1, const wchar_t *p2)
LTFileSpec(const lt_uint16 *path)
UTF16 constructor.
LTFileSpec(const char *p1, const char *p2, EncodingType encoding=NATIVE)
LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2, const lt_uint16 *p3)
LTFileSpec(const LTFileSpec &p1)
const char * n_str(void) const
Function to convert the path to native format.
EncodingType
native constructor
Definition: lt_fileSpec.h:69
LTFileSpec(const LTFileSpec &p1, const lt_uint16 *p2, const lt_uint16 *p3)
const char * basename(void) const
Return the base filename.
LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2)
LTFileSpec(const LTFileSpec &p1, const wchar_t *p2)
LTFileSpec(const LTFileSpec &p1, const lt_uint16 *p2)
LTFileSpec dirname(void) const
Return the parent directory.
bool empty(void) const
const char * getSuffix() const
returns suffix (in utf8)
bool operator<=(const LTFileSpec &fs) const

Extensis