Go to the documentation of this file.
32 #ifndef CPL_CONV_H_INCLUDED
33 #define CPL_CONV_H_INCLUDED
52 void CPL_DLL CPLVerifyConfiguration(
void);
59 const char CPL_DLL *CPL_STDCALL
63 const char *pszValue);
75 void CPL_DLL CPL_STDCALL CPLFreeConfig(
void);
83 int bOverrideEnvVars);
98 #define CPLFree VSIFree
103 char CPL_DLL *
CPLFGets(
char *,
int, FILE *);
113 double CPL_DLL
CPLAtof(
const char *);
115 double CPL_DLL
CPLStrtod(
const char *,
char **);
117 float CPL_DLL
CPLStrtof(
const char *,
char **);
124 double CPL_DLL
CPLAtofM(
const char *);
146 int CPL_DLL
CPLPrintDouble(
char *,
const char *,
double,
const char *);
147 int CPL_DLL
CPLPrintTime(
char *,
int,
const char *,
const struct tm *,
177 const char *pszPath,
const char *pszBasename,
180 const char *pszPath,
const char *pszBasename,
185 const char *pszSecondaryFilename)
195 int CPL_DLL
CPLCheckForFile(
char *pszFilename,
char **papszSiblingList);
211 typedef char const *(*CPLFileFinder)(
const char *,
const char *);
213 const char CPL_DLL *
CPLFindFile(
const char *pszClass,
const char *pszBasename);
215 const char *pszBasename);
242 FILE CPL_DLL *
CPLOpenShared(
const char *,
const char *,
int);
247 void CPL_DLL CPLCleanupSharedFileMutex(
void);
254 const char CPL_DLL *
CPLDecToDMS(
double dfAngle,
const char *pszAxis,
266 int CPL_DLL
CPLCopyFile(
const char *pszNewPath,
const char *pszOldPath);
267 int CPL_DLL
CPLCopyTree(
const char *pszNewPath,
const char *pszOldPath);
268 int CPL_DLL
CPLMoveFile(
const char *pszNewPath,
const char *pszOldPath);
269 int CPL_DLL
CPLSymlink(
const char *pszOldPath,
const char *pszNewPath,
277 #define CPL_ZIP_API_OFFERED
279 void CPL_DLL *
CPLCreateZip(
const char *pszZipFilename,
char **papszOptions);
281 char **papszOptions);
286 const char *pszInputFilename,
VSILFILE *fpInput,
288 GDALProgressFunc pProgressFunc,
289 void *pProgressData);
296 void CPL_DLL *
CPLZLibDeflate(
const void *ptr,
size_t nBytes,
int nLevel,
297 void *outptr,
size_t nOutAvailableBytes,
299 void CPL_DLL *
CPLZLibInflate(
const void *ptr,
size_t nBytes,
void *outptr,
300 size_t nOutAvailableBytes,
size_t *pnOutBytes);
306 const char *pszXSDFilename,
314 void CPLCleanupSetlocaleMutex(
void);
331 #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
335 class CPL_DLL CPLLocaleC
350 class CPLThreadLocaleCPrivate;
351 class CPL_DLL CPLThreadLocaleC
360 CPLThreadLocaleCPrivate *m_private;
372 #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
376 class CPL_DLL CPLConfigOptionSetter
380 CPLConfigOptionSetter(
const char *pszKey,
const char *pszValue,
381 bool bSetOnlyIfUndefined);
382 ~CPLConfigOptionSetter();
387 bool m_bRestoreOldValue;
394 #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
400 #include <type_traits>
414 template <
typename To,
typename From>
inline To
down_cast(From *f)
417 (std::is_base_of<From,
418 typename std::remove_pointer<To>::type>::value),
419 "target type not derived from source type");
420 CPLAssert(f ==
nullptr ||
dynamic_cast<To
>(f) !=
nullptr);
421 return static_cast<To
>(f);
428 #if defined(__cplusplus) && defined(GDAL_COMPILATION)
436 template <
typename T,
typename... Args>
437 std::unique_ptr<T> make_unique(Args &&...args)
439 return std::unique_ptr<T>(
new T(std::forward<Args>(args)...));
void CPLPopFinderLocation(void)
CPLPopFinderLocation.
Definition: cpl_findfile.cpp:290
double CPLStrtodDelim(const char *, char **, char)
Converts ASCII string to floating point number using specified delimiter.
Definition: cpl_strtod.cpp:233
int CPLValidateXML(const char *pszXMLFilename, const char *pszXSDFilename, CSLConstList papszOptions)
Validate a XML file against a XML schema.
Definition: cpl_xml_validate.cpp:1061
const char * CPLReadLineL(VSILFILE *)
Simplified line reading from text file.
Definition: cpl_conv.cpp:646
const char * CPLGenerateTempFilename(const char *pszStem)
Generate temporary file name.
Definition: cpl_path.cpp:1112
void CPLLoadConfigOptionsFromFile(const char *pszFilename, int bOverrideEnvVars)
Load configuration from a given configuration file.
Definition: cpl_conv.cpp:2154
int CPLIsPowerOfTwo(unsigned int i)
Definition: cpl_conv.cpp:3341
void * CPLGetSymbol(const char *, const char *)
Fetch a function pointer from a shared library / DLL.
Definition: cplgetsymbol.cpp:87
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:868
int CPLPrintStringFill(char *, const char *, int)
Copy the string pointed to by pszSrc, NOT including the terminating ‘\0’ character,...
Definition: cpl_conv.cpp:1268
const char * CPLCleanTrailingSlash(const char *)
Remove trailing forward/backward slash from the path for UNIX/Windows resp.
Definition: cpl_path.cpp:958
int CPLGetExecPath(char *pszPathBuf, int nMaxLength)
Fetch path of executable.
Definition: cpl_getexecpath.cpp:67
const char * CPLFindFile(const char *pszClass, const char *pszBasename)
CPLFindFile.
Definition: cpl_findfile.cpp:180
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:1501
double CPLDMSToDec(const char *is)
CPLDMSToDec.
Definition: cpl_conv.cpp:2434
const char * CPLExtractRelativePath(const char *, const char *, int *)
Get relative path from directory to target file.
Definition: cpl_path.cpp:868
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
int CPLPrintUIntBig(char *, GUIntBig, int)
Print GUIntBig value into specified string buffer.
Definition: cpl_conv.cpp:1351
void * CPLCalloc(size_t, size_t)
Safe version of calloc().
Definition: cpl_conv.cpp:151
int CPLCopyFile(const char *pszNewPath, const char *pszOldPath)
Copy a file.
Definition: cpl_conv.cpp:3022
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:1762
CPLErr CPLCloseZip(void *hZip)
Close ZIP file.
Definition: cpl_conv.cpp:3437
void * CPLScanPointer(const char *, int)
Extract pointer from string.
Definition: cpl_conv.cpp:1106
void CPLPushFinderLocation(const char *)
CPLPushFinderLocation.
Definition: cpl_findfile.cpp:251
double CPLPackedDMSToDec(double)
Convert a packed DMS value (DDDMMMSSS.SS) into decimal degrees.
Definition: cpl_conv.cpp:2609
GIntBig CPLAtoGIntBig(const char *pszString)
Convert a string to a 64 bit signed integer.
Definition: cpl_conv.cpp:1012
int bLarge
Whether fp must be interpreted as VSIFILE*.
Definition: cpl_conv.h:237
void CPLDumpSharedList(FILE *)
Report open shared files.
Definition: cpl_conv.cpp:2905
CPLSharedFileInfo * CPLGetSharedList(int *)
Fetch list of open shared files.
Definition: cpl_conv.cpp:2883
const char * CPLResetExtension(const char *, const char *)
Replace the extension with the provided one.
Definition: cpl_path.cpp:442
Information on a shared file.
Definition: cpl_conv.h:233
void * CPLRealloc(void *, size_t)
Safe version of realloc().
Definition: cpl_conv.cpp:238
double CPLAtofM(const char *)
Converts ASCII string to floating point number using any numeric locale.
Definition: cpl_strtod.cpp:143
const char * CPLGetPath(const char *)
Extract directory path portion of filename.
Definition: cpl_path.cpp:150
CPLErr CPLCloseFileInZip(void *hZip)
Close current file inside ZIP file.
Definition: cpl_conv.cpp:3432
void CPLFinderClean(void)
CPLFinderClean.
Definition: cpl_findfile.cpp:133
const char * CPLGetThreadLocalConfigOption(const char *, const char *)
Same as CPLGetConfigOption() but only with options set with CPLSetThreadLocalConfigOption()
Definition: cpl_conv.cpp:1776
const char * CPLDefaultFindFile(const char *pszClass, const char *pszBasename)
CPLDefaultFindFile.
Definition: cpl_findfile.cpp:148
void(* CPLSetConfigOptionSubscriber)(const char *pszKey, const char *pszValue, bool bThreadLocal, void *pUserData)
Callback for CPLSubscribeToSetConfigOption()
Definition: cpl_conv.h:66
#define CPLAssert(expr)
Assert on an expression.
Definition: cpl_error.h:213
GIntBig CPLAtoGIntBigEx(const char *pszString, int bWarn, int *pbOverflow)
Convert a string to a 64 bit signed integer.
Definition: cpl_conv.cpp:1058
#define CPL_C_START
Macro to start a block of C symbols.
Definition: cpl_port.h:306
FILE * CPLOpenShared(const char *, const char *, int)
Open a shared file handle.
Definition: cpl_conv.cpp:2720
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
const char * CPLGetGlobalConfigOption(const char *, const char *)
Same as CPLGetConfigOption() but excludes environment variables and options set with CPLSetThreadLoca...
Definition: cpl_conv.cpp:1807
int CPLCheckForFile(char *pszFilename, char **papszSiblingList)
Check for file existence.
Definition: cpl_conv.cpp:3376
char * CPLGetCurrentDir(void)
Get the current working directory name.
Definition: cpl_path.cpp:421
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:377
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1178
void CPLCloseShared(FILE *)
Close shared file.
Definition: cpl_conv.cpp:2792
const char * CPLGetDirname(const char *)
Extract directory path portion of filename.
Definition: cpl_path.cpp:204
unsigned long long GUIntBig
Large unsigned integer type (generally 64-bit unsigned integer type).
Definition: cpl_port.h:229
void * CPLCreateZip(const char *pszZipFilename, char **papszOptions)
Create ZIP file.
Definition: cpl_conv.cpp:3414
const char * CPLReadLine3L(VSILFILE *, int, int *, CSLConstList)
Simplified line reading from text file.
Definition: cpl_conv.cpp:699
char ** CPLGetConfigOptions(void)
Return the list of configuration options as KEY=VALUE pairs.
Definition: cpl_conv.cpp:1736
#define CPL_C_END
Macro to end a block of C symbols.
Definition: cpl_port.h:310
int CPLPrintString(char *, const char *, int)
Copy the string pointed to by pszSrc, NOT including the terminating ‘\0’ character,...
Definition: cpl_conv.cpp:1224
int CPLIsFilenameRelative(const char *pszFilename)
Is filename relative or absolute?
Definition: cpl_path.cpp:826
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:551
const char * CPLProjectRelativeFilename(const char *pszProjectDir, const char *pszSecondaryFilename)
Find a file relative to a project file.
Definition: cpl_path.cpp:761
void * CPLMalloc(size_t)
Safe version of malloc().
Definition: cpl_conv.cpp:181
const char * CPLLaunderForFilename(const char *pszName, const char *pszOutputPath)
Launder a string to be compatible of a filename.
Definition: cpl_path.cpp:1206
const char *(* CPLFileFinder)(const char *, const char *)
Callback for CPLPushFileFinder.
Definition: cpl_conv.h:211
Virtual file handle.
Definition: cpl_vsi_virtual.h:62
const char * CPLFormCIFilename(const char *pszPath, const char *pszBasename, const char *pszExtension)
Case insensitive file searching, returning full path.
Definition: cpl_path.cpp:669
int CPLMoveFile(const char *pszNewPath, const char *pszOldPath)
Move a file.
Definition: cpl_conv.cpp:3110
float CPLStrtof(const char *, char **)
Converts ASCII string to floating point number.
Definition: cpl_strtod.cpp:492
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:2063
char ** CPLCorrespondingPaths(const char *pszOldFilename, const char *pszNewFilename, char **papszFileList)
Identify corresponding paths.
Definition: cpl_path.cpp:1008
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:956
void CPLSetConfigOption(const char *, const char *)
Set a configuration option for GDAL/OGR use.
Definition: cpl_conv.cpp:1938
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:414
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:2519
int CPLUnlinkTree(const char *)
Recursively unlink a directory.
Definition: cpl_conv.cpp:2939
int CPLCopyTree(const char *pszNewPath, const char *pszOldPath)
Recursively copy a tree.
Definition: cpl_conv.cpp:3035
int CPLSubscribeToSetConfigOption(CPLSetConfigOptionSubscriber pfnCallback, void *pUserData)
Install a callback that will be notified of calls to CPLSetConfigOption()/ CPLSetThreadLocalConfigOpt...
Definition: cpl_conv.cpp:1839
char * pszAccess
Access mode.
Definition: cpl_conv.h:239
CPLErr CPLWriteFileInZip(void *hZip, const void *pBuffer, int nBufferSize)
Write in current file inside a ZIP file.
Definition: cpl_conv.cpp:3427
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:226
void CPLLoadConfigOptionsFromPredefinedFiles(void)
Load configuration from a set of predefined files.
Definition: cpl_conv.cpp:2350
char * CPLsetlocale(int category, const char *locale)
Prevents parallel executions of setlocale().
Definition: cpl_conv.cpp:3315
int CPLSymlink(const char *pszOldPath, const char *pszNewPath, CSLConstList papszOptions)
Create a symbolic link.
Definition: cpl_conv.cpp:3134
void CPLUnsubscribeToSetConfigOption(int nSubscriberId)
Remove a subscriber installed with CPLSubscribeToSetConfigOption()
Definition: cpl_conv.cpp:1871
int CPLStat(const char *, VSIStatBuf *)
Same as VSIStat() except it works on "C:" as if it were "C:\".
Definition: cpl_conv.cpp:2385
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition: cpl_port.h:976
const char * CPLExpandTilde(const char *pszFilename)
Expands ~/ at start of filename.
Definition: cpl_path.cpp:1153
double CPLDecToPackedDMS(double dfDec)
Convert decimal degrees into packed DMS value (DDDMMMSSS.SS).
Definition: cpl_conv.cpp:2643
const char * CPLReadLine(FILE *)
Simplified line reading from text file.
Definition: cpl_conv.cpp:578
int CPLPrintDouble(char *, const char *, double, const char *)
Print double value into specified string buffer.
Definition: cpl_conv.cpp:1443
char * pszFilename
Filename.
Definition: cpl_conv.h:238
CPLErr
Error category.
Definition: cpl_error.h:52
int CPLPrintPointer(char *, void *, int)
Print pointer value into specified string buffer.
Definition: cpl_conv.cpp:1399
char * CPLStrdup(const char *)
Safe version of strdup() function.
Definition: cpl_conv.cpp:306
double CPLAtof(const char *)
Converts ASCII string to floating point number.
Definition: cpl_strtod.cpp:118
CPLFileFinder CPLPopFileFinder(void)
CPLPopFileFinder.
Definition: cpl_findfile.cpp:240
GUIntBig CPLScanUIntBig(const char *, int)
Extract big integer from string.
Definition: cpl_conv.cpp:986
const char * CPLReadLine2L(VSILFILE *, int, CSLConstList)
Simplified line reading from text file.
Definition: cpl_conv.cpp:671
CPLErr CPLCreateFileInZip(void *hZip, const char *pszFilename, char **papszOptions)
Create a file in a ZIP file.
Definition: cpl_conv.cpp:3422
const char * CPLGetHomeDir(void)
Return the path to the home directory.
Definition: cpl_path.cpp:1181
int CPLPrintInt32(char *, GInt32, int)
Print GInt32 value into specified string buffer.
Definition: cpl_conv.cpp:1312
float CPLStrtofDelim(const char *, char **, char)
Converts ASCII string to floating point number using specified delimiter.
Definition: cpl_strtod.cpp:448
void CPLPushFileFinder(CPLFileFinder pfnFinder)
CPLPushFileFinder.
Definition: cpl_findfile.cpp:203
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:928
char ** CPLGetThreadLocalConfigOptions(void)
Return the list of thread local configuration options as KEY=VALUE pairs.
Definition: cpl_conv.cpp:2033
double CPLScanDouble(const char *, int)
Extract double from string.
Definition: cpl_conv.cpp:1172
const char * CPLGetBasename(const char *)
Extract basename (non-directory, non-extension) portion of filename.
Definition: cpl_path.cpp:287
void CPLStringToComplex(const char *pszString, double *pdfReal, double *pdfImag)
Fetch the real and imaginary part of a serialized complex number.
Definition: cpl_conv.cpp:2660
double CPLAtofDelim(const char *, char)
Converts ASCII string to floating point number.
Definition: cpl_strtod.cpp:74
int GInt32
Int32 type.
Definition: cpl_port.h:186
const char * CPLGetExtension(const char *)
Extract filename extension from full filename.
Definition: cpl_path.cpp:341
#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
const char * CPLGetFilename(const char *)
Extract non-directory portion of filename.
Definition: cpl_path.cpp:255
#define CPL_RETURNS_NONNULL
Qualifier for a function that does not return NULL.
Definition: cpl_port.h:1014
int nRefCount
Reference counter.
Definition: cpl_conv.h:236
FILE * fp
File pointer.
Definition: cpl_conv.h:235
double CPLStrtod(const char *, char **)
Converts ASCII string to floating point number.
Definition: cpl_strtod.cpp:422
const char * CPLGetConfigOption(const char *, const char *)
Get the value of a configuration option.
Definition: cpl_conv.cpp:1688
void CPLSetThreadLocalConfigOption(const char *pszKey, const char *pszValue)
Set a configuration option for GDAL/OGR use.
Definition: cpl_conv.cpp:1992
char * CPLStrlwr(char *)
Convert each characters of the string to lower case.
Definition: cpl_conv.cpp:332
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