GDAL

cpl_conv.h
Go to the documentation of this file.
1/******************************************************************************
2 * $Id$
3 *
4 * Project: CPL - Common Portability Library
5 * Purpose: Convenience functions declarations.
6 * This is intended to remain light weight.
7 * Author: Frank Warmerdam, warmerdam@pobox.com
8 *
9 ******************************************************************************
10 * Copyright (c) 1998, Frank Warmerdam
11 * Copyright (c) 2007-2013, Even Rouault <even dot rouault at spatialys.com>
12 *
13 * SPDX-License-Identifier: MIT
14 ****************************************************************************/
15
16#ifndef CPL_CONV_H_INCLUDED
17#define CPL_CONV_H_INCLUDED
18
19#include "cpl_port.h"
20#include "cpl_vsi.h"
21#include "cpl_error.h"
22
30/* -------------------------------------------------------------------- */
31/* Runtime check of various configuration items. */
32/* -------------------------------------------------------------------- */
33 CPL_C_START
34
36 void CPL_DLL CPLVerifyConfiguration(void);
39 const char CPL_DLL *CPL_STDCALL CPLGetConfigOption(const char *, const char *)
40 CPL_WARN_UNUSED_RESULT;
41 const char CPL_DLL *CPL_STDCALL CPLGetThreadLocalConfigOption(
42 const char *, const char *) CPL_WARN_UNUSED_RESULT;
43 const char CPL_DLL *CPL_STDCALL
44 CPLGetGlobalConfigOption(const char *, const char *) CPL_WARN_UNUSED_RESULT;
45 void CPL_DLL CPL_STDCALL CPLSetConfigOption(const char *, const char *);
46 void CPL_DLL CPL_STDCALL CPLSetThreadLocalConfigOption(const char *pszKey,
47 const char *pszValue);
48
50 typedef void (*CPLSetConfigOptionSubscriber)(const char *pszKey,
51 const char *pszValue,
52 bool bThreadLocal,
53 void *pUserData);
54 int CPL_DLL CPLSubscribeToSetConfigOption(
55 CPLSetConfigOptionSubscriber pfnCallback, void *pUserData);
56 void CPL_DLL CPLUnsubscribeToSetConfigOption(int nSubscriberId);
57
59 void CPL_DLL CPL_STDCALL CPLFreeConfig(void);
61 char CPL_DLL **CPLGetConfigOptions(void);
62 void CPL_DLL CPLSetConfigOptions(const char *const *papszConfigOptions);
63 char CPL_DLL **CPLGetThreadLocalConfigOptions(void);
64 void CPL_DLL
65 CPLSetThreadLocalConfigOptions(const char *const *papszConfigOptions);
66 void CPL_DLL CPLLoadConfigOptionsFromFile(const char *pszFilename,
67 int bOverrideEnvVars);
68 void CPL_DLL CPLLoadConfigOptionsFromPredefinedFiles(void);
69
70/* -------------------------------------------------------------------- */
71/* Safe malloc() API. Thin cover over VSI functions with fatal */
72/* error reporting if memory allocation fails. */
73/* -------------------------------------------------------------------- */
74 void CPL_DLL *CPLMalloc(size_t) CPL_WARN_UNUSED_RESULT;
75 void CPL_DLL *CPLCalloc(size_t, size_t) CPL_WARN_UNUSED_RESULT;
76 void CPL_DLL *CPLRealloc(void *, size_t) CPL_WARN_UNUSED_RESULT;
77 char CPL_DLL *
78 CPLStrdup(const char *) CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL;
79 char CPL_DLL *CPLStrlwr(char *);
80
82#define CPLFree VSIFree
83
84/* -------------------------------------------------------------------- */
85/* Read a line from a text file, and strip of CR/LF. */
86/* -------------------------------------------------------------------- */
87 char CPL_DLL *CPLFGets(char *, int, FILE *);
88 const char CPL_DLL *CPLReadLine(FILE *);
89 const char CPL_DLL *CPLReadLineL(VSILFILE *);
90 const char CPL_DLL *CPLReadLine2L(VSILFILE *, int, CSLConstList);
91 const char CPL_DLL *CPLReadLine3L(VSILFILE *, int, int *, CSLConstList);
92
93/* -------------------------------------------------------------------- */
94/* Convert ASCII string to floating point number */
95/* (THESE FUNCTIONS ARE NOT LOCALE AWARE!). */
96/* -------------------------------------------------------------------- */
97 double CPL_DLL CPLAtof(const char *);
98 double CPL_DLL CPLAtofDelim(const char *, char);
99 double CPL_DLL CPLStrtod(const char *, char **);
100 double CPL_DLL CPLStrtodM(const char *, char **);
101 double CPL_DLL CPLStrtodDelim(const char *, char **, char);
102 float CPL_DLL CPLStrtof(const char *, char **);
103 float CPL_DLL CPLStrtofDelim(const char *, char **, char);
104
105/* -------------------------------------------------------------------- */
106/* Convert number to string. This function is locale agnostic */
107/* (i.e. it will support "," or "." regardless of current locale) */
108/* -------------------------------------------------------------------- */
109 double CPL_DLL CPLAtofM(const char *);
110
111/* -------------------------------------------------------------------- */
112/* Read a numeric value from an ASCII character string. */
113/* -------------------------------------------------------------------- */
114 char CPL_DLL *CPLScanString(const char *, int, int, int);
115 double CPL_DLL CPLScanDouble(const char *, int);
116 long CPL_DLL CPLScanLong(const char *, int);
117 unsigned long CPL_DLL CPLScanULong(const char *, int);
118 GUIntBig CPL_DLL CPLScanUIntBig(const char *, int);
119 GIntBig CPL_DLL CPLAtoGIntBig(const char *pszString);
120 GIntBig CPL_DLL CPLAtoGIntBigEx(const char *pszString, int bWarn,
121 int *pbOverflow);
122 void CPL_DLL *CPLScanPointer(const char *, int);
123
124/* -------------------------------------------------------------------- */
125/* Print a value to an ASCII character string. */
126/* -------------------------------------------------------------------- */
127 int CPL_DLL CPLPrintString(char *, const char *, int);
128 int CPL_DLL CPLPrintStringFill(char *, const char *, int);
129 int CPL_DLL CPLPrintInt32(char *, GInt32, int);
130 int CPL_DLL CPLPrintUIntBig(char *, GUIntBig, int);
131 int CPL_DLL CPLPrintDouble(char *, const char *, double, const char *);
132 int CPL_DLL CPLPrintTime(char *, int, const char *, const struct tm *,
133 const char *);
134 int CPL_DLL CPLPrintPointer(char *, void *, int);
135
136/* -------------------------------------------------------------------- */
137/* Fetch a function from DLL / so. */
138/* -------------------------------------------------------------------- */
139
140 void CPL_DLL *CPLGetSymbol(const char *, const char *);
141
142/* -------------------------------------------------------------------- */
143/* Fetch executable path. */
144/* -------------------------------------------------------------------- */
145 int CPL_DLL CPLGetExecPath(char *pszPathBuf, int nMaxLength);
146
147/* -------------------------------------------------------------------- */
148/* Filename handling functions. */
149/* -------------------------------------------------------------------- */
150 const char CPL_DLL *
151 CPLGetPath(const char *) CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL;
152 const char CPL_DLL *
153 CPLGetDirname(const char *) CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL;
154 const char CPL_DLL *
155 CPLGetFilename(const char *) CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL;
156 const char CPL_DLL *
157 CPLGetBasename(const char *) CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL;
158 const char CPL_DLL *
159 CPLGetExtension(const char *) CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL;
160 char CPL_DLL *CPLGetCurrentDir(void);
161 const char CPL_DLL *CPLFormFilename(
162 const char *pszPath, const char *pszBasename,
163 const char *pszExtension) CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL;
164 const char CPL_DLL *CPLFormCIFilename(
165 const char *pszPath, const char *pszBasename,
166 const char *pszExtension) CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL;
167 const char CPL_DLL *CPLResetExtension(const char *, const char *)
168 CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL;
169 const char CPL_DLL *CPLProjectRelativeFilename(const char *pszProjectDir,
170 const char *pszSecondaryFilename)
171 CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL;
172 int CPL_DLL CPLIsFilenameRelative(const char *pszFilename);
173 const char CPL_DLL *CPLExtractRelativePath(const char *, const char *, int *)
174 CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL;
175 const char CPL_DLL *
176 CPLCleanTrailingSlash(const char *) CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL;
177 char CPL_DLL **
178 CPLCorrespondingPaths(const char *pszOldFilename, const char *pszNewFilename,
179 char **papszFileList) CPL_WARN_UNUSED_RESULT;
180 int CPL_DLL CPLCheckForFile(char *pszFilename, char **papszSiblingList);
181
182 const char CPL_DLL *CPLGenerateTempFilename(const char *pszStem)
183 CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL;
184 const char CPL_DLL *CPLExpandTilde(const char *pszFilename)
185 CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL;
186 const char CPL_DLL *CPLGetHomeDir(void) CPL_WARN_UNUSED_RESULT;
187 const char CPL_DLL *
188 CPLLaunderForFilename(const char *pszName,
189 const char *pszOutputPath) CPL_WARN_UNUSED_RESULT;
190
191/* -------------------------------------------------------------------- */
192/* Find File Function */
193/* -------------------------------------------------------------------- */
194
196 typedef char const *(*CPLFileFinder)(const char *, const char *);
197
198 const char CPL_DLL *CPLFindFile(const char *pszClass, const char *pszBasename);
199 const char CPL_DLL *CPLDefaultFindFile(const char *pszClass,
200 const char *pszBasename);
201 void CPL_DLL CPLPushFileFinder(CPLFileFinder pfnFinder);
202 CPLFileFinder CPL_DLL CPLPopFileFinder(void);
203 void CPL_DLL CPLPushFinderLocation(const char *);
204 void CPL_DLL CPLPopFinderLocation(void);
205 void CPL_DLL CPLFinderClean(void);
206
207/* -------------------------------------------------------------------- */
208/* Safe version of stat() that works properly on stuff like "C:". */
209/* -------------------------------------------------------------------- */
210 int CPL_DLL CPLStat(const char *, VSIStatBuf *) CPL_WARN_UNUSED_RESULT;
211
212/* -------------------------------------------------------------------- */
213/* Reference counted file handle manager. Makes sharing file */
214/* handles more practical. */
215/* -------------------------------------------------------------------- */
216
218 typedef struct
219{
220 FILE *fp;
221 int nRefCount;
222 int bLarge;
223 char *pszFilename;
224 char *pszAccess;
225} CPLSharedFileInfo;
226
227FILE CPL_DLL *CPLOpenShared(const char *, const char *, int);
228 void CPL_DLL CPLCloseShared(FILE *);
229 CPLSharedFileInfo CPL_DLL *CPLGetSharedList(int *);
230 void CPL_DLL CPLDumpSharedList(FILE *);
232 void CPL_DLL CPLCleanupSharedFileMutex(void);
235/* -------------------------------------------------------------------- */
236/* DMS to Dec to DMS conversion. */
237/* -------------------------------------------------------------------- */
238 double CPL_DLL CPLDMSToDec(const char *is);
239 const char CPL_DLL *CPLDecToDMS(double dfAngle, const char *pszAxis,
240 int nPrecision);
241 double CPL_DLL CPLPackedDMSToDec(double);
242 double CPL_DLL CPLDecToPackedDMS(double dfDec);
243
244 void CPL_DLL CPLStringToComplex(const char *pszString, double *pdfReal,
245 double *pdfImag);
246
247/* -------------------------------------------------------------------- */
248/* Misc other functions. */
249/* -------------------------------------------------------------------- */
250 int CPL_DLL CPLUnlinkTree(const char *);
251 int CPL_DLL CPLCopyFile(const char *pszNewPath, const char *pszOldPath);
252 int CPL_DLL CPLCopyTree(const char *pszNewPath, const char *pszOldPath);
253 int CPL_DLL CPLMoveFile(const char *pszNewPath, const char *pszOldPath);
254 int CPL_DLL CPLSymlink(const char *pszOldPath, const char *pszNewPath,
255 CSLConstList papszOptions);
256
257/* -------------------------------------------------------------------- */
258/* ZIP Creation. */
259/* -------------------------------------------------------------------- */
260
262#define CPL_ZIP_API_OFFERED
264 void CPL_DLL *CPLCreateZip(const char *pszZipFilename, char **papszOptions);
265 CPLErr CPL_DLL CPLCreateFileInZip(void *hZip, const char *pszFilename,
266 char **papszOptions);
267 CPLErr CPL_DLL CPLWriteFileInZip(void *hZip, const void *pBuffer,
268 int nBufferSize);
269 CPLErr CPL_DLL CPLCloseFileInZip(void *hZip);
270 CPLErr CPL_DLL CPLAddFileInZip(void *hZip, const char *pszArchiveFilename,
271 const char *pszInputFilename, VSILFILE *fpInput,
272 CSLConstList papszOptions,
273 GDALProgressFunc pProgressFunc,
274 void *pProgressData);
275 CPLErr CPL_DLL CPLCloseZip(void *hZip);
276
277/* -------------------------------------------------------------------- */
278/* ZLib compression */
279/* -------------------------------------------------------------------- */
280
281 void CPL_DLL *CPLZLibDeflate(const void *ptr, size_t nBytes, int nLevel,
282 void *outptr, size_t nOutAvailableBytes,
283 size_t *pnOutBytes);
284 void CPL_DLL *CPLZLibInflate(const void *ptr, size_t nBytes, void *outptr,
285 size_t nOutAvailableBytes, size_t *pnOutBytes);
286 void CPL_DLL *CPLZLibInflateEx(const void *ptr, size_t nBytes, void *outptr,
287 size_t nOutAvailableBytes,
288 bool bAllowResizeOutptr, size_t *pnOutBytes);
289
290/* -------------------------------------------------------------------- */
291/* XML validation. */
292/* -------------------------------------------------------------------- */
293 int CPL_DLL CPLValidateXML(const char *pszXMLFilename,
294 const char *pszXSDFilename,
295 CSLConstList papszOptions);
296
297/* -------------------------------------------------------------------- */
298/* Locale handling. Prevents parallel executions of setlocale(). */
299/* -------------------------------------------------------------------- */
300 char *CPLsetlocale(int category, const char *locale);
302 void CPLCleanupSetlocaleMutex(void);
310 int CPL_DLL CPLIsPowerOfTwo(unsigned int i);
311
312 CPL_C_END
313
314/* -------------------------------------------------------------------- */
315/* C++ object for temporarily forcing a LC_NUMERIC locale to "C". */
316/* -------------------------------------------------------------------- */
317
319#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
320
321 extern "C++"
322{
323 class CPL_DLL CPLLocaleC
324 {
325 CPL_DISALLOW_COPY_ASSIGN(CPLLocaleC)
326 public:
327 CPLLocaleC();
328 ~CPLLocaleC();
329
330 private:
331 char *pszOldLocale;
332 };
333
334 // Does the same as CPLLocaleC except that, when available, it tries to
335 // only affect the current thread. But code that would be dependent of
336 // setlocale(LC_NUMERIC, NULL) returning "C", such as current proj.4
337 // versions, will not work depending on the actual implementation
338 class CPLThreadLocaleCPrivate;
339
340 class CPL_DLL CPLThreadLocaleC
341 {
342 CPL_DISALLOW_COPY_ASSIGN(CPLThreadLocaleC)
343
344 public:
345 CPLThreadLocaleC();
346 ~CPLThreadLocaleC();
347
348 private:
349 CPLThreadLocaleCPrivate *m_private;
350 };
351}
352
353#endif /* def __cplusplus */
355
356/* -------------------------------------------------------------------- */
357/* C++ object for temporarily forcing a config option */
358/* -------------------------------------------------------------------- */
359
361#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
362
363 extern "C++"
364{
365 class CPL_DLL CPLConfigOptionSetter
366 {
367 CPL_DISALLOW_COPY_ASSIGN(CPLConfigOptionSetter)
368 public:
369 CPLConfigOptionSetter(const char *pszKey, const char *pszValue,
370 bool bSetOnlyIfUndefined);
371 ~CPLConfigOptionSetter();
372
373 private:
374 char *m_pszKey;
375 char *m_pszOldValue;
376 bool m_bRestoreOldValue;
377 };
378}
379
380#endif /* def __cplusplus */
382
383#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
384
385 extern "C++"
386{
387
388#ifndef DOXYGEN_SKIP
389#include <type_traits> // for std::is_base_of
390#endif
391
392 namespace cpl
393 {
403 template <typename To, typename From> inline To down_cast(From *f)
404 {
405 static_assert(
406 (std::is_base_of<From,
407 typename std::remove_pointer<To>::type>::value),
408 "target type not derived from source type");
409 CPLAssert(f == nullptr || dynamic_cast<To>(f) != nullptr);
410 return static_cast<To>(f);
411 }
412 } // namespace cpl
413} // extern "C++"
414
415#endif /* def __cplusplus */
416
417#endif /* ndef CPL_CONV_H_INCLUDED */
CPLGetHomeDir
const char * CPLGetHomeDir(void)
Return the path to the home directory.
Definition cpl_path.cpp:1275
CPLExpandTilde
const char * CPLExpandTilde(const char *pszFilename)
Expands ~/ at start of filename.
Definition cpl_path.cpp:1247
CPLSetConfigOptionSubscriber
void(* CPLSetConfigOptionSubscriber)(const char *pszKey, const char *pszValue, bool bThreadLocal, void *pUserData)
Callback for CPLSubscribeToSetConfigOption()
Definition cpl_conv.h:50
CPLCreateZip
void * CPLCreateZip(const char *pszZipFilename, char **papszOptions)
Create ZIP file.
Definition cpl_conv.cpp:3414
CPLAtofDelim
double CPLAtofDelim(const char *, char)
Converts ASCII string to floating point number.
Definition cpl_strtod.cpp:58
CPLPrintStringFill
int CPLPrintStringFill(char *, const char *, int)
Copy the string pointed to by pszSrc, NOT including the terminating ‘\0’ character,...
Definition cpl_conv.cpp:1257
CPLGetSymbol
void * CPLGetSymbol(const char *, const char *)
Fetch a function pointer from a shared library / DLL.
Definition cplgetsymbol.cpp:71
CPLIsFilenameRelative
int CPLIsFilenameRelative(const char *pszFilename)
Is filename relative or absolute?
Definition cpl_path.cpp:920
CPLReadLine2L
const char * CPLReadLine2L(VSILFILE *, int, CSLConstList)
Simplified line reading from text file.
Definition cpl_conv.cpp:660
CPLPrintUIntBig
int CPLPrintUIntBig(char *, GUIntBig, int)
Print GUIntBig value into specified string buffer.
Definition cpl_conv.cpp:1340
CPLCopyTree
int CPLCopyTree(const char *pszNewPath, const char *pszOldPath)
Recursively copy a tree.
Definition cpl_conv.cpp:3034
CPLCloseShared
void CPLCloseShared(FILE *)
Close shared file.
Definition cpl_conv.cpp:2791
CPLStrtof
float CPLStrtof(const char *, char **)
Converts ASCII string to floating point number.
Definition cpl_strtod.cpp:529
CPLsetlocale
char * CPLsetlocale(int category, const char *locale)
Prevents parallel executions of setlocale().
Definition cpl_conv.cpp:3315
CPLReadLine3L
const char * CPLReadLine3L(VSILFILE *, int, int *, CSLConstList)
Simplified line reading from text file.
Definition cpl_conv.cpp:688
CPLStrtod
double CPLStrtod(const char *, char **)
Converts ASCII string to floating point number.
Definition cpl_strtod.cpp:421
CPLGetExtension
const char * CPLGetExtension(const char *)
Extract filename extension from full filename.
Definition cpl_path.cpp:418
CPLLoadConfigOptionsFromFile
void CPLLoadConfigOptionsFromFile(const char *pszFilename, int bOverrideEnvVars)
Load configuration from a given configuration file.
Definition cpl_conv.cpp:2153
CPLMoveFile
int CPLMoveFile(const char *pszNewPath, const char *pszOldPath)
Move a file.
Definition cpl_conv.cpp:3109
CPLGetThreadLocalConfigOptions
char ** CPLGetThreadLocalConfigOptions(void)
Return the list of thread local configuration options as KEY=VALUE pairs.
Definition cpl_conv.cpp:2032
CPLPrintInt32
int CPLPrintInt32(char *, GInt32, int)
Print GInt32 value into specified string buffer.
Definition cpl_conv.cpp:1301
CPLScanLong
long CPLScanLong(const char *, int)
Scan up to a maximum number of characters from a string and convert the result to a long.
Definition cpl_conv.cpp:917
CPLSetConfigOptions
void CPLSetConfigOptions(const char *const *papszConfigOptions)
Replace the full list of configuration options with the passed list of KEY=VALUE pairs.
Definition cpl_conv.cpp:1754
CPLRealloc
void * CPLRealloc(void *, size_t)
Safe version of realloc().
Definition cpl_conv.cpp:226
CPLFileFinder
char const *(* CPLFileFinder)(const char *, const char *)
Callback for CPLPushFileFinder.
Definition cpl_conv.h:196
CPLStrtofDelim
float CPLStrtofDelim(const char *, char **, char)
Converts ASCII string to floating point number using specified delimiter.
Definition cpl_strtod.cpp:485
CPLZLibInflate
void * CPLZLibInflate(const void *ptr, size_t nBytes, void *outptr, size_t nOutAvailableBytes, size_t *pnOutBytes)
Uncompress a buffer compressed with ZLib compression.
Definition cpl_conv.cpp:3450
CPLSymlink
int CPLSymlink(const char *pszOldPath, const char *pszNewPath, CSLConstList papszOptions)
Create a symbolic link.
Definition cpl_conv.cpp:3133
CPLGetBasename
const char * CPLGetBasename(const char *)
Extract basename (non-directory, non-extension) portion of filename.
Definition cpl_path.cpp:364
CPLLaunderForFilename
const char * CPLLaunderForFilename(const char *pszName, const char *pszOutputPath)
Launder a string to be compatible of a filename.
Definition cpl_path.cpp:1300
CPLMalloc
void * CPLMalloc(size_t)
Safe version of malloc().
Definition cpl_conv.cpp:171
CPLGetDirname
const char * CPLGetDirname(const char *)
Extract directory path portion of filename.
Definition cpl_path.cpp:231
CPLAddFileInZip
CPLErr CPLAddFileInZip(void *hZip, const char *pszArchiveFilename, const char *pszInputFilename, VSILFILE *fpInput, CSLConstList papszOptions, GDALProgressFunc pProgressFunc, void *pProgressData)
Add a file inside a ZIP file opened/created with CPLCreateZip().
Definition cpl_minizip_zip.cpp:2332
CPLGetExecPath
int CPLGetExecPath(char *pszPathBuf, int nMaxLength)
Fetch path of executable.
Definition cpl_getexecpath.cpp:51
CPLFormCIFilename
const char * CPLFormCIFilename(const char *pszPath, const char *pszBasename, const char *pszExtension)
Case insensitive file searching, returning full path.
Definition cpl_path.cpp:766
CPLScanString
char * CPLScanString(const char *, int, int, int)
Scan up to a maximum number of characters from a given string, allocate a buffer for a new string and...
Definition cpl_conv.cpp:857
CPLPrintTime
int CPLPrintTime(char *, int, const char *, const struct tm *, const char *)
Print specified time value accordingly to the format options and specified locale name.
Definition cpl_conv.cpp:1490
CPLFinderClean
void CPLFinderClean(void)
CPLFinderClean.
Definition cpl_findfile.cpp:117
CPLCalloc
void * CPLCalloc(size_t, size_t)
Safe version of calloc().
Definition cpl_conv.cpp:141
CPLAtoGIntBigEx
GIntBig CPLAtoGIntBigEx(const char *pszString, int bWarn, int *pbOverflow)
Convert a string to a 64 bit signed integer.
Definition cpl_conv.cpp:1047
CPLScanPointer
void * CPLScanPointer(const char *, int)
Extract pointer from string.
Definition cpl_conv.cpp:1095
CPLGenerateTempFilename
const char * CPLGenerateTempFilename(const char *pszStem)
Generate temporary file name.
Definition cpl_path.cpp:1206
CPLGetPath
const char * CPLGetPath(const char *)
Extract directory path portion of filename.
Definition cpl_path.cpp:128
CPLCorrespondingPaths
char ** CPLCorrespondingPaths(const char *pszOldFilename, const char *pszNewFilename, char **papszFileList)
Identify corresponding paths.
Definition cpl_path.cpp:1102
CPLStrdup
char * CPLStrdup(const char *)
Safe version of strdup() function.
Definition cpl_conv.cpp:294
CPLCreateFileInZip
CPLErr CPLCreateFileInZip(void *hZip, const char *pszFilename, char **papszOptions)
Create a file in a ZIP file.
Definition cpl_conv.cpp:3422
CPLLoadConfigOptionsFromPredefinedFiles
void CPLLoadConfigOptionsFromPredefinedFiles(void)
Load configuration from a set of predefined files.
Definition cpl_conv.cpp:2349
CPLGetConfigOptions
char ** CPLGetConfigOptions(void)
Return the list of configuration options as KEY=VALUE pairs.
Definition cpl_conv.cpp:1728
CPLStrtodM
double CPLStrtodM(const char *, char **)
Converts ASCII string to floating point number.
Definition cpl_strtod.cpp:448
CPLDMSToDec
double CPLDMSToDec(const char *is)
CPLDMSToDec.
Definition cpl_conv.cpp:2433
CPLCleanTrailingSlash
const char * CPLCleanTrailingSlash(const char *)
Remove trailing forward/backward slash from the path for UNIX/Windows resp.
Definition cpl_path.cpp:1052
CPLReadLineL
const char * CPLReadLineL(VSILFILE *)
Simplified line reading from text file.
Definition cpl_conv.cpp:635
CPLReadLine
const char * CPLReadLine(FILE *)
Simplified line reading from text file.
Definition cpl_conv.cpp:567
CPLValidateXML
int CPLValidateXML(const char *pszXMLFilename, const char *pszXSDFilename, CSLConstList papszOptions)
Validate a XML file against a XML schema.
Definition cpl_xml_validate.cpp:1045
CPLCloseZip
CPLErr CPLCloseZip(void *hZip)
Close ZIP file.
Definition cpl_conv.cpp:3437
CPLGetGlobalConfigOption
const char * CPLGetGlobalConfigOption(const char *, const char *)
Same as CPLGetConfigOption() but excludes environment variables and options set with CPLSetThreadLoca...
Definition cpl_conv.cpp:1799
CPLResetExtension
const char * CPLResetExtension(const char *, const char *)
Replace the extension with the provided one.
Definition cpl_path.cpp:519
CPLOpenShared
FILE * CPLOpenShared(const char *, const char *, int)
Open a shared file handle.
Definition cpl_conv.cpp:2719
CPLPushFinderLocation
void CPLPushFinderLocation(const char *)
CPLPushFinderLocation.
Definition cpl_findfile.cpp:235
CPLGetCurrentDir
char * CPLGetCurrentDir(void)
Get the current working directory name.
Definition cpl_path.cpp:498
CPLPushFileFinder
void CPLPushFileFinder(CPLFileFinder pfnFinder)
CPLPushFileFinder.
Definition cpl_findfile.cpp:187
CPLStat
int CPLStat(const char *, VSIStatBuf *)
Same as VSIStat() except it works on "C:" as if it were "C:\".
Definition cpl_conv.cpp:2384
CPLUnsubscribeToSetConfigOption
void CPLUnsubscribeToSetConfigOption(int nSubscriberId)
Remove a subscriber installed with CPLSubscribeToSetConfigOption()
Definition cpl_conv.cpp:1863
CPLDecToPackedDMS
double CPLDecToPackedDMS(double dfDec)
Convert decimal degrees into packed DMS value (DDDMMMSSS.SS).
Definition cpl_conv.cpp:2642
CPLExtractRelativePath
const char * CPLExtractRelativePath(const char *, const char *, int *)
Get relative path from directory to target file.
Definition cpl_path.cpp:962
CPLGetThreadLocalConfigOption
const char * CPLGetThreadLocalConfigOption(const char *, const char *)
Same as CPLGetConfigOption() but only with options set with CPLSetThreadLocalConfigOption()
Definition cpl_conv.cpp:1768
CPLPopFinderLocation
void CPLPopFinderLocation(void)
CPLPopFinderLocation.
Definition cpl_findfile.cpp:274
CPLAtofM
double CPLAtofM(const char *)
Converts ASCII string to floating point number using any numeric locale.
Definition cpl_strtod.cpp:127
CPLSetConfigOption
void CPLSetConfigOption(const char *, const char *)
Set a configuration option for GDAL/OGR use.
Definition cpl_conv.cpp:1937
CPLFGets
char * CPLFGets(char *, int, FILE *)
Reads in at most one less than nBufferSize characters from the fp stream and stores them into the buf...
Definition cpl_conv.cpp:366
CPLAtoGIntBig
GIntBig CPLAtoGIntBig(const char *pszString)
Convert a string to a 64 bit signed integer.
Definition cpl_conv.cpp:1001
CPLPackedDMSToDec
double CPLPackedDMSToDec(double)
Convert a packed DMS value (DDDMMMSSS.SS) into decimal degrees.
Definition cpl_conv.cpp:2608
CPLDumpSharedList
void CPLDumpSharedList(FILE *)
Report open shared files.
Definition cpl_conv.cpp:2904
CPLUnlinkTree
int CPLUnlinkTree(const char *)
Recursively unlink a directory.
Definition cpl_conv.cpp:2938
CPLSubscribeToSetConfigOption
int CPLSubscribeToSetConfigOption(CPLSetConfigOptionSubscriber pfnCallback, void *pUserData)
Install a callback that will be notified of calls to CPLSetConfigOption()/ CPLSetThreadLocalConfigOpt...
Definition cpl_conv.cpp:1831
CPLProjectRelativeFilename
const char * CPLProjectRelativeFilename(const char *pszProjectDir, const char *pszSecondaryFilename)
Find a file relative to a project file.
Definition cpl_path.cpp:865
CPLScanUIntBig
GUIntBig CPLScanUIntBig(const char *, int)
Extract big integer from string.
Definition cpl_conv.cpp:975
CPLDecToDMS
const char * CPLDecToDMS(double dfAngle, const char *pszAxis, int nPrecision)
Translate a decimal degrees value to a DMS string with hemisphere.
Definition cpl_conv.cpp:2518
CPLFindFile
const char * CPLFindFile(const char *pszClass, const char *pszBasename)
CPLFindFile.
Definition cpl_findfile.cpp:164
CPLScanDouble
double CPLScanDouble(const char *, int)
Extract double from string.
Definition cpl_conv.cpp:1161
CPLIsPowerOfTwo
int CPLIsPowerOfTwo(unsigned int i)
Definition cpl_conv.cpp:3341
CPLGetConfigOption
const char * CPLGetConfigOption(const char *, const char *)
Get the value of a configuration option.
Definition cpl_conv.cpp:1680
CPLScanULong
unsigned long CPLScanULong(const char *, int)
Scan up to a maximum number of characters from a string and convert the result to a unsigned long.
Definition cpl_conv.cpp:945
CPLSetThreadLocalConfigOption
void CPLSetThreadLocalConfigOption(const char *pszKey, const char *pszValue)
Set a configuration option for GDAL/OGR use.
Definition cpl_conv.cpp:1991
CPLStrtodDelim
double CPLStrtodDelim(const char *, char **, char)
Converts ASCII string to floating point number using specified delimiter.
Definition cpl_strtod.cpp:218
cpl::down_cast
To down_cast(From *f)
Use cpl::down_cast<Derived*>(pointer_to_base) as equivalent of static_cast<Derived*>(pointer_to_base)...
Definition cpl_conv.h:403
CPLGetFilename
const char * CPLGetFilename(const char *)
Extract non-directory portion of filename.
Definition cpl_path.cpp:332
CPLStrlwr
char * CPLStrlwr(char *)
Convert each characters of the string to lower case.
Definition cpl_conv.cpp:320
CPLCopyFile
int CPLCopyFile(const char *pszNewPath, const char *pszOldPath)
Copy a file.
Definition cpl_conv.cpp:3021
CPLFormFilename
const char * CPLFormFilename(const char *pszPath, const char *pszBasename, const char *pszExtension)
Build a full file path from a passed path, file basename and extension.
Definition cpl_path.cpp:599
CPLPrintDouble
int CPLPrintDouble(char *, const char *, double, const char *)
Print double value into specified string buffer.
Definition cpl_conv.cpp:1432
CPLZLibDeflate
void * CPLZLibDeflate(const void *ptr, size_t nBytes, int nLevel, void *outptr, size_t nOutAvailableBytes, size_t *pnOutBytes)
Compress a buffer with ZLib compression.
Definition cpl_conv.cpp:3442
CPLPrintString
int CPLPrintString(char *, const char *, int)
Copy the string pointed to by pszSrc, NOT including the terminating ‘\0’ character,...
Definition cpl_conv.cpp:1213
CPLCloseFileInZip
CPLErr CPLCloseFileInZip(void *hZip)
Close current file inside ZIP file.
Definition cpl_conv.cpp:3432
CPLDefaultFindFile
const char * CPLDefaultFindFile(const char *pszClass, const char *pszBasename)
CPLDefaultFindFile.
Definition cpl_findfile.cpp:132
CPLWriteFileInZip
CPLErr CPLWriteFileInZip(void *hZip, const void *pBuffer, int nBufferSize)
Write in current file inside a ZIP file.
Definition cpl_conv.cpp:3427
CPLPopFileFinder
CPLFileFinder CPLPopFileFinder(void)
CPLPopFileFinder.
Definition cpl_findfile.cpp:224
CPLPrintPointer
int CPLPrintPointer(char *, void *, int)
Print pointer value into specified string buffer.
Definition cpl_conv.cpp:1388
CPLStringToComplex
void CPLStringToComplex(const char *pszString, double *pdfReal, double *pdfImag)
Fetch the real and imaginary part of a serialized complex number.
Definition cpl_conv.cpp:2659
CPLSetThreadLocalConfigOptions
void CPLSetThreadLocalConfigOptions(const char *const *papszConfigOptions)
Replace the full list of thread local configuration options with the passed list of KEY=VALUE pairs.
Definition cpl_conv.cpp:2062
CPLZLibInflateEx
void * CPLZLibInflateEx(const void *ptr, size_t nBytes, void *outptr, size_t nOutAvailableBytes, bool bAllowResizeOutptr, size_t *pnOutBytes)
Uncompress a buffer compressed with ZLib compression.
Definition cpl_vsil_gzip.cpp:5139
CPLCheckForFile
int CPLCheckForFile(char *pszFilename, char **papszSiblingList)
Check for file existence.
Definition cpl_conv.cpp:3376
CPLGetSharedList
CPLSharedFileInfo * CPLGetSharedList(int *)
Fetch list of open shared files.
Definition cpl_conv.cpp:2882
CPLAtof
double CPLAtof(const char *)
Converts ASCII string to floating point number.
Definition cpl_strtod.cpp:102
cpl_error.h
CPL error handling services.
CPLAssert
#define CPLAssert(expr)
Assert on an expression.
Definition cpl_error.h:209
CPLErr
CPLErr
Error category.
Definition cpl_error.h:37
cpl_port.h
Core portability definitions for CPL.
GUIntBig
unsigned long long GUIntBig
Large unsigned integer type (generally 64-bit unsigned integer type).
Definition cpl_port.h:202
CPL_C_END
#define CPL_C_END
Macro to end a block of C symbols.
Definition cpl_port.h:283
CPL_C_START
#define CPL_C_START
Macro to start a block of C symbols.
Definition cpl_port.h:279
CPL_RETURNS_NONNULL
#define CPL_RETURNS_NONNULL
Qualifier for a function that does not return NULL.
Definition cpl_port.h:1002
CPL_DISALLOW_COPY_ASSIGN
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition cpl_port.h:1030
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1179
CPL_WARN_UNUSED_RESULT
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition cpl_port.h:964
GInt32
int GInt32
Int32 type.
Definition cpl_port.h:159
GIntBig
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition cpl_port.h:199
cpl_vsi.h
Standard C Covers.
CPLSharedFileInfo
Information on a shared file.
Definition cpl_conv.h:219
CPLSharedFileInfo::pszAccess
char * pszAccess
Access mode.
Definition cpl_conv.h:224
CPLSharedFileInfo::fp
FILE * fp
File pointer.
Definition cpl_conv.h:220
CPLSharedFileInfo::nRefCount
int nRefCount
Reference counter.
Definition cpl_conv.h:221
CPLSharedFileInfo::pszFilename
char * pszFilename
Filename.
Definition cpl_conv.h:223
CPLSharedFileInfo::bLarge
int bLarge
Whether fp must be interpreted as VSIFILE*.
Definition cpl_conv.h:222
VSIVirtualHandle
Virtual file handle.
Definition cpl_vsi_virtual.h:47