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 * Permission is hereby granted, free of charge, to any person obtaining a
14 * copy of this software and associated documentation files (the "Software"),
15 * to deal in the Software without restriction, including without limitation
16 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 * and/or sell copies of the Software, and to permit persons to whom the
18 * Software is furnished to do so, subject to the following conditions:
19 *
20 * The above copyright notice and this permission notice shall be included
21 * in all copies or substantial portions of the Software.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 * DEALINGS IN THE SOFTWARE.
30 ****************************************************************************/
31
32#ifndef CPL_CONV_H_INCLUDED
33#define CPL_CONV_H_INCLUDED
34
35#include "cpl_port.h"
36#include "cpl_vsi.h"
37#include "cpl_error.h"
38
46/* -------------------------------------------------------------------- */
47/* Runtime check of various configuration items. */
48/* -------------------------------------------------------------------- */
50
52void CPL_DLL CPLVerifyConfiguration(void);
55const char CPL_DLL *CPL_STDCALL CPLGetConfigOption(const char *, const char *)
57const char CPL_DLL *CPL_STDCALL CPLGetThreadLocalConfigOption(
58 const char *, const char *) CPL_WARN_UNUSED_RESULT;
59const char CPL_DLL *CPL_STDCALL
60CPLGetGlobalConfigOption(const char *, const char *) CPL_WARN_UNUSED_RESULT;
61void CPL_DLL CPL_STDCALL CPLSetConfigOption(const char *, const char *);
62void CPL_DLL CPL_STDCALL CPLSetThreadLocalConfigOption(const char *pszKey,
63 const char *pszValue);
64
66typedef void (*CPLSetConfigOptionSubscriber)(const char *pszKey,
67 const char *pszValue,
68 bool bThreadLocal,
69 void *pUserData);
71 CPLSetConfigOptionSubscriber pfnCallback, void *pUserData);
72void CPL_DLL CPLUnsubscribeToSetConfigOption(int nSubscriberId);
73
75void CPL_DLL CPL_STDCALL CPLFreeConfig(void);
77char CPL_DLL **CPLGetConfigOptions(void);
78void CPL_DLL CPLSetConfigOptions(const char *const *papszConfigOptions);
79char CPL_DLL **CPLGetThreadLocalConfigOptions(void);
80void CPL_DLL
81CPLSetThreadLocalConfigOptions(const char *const *papszConfigOptions);
82void CPL_DLL CPLLoadConfigOptionsFromFile(const char *pszFilename,
83 int bOverrideEnvVars);
85
86/* -------------------------------------------------------------------- */
87/* Safe malloc() API. Thin cover over VSI functions with fatal */
88/* error reporting if memory allocation fails. */
89/* -------------------------------------------------------------------- */
90void CPL_DLL *CPLMalloc(size_t) CPL_WARN_UNUSED_RESULT;
91void CPL_DLL *CPLCalloc(size_t, size_t) CPL_WARN_UNUSED_RESULT;
92void CPL_DLL *CPLRealloc(void *, size_t) CPL_WARN_UNUSED_RESULT;
93char CPL_DLL *
95char CPL_DLL *CPLStrlwr(char *);
96
98#define CPLFree VSIFree
99
100/* -------------------------------------------------------------------- */
101/* Read a line from a text file, and strip of CR/LF. */
102/* -------------------------------------------------------------------- */
103char CPL_DLL *CPLFGets(char *, int, FILE *);
104const char CPL_DLL *CPLReadLine(FILE *);
105const char CPL_DLL *CPLReadLineL(VSILFILE *);
106const char CPL_DLL *CPLReadLine2L(VSILFILE *, int, CSLConstList);
107const char CPL_DLL *CPLReadLine3L(VSILFILE *, int, int *, CSLConstList);
108
109/* -------------------------------------------------------------------- */
110/* Convert ASCII string to floating point number */
111/* (THESE FUNCTIONS ARE NOT LOCALE AWARE!). */
112/* -------------------------------------------------------------------- */
113double CPL_DLL CPLAtof(const char *);
114double CPL_DLL CPLAtofDelim(const char *, char);
115double CPL_DLL CPLStrtod(const char *, char **);
116double CPL_DLL CPLStrtodM(const char *, char **);
117double CPL_DLL CPLStrtodDelim(const char *, char **, char);
118float CPL_DLL CPLStrtof(const char *, char **);
119float CPL_DLL CPLStrtofDelim(const char *, char **, char);
120
121/* -------------------------------------------------------------------- */
122/* Convert number to string. This function is locale agnostic */
123/* (i.e. it will support "," or "." regardless of current locale) */
124/* -------------------------------------------------------------------- */
125double CPL_DLL CPLAtofM(const char *);
126
127/* -------------------------------------------------------------------- */
128/* Read a numeric value from an ASCII character string. */
129/* -------------------------------------------------------------------- */
130char CPL_DLL *CPLScanString(const char *, int, int, int);
131double CPL_DLL CPLScanDouble(const char *, int);
132long CPL_DLL CPLScanLong(const char *, int);
133unsigned long CPL_DLL CPLScanULong(const char *, int);
134GUIntBig CPL_DLL CPLScanUIntBig(const char *, int);
135GIntBig CPL_DLL CPLAtoGIntBig(const char *pszString);
136GIntBig CPL_DLL CPLAtoGIntBigEx(const char *pszString, int bWarn,
137 int *pbOverflow);
138void CPL_DLL *CPLScanPointer(const char *, int);
139
140/* -------------------------------------------------------------------- */
141/* Print a value to an ASCII character string. */
142/* -------------------------------------------------------------------- */
143int CPL_DLL CPLPrintString(char *, const char *, int);
144int CPL_DLL CPLPrintStringFill(char *, const char *, int);
145int CPL_DLL CPLPrintInt32(char *, GInt32, int);
146int CPL_DLL CPLPrintUIntBig(char *, GUIntBig, int);
147int CPL_DLL CPLPrintDouble(char *, const char *, double, const char *);
148int CPL_DLL CPLPrintTime(char *, int, const char *, const struct tm *,
149 const char *);
150int CPL_DLL CPLPrintPointer(char *, void *, int);
151
152/* -------------------------------------------------------------------- */
153/* Fetch a function from DLL / so. */
154/* -------------------------------------------------------------------- */
155
156void CPL_DLL *CPLGetSymbol(const char *, const char *);
157
158/* -------------------------------------------------------------------- */
159/* Fetch executable path. */
160/* -------------------------------------------------------------------- */
161int CPL_DLL CPLGetExecPath(char *pszPathBuf, int nMaxLength);
162
163/* -------------------------------------------------------------------- */
164/* Filename handling functions. */
165/* -------------------------------------------------------------------- */
166const char CPL_DLL *
168const char CPL_DLL *
170const char CPL_DLL *
172const char CPL_DLL *
174const char CPL_DLL *
176char CPL_DLL *CPLGetCurrentDir(void);
177const char CPL_DLL *CPLFormFilename(
178 const char *pszPath, const char *pszBasename,
179 const char *pszExtension) CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL;
180const char CPL_DLL *CPLFormCIFilename(
181 const char *pszPath, const char *pszBasename,
182 const char *pszExtension) CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL;
183const char CPL_DLL *CPLResetExtension(const char *, const char *)
185const char CPL_DLL *CPLProjectRelativeFilename(const char *pszProjectDir,
186 const char *pszSecondaryFilename)
188int CPL_DLL CPLIsFilenameRelative(const char *pszFilename);
189const char CPL_DLL *CPLExtractRelativePath(const char *, const char *, int *)
191const char CPL_DLL *
193char CPL_DLL **
194CPLCorrespondingPaths(const char *pszOldFilename, const char *pszNewFilename,
195 char **papszFileList) CPL_WARN_UNUSED_RESULT;
196int CPL_DLL CPLCheckForFile(char *pszFilename, char **papszSiblingList);
197
198const char CPL_DLL *CPLGenerateTempFilename(const char *pszStem)
200const char CPL_DLL *CPLExpandTilde(const char *pszFilename)
202const char CPL_DLL *CPLGetHomeDir(void) CPL_WARN_UNUSED_RESULT;
203const char CPL_DLL *
204CPLLaunderForFilename(const char *pszName,
205 const char *pszOutputPath) CPL_WARN_UNUSED_RESULT;
206
207/* -------------------------------------------------------------------- */
208/* Find File Function */
209/* -------------------------------------------------------------------- */
210
212typedef char const *(*CPLFileFinder)(const char *, const char *);
213
214const char CPL_DLL *CPLFindFile(const char *pszClass, const char *pszBasename);
215const char CPL_DLL *CPLDefaultFindFile(const char *pszClass,
216 const char *pszBasename);
217void CPL_DLL CPLPushFileFinder(CPLFileFinder pfnFinder);
218CPLFileFinder CPL_DLL CPLPopFileFinder(void);
219void CPL_DLL CPLPushFinderLocation(const char *);
220void CPL_DLL CPLPopFinderLocation(void);
221void CPL_DLL CPLFinderClean(void);
222
223/* -------------------------------------------------------------------- */
224/* Safe version of stat() that works properly on stuff like "C:". */
225/* -------------------------------------------------------------------- */
226int CPL_DLL CPLStat(const char *, VSIStatBuf *) CPL_WARN_UNUSED_RESULT;
227
228/* -------------------------------------------------------------------- */
229/* Reference counted file handle manager. Makes sharing file */
230/* handles more practical. */
231/* -------------------------------------------------------------------- */
232
234typedef struct
235{
236 FILE *fp;
238 int bLarge;
240 char *pszAccess;
242
243FILE CPL_DLL *CPLOpenShared(const char *, const char *, int);
244void CPL_DLL CPLCloseShared(FILE *);
245CPLSharedFileInfo CPL_DLL *CPLGetSharedList(int *);
246void CPL_DLL CPLDumpSharedList(FILE *);
248void CPL_DLL CPLCleanupSharedFileMutex(void);
251/* -------------------------------------------------------------------- */
252/* DMS to Dec to DMS conversion. */
253/* -------------------------------------------------------------------- */
254double CPL_DLL CPLDMSToDec(const char *is);
255const char CPL_DLL *CPLDecToDMS(double dfAngle, const char *pszAxis,
256 int nPrecision);
257double CPL_DLL CPLPackedDMSToDec(double);
258double CPL_DLL CPLDecToPackedDMS(double dfDec);
259
260void CPL_DLL CPLStringToComplex(const char *pszString, double *pdfReal,
261 double *pdfImag);
262
263/* -------------------------------------------------------------------- */
264/* Misc other functions. */
265/* -------------------------------------------------------------------- */
266int CPL_DLL CPLUnlinkTree(const char *);
267int CPL_DLL CPLCopyFile(const char *pszNewPath, const char *pszOldPath);
268int CPL_DLL CPLCopyTree(const char *pszNewPath, const char *pszOldPath);
269int CPL_DLL CPLMoveFile(const char *pszNewPath, const char *pszOldPath);
270int CPL_DLL CPLSymlink(const char *pszOldPath, const char *pszNewPath,
271 CSLConstList papszOptions);
272
273/* -------------------------------------------------------------------- */
274/* ZIP Creation. */
275/* -------------------------------------------------------------------- */
276
278#define CPL_ZIP_API_OFFERED
280void CPL_DLL *CPLCreateZip(const char *pszZipFilename, char **papszOptions);
281CPLErr CPL_DLL CPLCreateFileInZip(void *hZip, const char *pszFilename,
282 char **papszOptions);
283CPLErr CPL_DLL CPLWriteFileInZip(void *hZip, const void *pBuffer,
284 int nBufferSize);
285CPLErr CPL_DLL CPLCloseFileInZip(void *hZip);
286CPLErr CPL_DLL CPLAddFileInZip(void *hZip, const char *pszArchiveFilename,
287 const char *pszInputFilename, VSILFILE *fpInput,
288 CSLConstList papszOptions,
289 GDALProgressFunc pProgressFunc,
290 void *pProgressData);
291CPLErr CPL_DLL CPLCloseZip(void *hZip);
292
293/* -------------------------------------------------------------------- */
294/* ZLib compression */
295/* -------------------------------------------------------------------- */
296
297void CPL_DLL *CPLZLibDeflate(const void *ptr, size_t nBytes, int nLevel,
298 void *outptr, size_t nOutAvailableBytes,
299 size_t *pnOutBytes);
300void CPL_DLL *CPLZLibInflate(const void *ptr, size_t nBytes, void *outptr,
301 size_t nOutAvailableBytes, size_t *pnOutBytes);
302void CPL_DLL *CPLZLibInflateEx(const void *ptr, size_t nBytes, void *outptr,
303 size_t nOutAvailableBytes,
304 bool bAllowResizeOutptr, size_t *pnOutBytes);
305
306/* -------------------------------------------------------------------- */
307/* XML validation. */
308/* -------------------------------------------------------------------- */
309int CPL_DLL CPLValidateXML(const char *pszXMLFilename,
310 const char *pszXSDFilename,
311 CSLConstList papszOptions);
312
313/* -------------------------------------------------------------------- */
314/* Locale handling. Prevents parallel executions of setlocale(). */
315/* -------------------------------------------------------------------- */
316char *CPLsetlocale(int category, const char *locale);
318void CPLCleanupSetlocaleMutex(void);
326int CPL_DLL CPLIsPowerOfTwo(unsigned int i);
327
329
330/* -------------------------------------------------------------------- */
331/* C++ object for temporarily forcing a LC_NUMERIC locale to "C". */
332/* -------------------------------------------------------------------- */
333
335#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
336
337extern "C++"
338{
339 class CPL_DLL CPLLocaleC
340 {
341 CPL_DISALLOW_COPY_ASSIGN(CPLLocaleC)
342 public:
343 CPLLocaleC();
344 ~CPLLocaleC();
345
346 private:
347 char *pszOldLocale;
348 };
349
350 // Does the same as CPLLocaleC except that, when available, it tries to
351 // only affect the current thread. But code that would be dependent of
352 // setlocale(LC_NUMERIC, NULL) returning "C", such as current proj.4
353 // versions, will not work depending on the actual implementation
354 class CPLThreadLocaleCPrivate;
355
356 class CPL_DLL CPLThreadLocaleC
357 {
358 CPL_DISALLOW_COPY_ASSIGN(CPLThreadLocaleC)
359
360 public:
361 CPLThreadLocaleC();
362 ~CPLThreadLocaleC();
363
364 private:
365 CPLThreadLocaleCPrivate *m_private;
366 };
367}
368
369#endif /* def __cplusplus */
371
372/* -------------------------------------------------------------------- */
373/* C++ object for temporarily forcing a config option */
374/* -------------------------------------------------------------------- */
375
377#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
378
379extern "C++"
380{
381 class CPL_DLL CPLConfigOptionSetter
382 {
383 CPL_DISALLOW_COPY_ASSIGN(CPLConfigOptionSetter)
384 public:
385 CPLConfigOptionSetter(const char *pszKey, const char *pszValue,
386 bool bSetOnlyIfUndefined);
387 ~CPLConfigOptionSetter();
388
389 private:
390 char *m_pszKey;
391 char *m_pszOldValue;
392 bool m_bRestoreOldValue;
393 };
394}
395
396#endif /* def __cplusplus */
398
399#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
400
401extern "C++"
402{
403
404#ifndef DOXYGEN_SKIP
405#include <type_traits> // for std::is_base_of
406#endif
407
408 namespace cpl
409 {
419 template <typename To, typename From> inline To down_cast(From *f)
420 {
421 static_assert(
422 (std::is_base_of<From,
423 typename std::remove_pointer<To>::type>::value),
424 "target type not derived from source type");
425 CPLAssert(f == nullptr || dynamic_cast<To>(f) != nullptr);
426 return static_cast<To>(f);
427 }
428 } // namespace cpl
429} // extern "C++"
430
431#endif /* def __cplusplus */
432
433#endif /* ndef CPL_CONV_H_INCLUDED */
const char * CPLGetHomeDir(void)
Return the path to the home directory.
Definition: cpl_path.cpp:1125
const char * CPLExpandTilde(const char *pszFilename)
Expands ~/ at start of filename.
Definition: cpl_path.cpp:1097
void(* CPLSetConfigOptionSubscriber)(const char *pszKey, const char *pszValue, bool bThreadLocal, void *pUserData)
Callback for CPLSubscribeToSetConfigOption()
Definition: cpl_conv.h:66
void * CPLCreateZip(const char *pszZipFilename, char **papszOptions)
Create ZIP file.
Definition: cpl_conv.cpp:3423
double CPLAtofDelim(const char *, char)
Converts ASCII string to floating point number.
Definition: cpl_strtod.cpp:74
int CPLPrintStringFill(char *, const char *, int)
Copy the string pointed to by pszSrc, NOT including the terminating ‘\0’ character,...
Definition: cpl_conv.cpp:1273
void * CPLGetSymbol(const char *, const char *)
Fetch a function pointer from a shared library / DLL.
Definition: cplgetsymbol.cpp:87
int CPLIsFilenameRelative(const char *pszFilename)
Is filename relative or absolute?
Definition: cpl_path.cpp:770
const char * CPLReadLine2L(VSILFILE *, int, CSLConstList)
Simplified line reading from text file.
Definition: cpl_conv.cpp:676
int CPLPrintUIntBig(char *, GUIntBig, int)
Print GUIntBig value into specified string buffer.
Definition: cpl_conv.cpp:1356
int CPLCopyTree(const char *pszNewPath, const char *pszOldPath)
Recursively copy a tree.
Definition: cpl_conv.cpp:3043
void CPLCloseShared(FILE *)
Close shared file.
Definition: cpl_conv.cpp:2800
float CPLStrtof(const char *, char **)
Converts ASCII string to floating point number.
Definition: cpl_strtod.cpp:545
char * CPLsetlocale(int category, const char *locale)
Prevents parallel executions of setlocale().
Definition: cpl_conv.cpp:3324
const char * CPLReadLine3L(VSILFILE *, int, int *, CSLConstList)
Simplified line reading from text file.
Definition: cpl_conv.cpp:704
double CPLStrtod(const char *, char **)
Converts ASCII string to floating point number.
Definition: cpl_strtod.cpp:437
const char * CPLGetExtension(const char *)
Extract filename extension from full filename.
Definition: cpl_path.cpp:335
void CPLLoadConfigOptionsFromFile(const char *pszFilename, int bOverrideEnvVars)
Load configuration from a given configuration file.
Definition: cpl_conv.cpp:2162
int CPLMoveFile(const char *pszNewPath, const char *pszOldPath)
Move a file.
Definition: cpl_conv.cpp:3118
char ** CPLGetThreadLocalConfigOptions(void)
Return the list of thread local configuration options as KEY=VALUE pairs.
Definition: cpl_conv.cpp:2041
int CPLPrintInt32(char *, GInt32, int)
Print GInt32 value into specified string buffer.
Definition: cpl_conv.cpp:1317
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:933
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:1770
void * CPLRealloc(void *, size_t)
Safe version of realloc().
Definition: cpl_conv.cpp:242
char const *(* CPLFileFinder)(const char *, const char *)
Callback for CPLPushFileFinder.
Definition: cpl_conv.h:212
float CPLStrtofDelim(const char *, char **, char)
Converts ASCII string to floating point number using specified delimiter.
Definition: cpl_strtod.cpp:501
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:3459
int CPLSymlink(const char *pszOldPath, const char *pszNewPath, CSLConstList papszOptions)
Create a symbolic link.
Definition: cpl_conv.cpp:3142
const char * CPLGetBasename(const char *)
Extract basename (non-directory, non-extension) portion of filename.
Definition: cpl_path.cpp:281
const char * CPLLaunderForFilename(const char *pszName, const char *pszOutputPath)
Launder a string to be compatible of a filename.
Definition: cpl_path.cpp:1150
void * CPLMalloc(size_t)
Safe version of malloc().
Definition: cpl_conv.cpp:187
const char * CPLGetDirname(const char *)
Extract directory path portion of filename.
Definition: cpl_path.cpp:198
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
int CPLGetExecPath(char *pszPathBuf, int nMaxLength)
Fetch path of executable.
Definition: cpl_getexecpath.cpp:67
const char * CPLFormCIFilename(const char *pszPath, const char *pszBasename, const char *pszExtension)
Case insensitive file searching, returning full path.
Definition: cpl_path.cpp:624
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:873
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:1506
void CPLFinderClean(void)
CPLFinderClean.
Definition: cpl_findfile.cpp:133
void * CPLCalloc(size_t, size_t)
Safe version of calloc().
Definition: cpl_conv.cpp:157
GIntBig CPLAtoGIntBigEx(const char *pszString, int bWarn, int *pbOverflow)
Convert a string to a 64 bit signed integer.
Definition: cpl_conv.cpp:1063
void * CPLScanPointer(const char *, int)
Extract pointer from string.
Definition: cpl_conv.cpp:1111
const char * CPLGenerateTempFilename(const char *pszStem)
Generate temporary file name.
Definition: cpl_path.cpp:1056
const char * CPLGetPath(const char *)
Extract directory path portion of filename.
Definition: cpl_path.cpp:144
char ** CPLCorrespondingPaths(const char *pszOldFilename, const char *pszNewFilename, char **papszFileList)
Identify corresponding paths.
Definition: cpl_path.cpp:952
char * CPLStrdup(const char *)
Safe version of strdup() function.
Definition: cpl_conv.cpp:310
CPLErr CPLCreateFileInZip(void *hZip, const char *pszFilename, char **papszOptions)
Create a file in a ZIP file.
Definition: cpl_conv.cpp:3431
void CPLLoadConfigOptionsFromPredefinedFiles(void)
Load configuration from a set of predefined files.
Definition: cpl_conv.cpp:2358
char ** CPLGetConfigOptions(void)
Return the list of configuration options as KEY=VALUE pairs.
Definition: cpl_conv.cpp:1744
double CPLStrtodM(const char *, char **)
Converts ASCII string to floating point number.
Definition: cpl_strtod.cpp:464
double CPLDMSToDec(const char *is)
CPLDMSToDec.
Definition: cpl_conv.cpp:2442
const char * CPLCleanTrailingSlash(const char *)
Remove trailing forward/backward slash from the path for UNIX/Windows resp.
Definition: cpl_path.cpp:902
const char * CPLReadLineL(VSILFILE *)
Simplified line reading from text file.
Definition: cpl_conv.cpp:651
const char * CPLReadLine(FILE *)
Simplified line reading from text file.
Definition: cpl_conv.cpp:583
int CPLValidateXML(const char *pszXMLFilename, const char *pszXSDFilename, CSLConstList papszOptions)
Validate a XML file against a XML schema.
Definition: cpl_xml_validate.cpp:1061
CPLErr CPLCloseZip(void *hZip)
Close ZIP file.
Definition: cpl_conv.cpp:3446
const char * CPLGetGlobalConfigOption(const char *, const char *)
Same as CPLGetConfigOption() but excludes environment variables and options set with CPLSetThreadLoca...
Definition: cpl_conv.cpp:1815
const char * CPLResetExtension(const char *, const char *)
Replace the extension with the provided one.
Definition: cpl_path.cpp:436
FILE * CPLOpenShared(const char *, const char *, int)
Open a shared file handle.
Definition: cpl_conv.cpp:2728
void CPLPushFinderLocation(const char *)
CPLPushFinderLocation.
Definition: cpl_findfile.cpp:251
char * CPLGetCurrentDir(void)
Get the current working directory name.
Definition: cpl_path.cpp:415
void CPLPushFileFinder(CPLFileFinder pfnFinder)
CPLPushFileFinder.
Definition: cpl_findfile.cpp:203
int CPLStat(const char *, VSIStatBuf *)
Same as VSIStat() except it works on "C:" as if it were "C:\".
Definition: cpl_conv.cpp:2393
void CPLUnsubscribeToSetConfigOption(int nSubscriberId)
Remove a subscriber installed with CPLSubscribeToSetConfigOption()
Definition: cpl_conv.cpp:1879
double CPLDecToPackedDMS(double dfDec)
Convert decimal degrees into packed DMS value (DDDMMMSSS.SS).
Definition: cpl_conv.cpp:2651
const char * CPLExtractRelativePath(const char *, const char *, int *)
Get relative path from directory to target file.
Definition: cpl_path.cpp:812
const char * CPLGetThreadLocalConfigOption(const char *, const char *)
Same as CPLGetConfigOption() but only with options set with CPLSetThreadLocalConfigOption()
Definition: cpl_conv.cpp:1784
void CPLPopFinderLocation(void)
CPLPopFinderLocation.
Definition: cpl_findfile.cpp:290
double CPLAtofM(const char *)
Converts ASCII string to floating point number using any numeric locale.
Definition: cpl_strtod.cpp:143
void CPLSetConfigOption(const char *, const char *)
Set a configuration option for GDAL/OGR use.
Definition: cpl_conv.cpp:1946
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:382
GIntBig CPLAtoGIntBig(const char *pszString)
Convert a string to a 64 bit signed integer.
Definition: cpl_conv.cpp:1017
double CPLPackedDMSToDec(double)
Convert a packed DMS value (DDDMMMSSS.SS) into decimal degrees.
Definition: cpl_conv.cpp:2617
void CPLDumpSharedList(FILE *)
Report open shared files.
Definition: cpl_conv.cpp:2913
int CPLUnlinkTree(const char *)
Recursively unlink a directory.
Definition: cpl_conv.cpp:2947
int CPLSubscribeToSetConfigOption(CPLSetConfigOptionSubscriber pfnCallback, void *pUserData)
Install a callback that will be notified of calls to CPLSetConfigOption()/ CPLSetThreadLocalConfigOpt...
Definition: cpl_conv.cpp:1847
const char * CPLProjectRelativeFilename(const char *pszProjectDir, const char *pszSecondaryFilename)
Find a file relative to a project file.
Definition: cpl_path.cpp:715
GUIntBig CPLScanUIntBig(const char *, int)
Extract big integer from string.
Definition: cpl_conv.cpp:991
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:2527
const char * CPLFindFile(const char *pszClass, const char *pszBasename)
CPLFindFile.
Definition: cpl_findfile.cpp:180
double CPLScanDouble(const char *, int)
Extract double from string.
Definition: cpl_conv.cpp:1177
int CPLIsPowerOfTwo(unsigned int i)
Definition: cpl_conv.cpp:3350
const char * CPLGetConfigOption(const char *, const char *)
Get the value of a configuration option.
Definition: cpl_conv.cpp:1696
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:961
void CPLSetThreadLocalConfigOption(const char *pszKey, const char *pszValue)
Set a configuration option for GDAL/OGR use.
Definition: cpl_conv.cpp:2000
double CPLStrtodDelim(const char *, char **, char)
Converts ASCII string to floating point number using specified delimiter.
Definition: cpl_strtod.cpp:234
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:419
const char * CPLGetFilename(const char *)
Extract non-directory portion of filename.
Definition: cpl_path.cpp:249
char * CPLStrlwr(char *)
Convert each characters of the string to lower case.
Definition: cpl_conv.cpp:336
int CPLCopyFile(const char *pszNewPath, const char *pszOldPath)
Copy a file.
Definition: cpl_conv.cpp:3030
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:515
int CPLPrintDouble(char *, const char *, double, const char *)
Print double value into specified string buffer.
Definition: cpl_conv.cpp:1448
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:3451
int CPLPrintString(char *, const char *, int)
Copy the string pointed to by pszSrc, NOT including the terminating ‘\0’ character,...
Definition: cpl_conv.cpp:1229
CPLErr CPLCloseFileInZip(void *hZip)
Close current file inside ZIP file.
Definition: cpl_conv.cpp:3441
const char * CPLDefaultFindFile(const char *pszClass, const char *pszBasename)
CPLDefaultFindFile.
Definition: cpl_findfile.cpp:148
CPLErr CPLWriteFileInZip(void *hZip, const void *pBuffer, int nBufferSize)
Write in current file inside a ZIP file.
Definition: cpl_conv.cpp:3436
CPLFileFinder CPLPopFileFinder(void)
CPLPopFileFinder.
Definition: cpl_findfile.cpp:240
int CPLPrintPointer(char *, void *, int)
Print pointer value into specified string buffer.
Definition: cpl_conv.cpp:1404
void CPLStringToComplex(const char *pszString, double *pdfReal, double *pdfImag)
Fetch the real and imaginary part of a serialized complex number.
Definition: cpl_conv.cpp:2668
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:2071
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:5039
int CPLCheckForFile(char *pszFilename, char **papszSiblingList)
Check for file existence.
Definition: cpl_conv.cpp:3385
CPLSharedFileInfo * CPLGetSharedList(int *)
Fetch list of open shared files.
Definition: cpl_conv.cpp:2891
double CPLAtof(const char *)
Converts ASCII string to floating point number.
Definition: cpl_strtod.cpp:118
CPL error handling services.
#define CPLAssert(expr)
Assert on an expression.
Definition: cpl_error.h:216
CPLErr
Error category.
Definition: cpl_error.h:53
Core portability definitions for CPL.
unsigned long long GUIntBig
Large unsigned integer type (generally 64-bit unsigned integer type).
Definition: cpl_port.h:218
#define CPL_C_END
Macro to end a block of C symbols.
Definition: cpl_port.h:299
#define CPL_C_START
Macro to start a block of C symbols.
Definition: cpl_port.h:295
#define CPL_RETURNS_NONNULL
Qualifier for a function that does not return NULL.
Definition: cpl_port.h:1014
#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:1042
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1183
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition: cpl_port.h:976
int GInt32
Int32 type.
Definition: cpl_port.h:175
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:215
Standard C Covers.
Information on a shared file.
Definition: cpl_conv.h:235
char * pszAccess
Access mode.
Definition: cpl_conv.h:240
FILE * fp
File pointer.
Definition: cpl_conv.h:236
int nRefCount
Reference counter.
Definition: cpl_conv.h:237
char * pszFilename
Filename.
Definition: cpl_conv.h:239
int bLarge
Whether fp must be interpreted as VSIFILE*.
Definition: cpl_conv.h:238
Virtual file handle.
Definition: cpl_vsi_virtual.h:63