GDAL
Public Member Functions | List of all members
CPLString Class Reference

Convenient string class based on std::string. More...

#include <cpl_string.h>

Inheritance diagram for CPLString:

Public Member Functions

 CPLString (void)
 Constructor.
 
 CPLString (const std::string &oStr)
 Constructor.
 
 CPLString (const char *pszStr)
 Constructor.
 
 operator const char * (void) const
 Return string as zero terminated character array.
 
char & operator[] (std::string::size_type i)
 Return character at specified index.
 
const char & operator[] (std::string::size_type i) const
 Return character at specified index.
 
char & operator[] (int i)
 Return character at specified index.
 
const char & operator[] (int i) const
 Return character at specified index.
 
const char & back () const
 Return last character (undefined behaviour if string is empty)
 
char & back ()
 Return last character (undefined behaviour if string is empty)
 
void Clear ()
 Clear the string.
 
void Seize (char *pszValue)
 Assign specified string and take ownership of it (assumed to be allocated with CPLMalloc()). More...
 
CPLStringPrintf (const char *pszFormat,...)
 Assign the content of the string using sprintf()
 
CPLStringvPrintf (const char *pszFormat, va_list args)
 Assign the content of the string using vsprintf()
 
CPLStringFormatC (double dfValue, const char *pszFormat=NULL)
 Format double in C locale. More...
 
CPLStringTrim ()
 Trim white space. More...
 
CPLStringRecode (const char *pszSrcEncoding, const char *pszDstEncoding)
 Recode the string.
 
CPLStringreplaceAll (const std::string &osBefore, const std::string &osAfter)
 Replace all occurrences of osBefore with osAfter.
 
CPLStringreplaceAll (const std::string &osBefore, char chAfter)
 Replace all occurrences of osBefore with chAfter.
 
CPLStringreplaceAll (char chBefore, const std::string &osAfter)
 Replace all occurrences of chBefore with osAfter.
 
CPLStringreplaceAll (char chBefore, char chAfter)
 Replace all occurrences of chBefore with chAfter.
 
size_t ifind (const std::string &str, size_t pos=0) const
 Case insensitive find() alternative. More...
 
size_t ifind (const char *s, size_t pos=0) const
 Case insensitive find() alternative. More...
 
CPLStringtoupper (void)
 Convert to upper case in place.
 
CPLStringtolower (void)
 Convert to lower case in place.
 

Detailed Description

Convenient string class based on std::string.

Member Function Documentation

CPLString & CPLString::FormatC ( double  dfValue,
const char *  pszFormat = NULL 
)

Format double in C locale.

The passed value is formatted using the C locale (period as decimal separator) and appended to the target CPLString.

Parameters
dfValuethe value to format.
pszFormatthe sprintf() style format to use or omit for default. Note that this format string should only include one substitution argument and it must be for a double (f or g).
Returns
a reference to the CPLString.
size_t CPLString::ifind ( const std::string &  str,
size_t  pos = 0 
) const

Case insensitive find() alternative.

Parameters
strsubstring to find.
posoffset in the string at which the search starts.
Returns
the position of substring in the string or std::string::npos if not found.
Since
GDAL 1.9.0
size_t CPLString::ifind ( const char *  s,
size_t  nPos = 0 
) const

Case insensitive find() alternative.

Parameters
ssubstring to find.
nPosoffset in the string at which the search starts.
Returns
the position of the substring in the string or std::string::npos if not found.
Since
GDAL 1.9.0
void CPLString::Seize ( char *  pszValue)
inline

Assign specified string and take ownership of it (assumed to be allocated with CPLMalloc()).

NULL can be safely passed to clear the string.

CPLString & CPLString::Trim ( )

Trim white space.

Trims white space off the let and right of the string. White space is any of a space, a tab, a newline ('\n') or a carriage control ('\r').

Returns
a reference to the CPLString.

The documentation for this class was generated from the following files:

Generated for GDAL by doxygen 1.8.8.