OGR
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)
 
 CPLString (const std::string &oStr)
 
 CPLString (const char *pszStr)
 
 CPLString (const char *pszStr, size_t n)
 
 operator const char * (void) const
 
char & operator[] (std::string::size_type i)
 
const char & operator[] (std::string::size_type i) const
 
char & operator[] (int i)
 
const char & operator[] (int i) const
 
const char & back () const
 
char & back ()
 
void Clear ()
 
void Seize (char *pszValue)
 
CPLStringPrintf (const char *pszFormat,...)
 
CPLStringvPrintf (const char *pszFormat, va_list args)
 
CPLStringFormatC (double dfValue, const char *pszFormat=NULL)
 
CPLStringTrim ()
 
CPLStringRecode (const char *pszSrcEncoding, const char *pszDstEncoding)
 
CPLStringreplaceAll (const std::string &osBefore, const std::string &osAfter)
 
CPLStringreplaceAll (const std::string &osBefore, char chAfter)
 
CPLStringreplaceAll (char chBefore, const std::string &osAfter)
 
CPLStringreplaceAll (char chBefore, char chAfter)
 
size_t ifind (const std::string &str, size_t pos=0) const
 
size_t ifind (const char *s, size_t pos=0) const
 
CPLStringtoupper (void)
 
CPLStringtolower (void)
 

Detailed Description

Convenient string class based on std::string.

Constructor & Destructor Documentation

◆ CPLString() [1/4]

CPLString::CPLString ( void  )
inline

Constructor

◆ CPLString() [2/4]

CPLString::CPLString ( const std::string &  oStr)
inline

Constructor

◆ CPLString() [3/4]

CPLString::CPLString ( const char *  pszStr)
inline

Constructor

◆ CPLString() [4/4]

CPLString::CPLString ( const char *  pszStr,
size_t  n 
)
inline

Constructor

Member Function Documentation

◆ back() [1/2]

const char& CPLString::back ( ) const
inline

Return last character (undefined behaviour if string is empty)

Referenced by CPLURLAddKVP().

◆ back() [2/2]

char& CPLString::back ( )
inline

Return last character (undefined behaviour if string is empty)

◆ Clear()

void CPLString::Clear ( )
inline

Clear the string

◆ FormatC()

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.

References CPLsnprintf().

◆ ifind() [1/2]

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

Referenced by CPLURLAddKVP(), and CPLURLGetValue().

◆ ifind() [2/2]

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

References EQUALN, and tolower().

◆ operator const char *()

CPLString::operator const char * ( void  ) const
inline

Return string as zero terminated character array

◆ operator[]() [1/4]

char& CPLString::operator[] ( std::string::size_type  i)
inline

Return character at specified index

◆ operator[]() [2/4]

const char& CPLString::operator[] ( std::string::size_type  i) const
inline

Return character at specified index

◆ operator[]() [3/4]

char& CPLString::operator[] ( int  i)
inline

Return character at specified index

◆ operator[]() [4/4]

const char& CPLString::operator[] ( int  i) const
inline

Return character at specified index

◆ Printf()

CPLString & CPLString::Printf ( const char *  pszFormat,
  ... 
)

◆ Recode()

CPLString & CPLString::Recode ( const char *  pszSrcEncoding,
const char *  pszDstEncoding 
)

Recode the string

References CPL_ENC_UTF8, CPLFree, and CPLRecode().

◆ replaceAll() [1/4]

CPLString & CPLString::replaceAll ( const std::string &  osBefore,
const std::string &  osAfter 
)

Replace all occurrences of osBefore with osAfter.

Referenced by replaceAll().

◆ replaceAll() [2/4]

CPLString & CPLString::replaceAll ( const std::string &  osBefore,
char  chAfter 
)

Replace all occurrences of osBefore with chAfter.

References replaceAll().

◆ replaceAll() [3/4]

CPLString & CPLString::replaceAll ( char  chBefore,
const std::string &  osAfter 
)

Replace all occurrences of chBefore with osAfter.

References replaceAll().

◆ replaceAll() [4/4]

CPLString & CPLString::replaceAll ( char  chBefore,
char  chAfter 
)

Replace all occurrences of chBefore with chAfter.

References replaceAll().

◆ Seize()

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.

References CPLFree.

Referenced by GOA2GetAuthorizationURL(), and GOA2GetRefreshToken().

◆ tolower()

CPLString & CPLString::tolower ( void  )

Convert to lower case in place.

Referenced by ifind().

◆ toupper()

CPLString & CPLString::toupper ( void  )

Convert to upper case in place.

◆ Trim()

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.

◆ vPrintf()

CPLString & CPLString::vPrintf ( const char *  pszFormat,
va_list  args 
)

Assign the content of the string using vsprintf()

References CPLError(), CPLMalloc(), and CPLvsnprintf().

Referenced by CPLOPrintf(), CPLOvPrintf(), CPLVASPrintf(), CSLAppendPrintf(), Printf(), and VSIFPrintfL().


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

Generated for GDAL by doxygen 1.8.14.