EVOLUTION-MANAGER
Edit File: cpl__string_8h.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.5"/> <title>SDTS_AL: cpl_string.h File Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">SDTS_AL </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.5 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="dir_651562d8bf6cfd3e81eff5b570d7df50.html">port</a></li> </ul> </div> </div><!-- top --> <div class="header"> <div class="summary"> <a href="#func-members">Functions</a> </div> <div class="headertitle"> <div class="title">cpl_string.h File Reference</div> </div> </div><!--header--> <div class="contents"> <div class="textblock"><code>#include "<a class="el" href="cpl__vsi_8h_source.html">cpl_vsi.h</a>"</code><br/> <code>#include "<a class="el" href="cpl__error_8h_source.html">cpl_error.h</a>"</code><br/> <code>#include "<a class="el" href="cpl__conv_8h_source.html">cpl_conv.h</a>"</code><br/> </div> <p><a href="cpl__string_8h_source.html">Go to the source code of this file.</a></p> <table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a> Functions</h2></td></tr> <tr class="memitem:a96ed5f2caeffc83ca3ada153970ef282"><td class="memItemLeft" align="right" valign="top">int CPL_DLL </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#a96ed5f2caeffc83ca3ada153970ef282">CSLCount</a> (char **papszStrList)</td></tr> <tr class="separator:a96ed5f2caeffc83ca3ada153970ef282"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ace6799a8ba4bbb58318f17aecd9f55dd"><td class="memItemLeft" align="right" valign="top">void CPL_DLL CPL_STDCALL </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#ace6799a8ba4bbb58318f17aecd9f55dd">CSLDestroy</a> (char **papszStrList)</td></tr> <tr class="separator:ace6799a8ba4bbb58318f17aecd9f55dd"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:aee4f268f0d07b8f93f0a28609d36916b"><td class="memItemLeft" align="right" valign="top">char CPL_DLL ** </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#aee4f268f0d07b8f93f0a28609d36916b">CSLDuplicate</a> (char **papszStrList) CPL_WARN_UNUSED_RESULT</td></tr> <tr class="separator:aee4f268f0d07b8f93f0a28609d36916b"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a086854aa18fc7bbad86d64af501a4927"><td class="memItemLeft" align="right" valign="top">char CPL_DLL ** </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#a086854aa18fc7bbad86d64af501a4927">CSLMerge</a> (char **papszOrig, char **papszOverride) CPL_WARN_UNUSED_RESULT</td></tr> <tr class="memdesc:a086854aa18fc7bbad86d64af501a4927"><td class="mdescLeft"> </td><td class="mdescRight">Merge two lists. <a href="#a086854aa18fc7bbad86d64af501a4927">More...</a><br/></td></tr> <tr class="separator:a086854aa18fc7bbad86d64af501a4927"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ae43588e11ec022600694aa71c64abeee"><td class="memItemLeft" align="right" valign="top">char CPL_DLL ** </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#ae43588e11ec022600694aa71c64abeee">CSLTokenizeString2</a> (const char *pszString, const char *pszDelimeter, int nCSLTFlags) CPL_WARN_UNUSED_RESULT</td></tr> <tr class="separator:ae43588e11ec022600694aa71c64abeee"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:af7e9cd880b5891a50db53c7c8ea6b2cf"><td class="memItemLeft" align="right" valign="top">char CPL_DLL ** </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#af7e9cd880b5891a50db53c7c8ea6b2cf">CSLLoad</a> (const char *pszFname) CPL_WARN_UNUSED_RESULT</td></tr> <tr class="separator:af7e9cd880b5891a50db53c7c8ea6b2cf"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a78b15b98755ff10f2f8f239ddff9ac66"><td class="memItemLeft" align="right" valign="top">char CPL_DLL ** </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#a78b15b98755ff10f2f8f239ddff9ac66">CSLLoad2</a> (const char *pszFname, int nMaxLines, int nMaxCols, char **papszOptions) CPL_WARN_UNUSED_RESULT</td></tr> <tr class="separator:a78b15b98755ff10f2f8f239ddff9ac66"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ab8d50a9c6645f8cd176febb7a4ea41ce"><td class="memItemLeft" align="right" valign="top">int CPL_DLL </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#ab8d50a9c6645f8cd176febb7a4ea41ce">CSLFindString</a> (char **, const char *)</td></tr> <tr class="separator:ab8d50a9c6645f8cd176febb7a4ea41ce"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a1b1b6eda40b063071fc1de336ae1f19a"><td class="memItemLeft" align="right" valign="top">int CPL_DLL </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#a1b1b6eda40b063071fc1de336ae1f19a">CSLPartialFindString</a> (char **papszHaystack, const char *pszNeedle)</td></tr> <tr class="separator:a1b1b6eda40b063071fc1de336ae1f19a"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ae9340238e2dfe853b82b7e35be8202cb"><td class="memItemLeft" align="right" valign="top">int CPL_DLL </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#ae9340238e2dfe853b82b7e35be8202cb">CSLFindName</a> (char **papszStrList, const char *pszName)</td></tr> <tr class="separator:ae9340238e2dfe853b82b7e35be8202cb"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:affaa0f415488e88b1f729fda33eae311"><td class="memItemLeft" align="right" valign="top">int CPL_DLL </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#affaa0f415488e88b1f729fda33eae311">CSLTestBoolean</a> (const char *pszValue)</td></tr> <tr class="separator:affaa0f415488e88b1f729fda33eae311"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a9b0956ead51f6795ee28dbdc8e1121fd"><td class="memItemLeft" align="right" valign="top">const char CPL_DLL * </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#a9b0956ead51f6795ee28dbdc8e1121fd">CPLParseNameValue</a> (const char *pszNameValue, char **ppszKey)</td></tr> <tr class="separator:a9b0956ead51f6795ee28dbdc8e1121fd"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a7cace9e31474df1e83493f5d8d7b1019"><td class="memItemLeft" align="right" valign="top">char CPL_DLL ** </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#a7cace9e31474df1e83493f5d8d7b1019">CSLSetNameValue</a> (char **papszStrList, const char *pszName, const char *pszValue) CPL_WARN_UNUSED_RESULT</td></tr> <tr class="separator:a7cace9e31474df1e83493f5d8d7b1019"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a2e7670421e44ece23a49af78556eb96d"><td class="memItemLeft" align="right" valign="top">void CPL_DLL </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#a2e7670421e44ece23a49af78556eb96d">CSLSetNameValueSeparator</a> (char **papszStrList, const char *pszSeparator)</td></tr> <tr class="separator:a2e7670421e44ece23a49af78556eb96d"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ab74e751ef08df91189b4c3f6845760eb"><td class="memItemLeft" align="right" valign="top">char CPL_DLL * </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#ab74e751ef08df91189b4c3f6845760eb">CPLEscapeString</a> (const char *pszString, int nLength, int nScheme) CPL_WARN_UNUSED_RESULT</td></tr> <tr class="separator:ab74e751ef08df91189b4c3f6845760eb"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a707ed9e3b3350b5d995b2206e7ea3235"><td class="memItemLeft" align="right" valign="top">char CPL_DLL * </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#a707ed9e3b3350b5d995b2206e7ea3235">CPLUnescapeString</a> (const char *pszString, int *pnLength, int nScheme) CPL_WARN_UNUSED_RESULT</td></tr> <tr class="separator:a707ed9e3b3350b5d995b2206e7ea3235"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a12e0997a9cc487d750a805628a9d5dad"><td class="memItemLeft" align="right" valign="top">char CPL_DLL * </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#a12e0997a9cc487d750a805628a9d5dad">CPLBinaryToHex</a> (int nBytes, const GByte *pabyData) CPL_WARN_UNUSED_RESULT</td></tr> <tr class="separator:a12e0997a9cc487d750a805628a9d5dad"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ac27d8320ca1cf3fe684234c9161281ad"><td class="memItemLeft" align="right" valign="top">CPLValueType CPL_DLL </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#ac27d8320ca1cf3fe684234c9161281ad">CPLGetValueType</a> (const char *pszValue)</td></tr> <tr class="separator:ac27d8320ca1cf3fe684234c9161281ad"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a23730792907209d78ed81a6d218e371a"><td class="memItemLeft" align="right" valign="top">size_t CPL_DLL </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#a23730792907209d78ed81a6d218e371a">CPLStrlcpy</a> (char *pszDest, const char *pszSrc, size_t nDestSize)</td></tr> <tr class="separator:a23730792907209d78ed81a6d218e371a"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a068017b75019d39ea9d74ed55218d40d"><td class="memItemLeft" align="right" valign="top">size_t CPL_DLL </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#a068017b75019d39ea9d74ed55218d40d">CPLStrlcat</a> (char *pszDest, const char *pszSrc, size_t nDestSize)</td></tr> <tr class="separator:a068017b75019d39ea9d74ed55218d40d"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a0ac300fe626b6e9132fcac05f2d428f2"><td class="memItemLeft" align="right" valign="top">size_t CPL_DLL </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#a0ac300fe626b6e9132fcac05f2d428f2">CPLStrnlen</a> (const char *pszStr, size_t nMaxLen)</td></tr> <tr class="separator:a0ac300fe626b6e9132fcac05f2d428f2"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:af09869457bd5c549af82b425a03f3d8e"><td class="memItemLeft" align="right" valign="top">int CPL_DLL </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#af09869457bd5c549af82b425a03f3d8e">CPLEncodingCharSize</a> (const char *pszEncoding)</td></tr> <tr class="separator:af09869457bd5c549af82b425a03f3d8e"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a690cfe69b41b7d2a12b0d9f725413bcd"><td class="memItemLeft" align="right" valign="top">char CPL_DLL * </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#a690cfe69b41b7d2a12b0d9f725413bcd">CPLRecode</a> (const char *pszSource, const char *pszSrcEncoding, const char *pszDstEncoding) CPL_WARN_UNUSED_RESULT</td></tr> <tr class="separator:a690cfe69b41b7d2a12b0d9f725413bcd"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a0cd9738c76b969cffc33548761dd9f1d"><td class="memItemLeft" align="right" valign="top">char CPL_DLL * </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#a0cd9738c76b969cffc33548761dd9f1d">CPLRecodeFromWChar</a> (const wchar_t *pwszSource, const char *pszSrcEncoding, const char *pszDstEncoding) CPL_WARN_UNUSED_RESULT</td></tr> <tr class="separator:a0cd9738c76b969cffc33548761dd9f1d"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a46bda3869d6db85cf19400913855a91d"><td class="memItemLeft" align="right" valign="top">wchar_t CPL_DLL * </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#a46bda3869d6db85cf19400913855a91d">CPLRecodeToWChar</a> (const char *pszSource, const char *pszSrcEncoding, const char *pszDstEncoding) CPL_WARN_UNUSED_RESULT</td></tr> <tr class="separator:a46bda3869d6db85cf19400913855a91d"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a19d265ba589314775243b478f6003971"><td class="memItemLeft" align="right" valign="top">int CPL_DLL </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#a19d265ba589314775243b478f6003971">CPLIsUTF8</a> (const char *pabyData, int nLen)</td></tr> <tr class="separator:a19d265ba589314775243b478f6003971"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ae91c2895ab6061cf43ea68db745e94be"><td class="memItemLeft" align="right" valign="top">char CPL_DLL * </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#ae91c2895ab6061cf43ea68db745e94be">CPLForceToASCII</a> (const char *pabyData, int nLen, char chReplacementChar) CPL_WARN_UNUSED_RESULT</td></tr> <tr class="separator:ae91c2895ab6061cf43ea68db745e94be"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ab283c4518e6210d5cc7294e3c5cfaf33"><td class="memItemLeft" align="right" valign="top">int CPL_DLL </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__string_8h.html#ab283c4518e6210d5cc7294e3c5cfaf33">CPLStrlenUTF8</a> (const char *pszUTF8Str)</td></tr> <tr class="separator:ab283c4518e6210d5cc7294e3c5cfaf33"><td class="memSeparator" colspan="2"> </td></tr> </table> <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> <div class="textblock"><p>Various convenience functions for working with strings and string lists.</p> <p>A StringList is just an array of strings with the last pointer being NULL. An empty StringList may be either a NULL pointer, or a pointer to a pointer memory location with a NULL value.</p> <p>A common convention for StringLists is to use them to store name/value lists. In this case the contents are treated like a dictionary of name/value pairs. The actual data is formatted with each string having the format "<name>:<value>" (though "=" is also an acceptable separator). A number of the functions in the file operate on name/value style string lists (such as <a class="el" href="cpl__string_8h.html#a7cace9e31474df1e83493f5d8d7b1019">CSLSetNameValue()</a>, and CSLFetchNameValue()).</p> <p>To some extent the CPLStringList C++ class can be used to abstract managing string lists a bit but still be able to return them from C functions. </p> </div><h2 class="groupheader">Function Documentation</h2> <a class="anchor" id="a12e0997a9cc487d750a805628a9d5dad"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">char CPL_DLL* CPLBinaryToHex </td> <td>(</td> <td class="paramtype">int </td> <td class="paramname"><em>nBytes</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const GByte * </td> <td class="paramname"><em>pabyData</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Binary to hexadecimal translation.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">nBytes</td><td>number of bytes of binary data in pabyData. </td></tr> <tr><td class="paramname">pabyData</td><td>array of data bytes to translate.</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>hexadecimal translation, zero terminated. Free with CPLFree(). </dd></dl> </div> </div> <a class="anchor" id="af09869457bd5c549af82b425a03f3d8e"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int CPL_DLL CPLEncodingCharSize </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszEncoding</em></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p>Return bytes per character for encoding.</p> <p>This function returns the size in bytes of the smallest character in this encoding. For fixed width encodings (ASCII, UCS-2, UCS-4) this is straight forward. For encodings like UTF8 and UTF16 which represent some characters as a sequence of atomic character sizes the function still returns the atomic character size (1 for UTF8, 2 for UTF16).</p> <p>This function will return the correct value for well known encodings with corresponding CPL_ENC_ values. It may not return the correct value for other encodings even if they are supported by the underlying iconv or windows transliteration services. Hopefully it will improve over time.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">pszEncoding</td><td>the name of the encoding.</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>the size of a minimal character in bytes or -1 if the size is unknown. </dd></dl> </div> </div> <a class="anchor" id="ab74e751ef08df91189b4c3f6845760eb"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">char CPL_DLL* CPLEscapeString </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszInput</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int </td> <td class="paramname"><em>nLength</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int </td> <td class="paramname"><em>nScheme</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Apply escaping to string to preserve special characters.</p> <p>This function will "escape" a variety of special characters to make the string suitable to embed within a string constant or to write within a text stream but in a form that can be reconstitued to it's original form. The escaping will even preserve zero bytes allowing preservation of raw binary data.</p> <p>CPLES_BackslashQuotable(0): This scheme turns a binary string into a form suitable to be placed within double quotes as a string constant. The backslash, quote, '\0' and newline characters are all escaped in the usual C style.</p> <p>CPLES_XML(1): This scheme converts the '<', '>', '"' and '&' characters into their XML/HTML equivelent (<, >, " and &) making a string safe to embed as CDATA within an XML element. The '\0' is not escaped and should not be included in the input.</p> <p>CPLES_URL(2): Everything except alphanumerics and the underscore are converted to a percent followed by a two digit hex encoding of the character (leading zero supplied if needed). This is the mechanism used for encoding values to be passed in URLs.</p> <p>CPLES_SQL(3): All single quotes are replaced with two single quotes. Suitable for use when constructing literal values for SQL commands where the literal will be enclosed in single quotes.</p> <p>CPLES_CSV(4): If the values contains commas, semicolons, tabs, double quotes, or newlines it placed in double quotes, and double quotes in the value are doubled. Suitable for use when constructing field values for .csv files. Note that <a class="el" href="cpl__string_8h.html#a707ed9e3b3350b5d995b2206e7ea3235">CPLUnescapeString()</a> currently does not support this format, only <a class="el" href="cpl__string_8h.html#ab74e751ef08df91189b4c3f6845760eb">CPLEscapeString()</a>. See cpl_csv.cpp for csv parsing support.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">pszInput</td><td>the string to escape. </td></tr> <tr><td class="paramname">nLength</td><td>The number of bytes of data to preserve. If this is -1 the strlen(pszString) function will be used to compute the length. </td></tr> <tr><td class="paramname">nScheme</td><td>the encoding scheme to use.</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>an escaped, zero terminated string that should be freed with CPLFree() when no longer needed. </dd></dl> </div> </div> <a class="anchor" id="ae91c2895ab6061cf43ea68db745e94be"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">char CPL_DLL* CPLForceToASCII </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>pabyData</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int </td> <td class="paramname"><em>nLen</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">char </td> <td class="paramname"><em>chReplacementChar</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Return a new string that is made only of ASCII characters. If non-ASCII characters are found in the input string, they will be replaced by the provided replacement character.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">pabyData</td><td>input string to test </td></tr> <tr><td class="paramname">nLen</td><td>length of the input string, or -1 if the function must compute the string length. In which case it must be null terminated. </td></tr> <tr><td class="paramname">chReplacementChar</td><td>character which will be used when the input stream contains a non ASCII character. Must be valid ASCII !</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>a new string that must be freed with CPLFree().</dd></dl> <dl class="section since"><dt>Since</dt><dd>GDAL 1.7.0 </dd></dl> </div> </div> <a class="anchor" id="ac27d8320ca1cf3fe684234c9161281ad"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">CPLValueType CPL_DLL CPLGetValueType </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszValue</em></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p>Detect the type of the value contained in a string, whether it is a real, an integer or a string Leading and trailing spaces are skipped in the analysis.</p> <p>Note: in the context of this function, integer must be understood in a broad sense. It does not mean that the value can fit into a 32 bit integer for example. It might be larger.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">pszValue</td><td>the string to analyze</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>returns the type of the value contained in the string. </dd></dl> </div> </div> <a class="anchor" id="a19d265ba589314775243b478f6003971"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int CPL_DLL CPLIsUTF8 </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>pabyData</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int </td> <td class="paramname"><em>nLen</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Test if a string is encoded as UTF-8.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">pabyData</td><td>input string to test </td></tr> <tr><td class="paramname">nLen</td><td>length of the input string, or -1 if the function must compute the string length. In which case it must be null terminated. </td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>TRUE if the string is encoded as UTF-8. FALSE otherwise</dd></dl> <dl class="section since"><dt>Since</dt><dd>GDAL 1.7.0 </dd></dl> </div> </div> <a class="anchor" id="a9b0956ead51f6795ee28dbdc8e1121fd"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">const char CPL_DLL* CPLParseNameValue </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszNameValue</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">char ** </td> <td class="paramname"><em>ppszKey</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Parse NAME=VALUE string into name and value components.</p> <p>Note that if ppszKey is non-NULL, the key (or name) portion will be allocated using VSIMalloc(), and returned in that pointer. It is the applications responsibility to free this string, but the application should not modify or free the returned value portion.</p> <p>This function also support "NAME:VALUE" strings and will strip white space from around the delimeter when forming name and value strings.</p> <p>Eventually CSLFetchNameValue() and friends may be modified to use <a class="el" href="cpl__string_8h.html#a9b0956ead51f6795ee28dbdc8e1121fd">CPLParseNameValue()</a>.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">pszNameValue</td><td>string in "NAME=VALUE" format. </td></tr> <tr><td class="paramname">ppszKey</td><td>optional pointer though which to return the name portion. </td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>the value portion (pointing into original string). </dd></dl> </div> </div> <a class="anchor" id="a690cfe69b41b7d2a12b0d9f725413bcd"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">char CPL_DLL* CPLRecode </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszSource</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszSrcEncoding</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszDstEncoding</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Convert a string from a source encoding to a destination encoding.</p> <p>The only guaranteed supported encodings are CPL_ENC_UTF8, CPL_ENC_ASCII and CPL_ENC_ISO8859_1. Currently, the following conversions are supported : </p> <ul> <li> CPL_ENC_ASCII -> CPL_ENC_UTF8 or CPL_ENC_ISO8859_1 (no conversion in fact) </li> <li> CPL_ENC_ISO8859_1 -> CPL_ENC_UTF8 </li> <li> CPL_ENC_UTF8 -> CPL_ENC_ISO8859_1 </li> </ul> <p>If an error occurs an error may, or may not be posted with CPLError().</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">pszSource</td><td>a NULL terminated string. </td></tr> <tr><td class="paramname">pszSrcEncoding</td><td>the source encoding. </td></tr> <tr><td class="paramname">pszDstEncoding</td><td>the destination encoding.</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>a NULL terminated string which should be freed with CPLFree().</dd></dl> <dl class="section since"><dt>Since</dt><dd>GDAL 1.6.0 </dd></dl> </div> </div> <a class="anchor" id="a0cd9738c76b969cffc33548761dd9f1d"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">char CPL_DLL* CPLRecodeFromWChar </td> <td>(</td> <td class="paramtype">const wchar_t * </td> <td class="paramname"><em>pwszSource</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszSrcEncoding</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszDstEncoding</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Convert wchar_t string to UTF-8.</p> <p>Convert a wchar_t string into a multibyte utf-8 string. The only guaranteed supported source encoding is CPL_ENC_UCS2, and the only guaranteed supported destination encodings are CPL_ENC_UTF8, CPL_ENC_ASCII and CPL_ENC_ISO8859_1. In some cases (ie. using iconv()) other encodings may also be supported.</p> <p>Note that the wchar_t type varies in size on different systems. On win32 it is normally 2 bytes, and on unix 4 bytes.</p> <p>If an error occurs an error may, or may not be posted with CPLError().</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">pwszSource</td><td>the source wchar_t string, terminated with a 0 wchar_t. </td></tr> <tr><td class="paramname">pszSrcEncoding</td><td>the source encoding, typically CPL_ENC_UCS2. </td></tr> <tr><td class="paramname">pszDstEncoding</td><td>the destination encoding, typically CPL_ENC_UTF8.</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>a zero terminated multi-byte string which should be freed with CPLFree(), or NULL if an error occurs.</dd></dl> <dl class="section since"><dt>Since</dt><dd>GDAL 1.6.0 </dd></dl> </div> </div> <a class="anchor" id="a46bda3869d6db85cf19400913855a91d"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">wchar_t CPL_DLL* CPLRecodeToWChar </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszSource</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszSrcEncoding</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszDstEncoding</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Convert UTF-8 string to a wchar_t string.</p> <p>Convert a 8bit, multi-byte per character input string into a wide character (wchar_t) string. The only guaranteed supported source encodings are CPL_ENC_UTF8, CPL_ENC_ASCII and CPL_ENC_ISO8869_1 (LATIN1). The only guaranteed supported destination encoding is CPL_ENC_UCS2. Other source and destination encodings may be supported depending on the underlying implementation.</p> <p>Note that the wchar_t type varies in size on different systems. On win32 it is normally 2 bytes, and on unix 4 bytes.</p> <p>If an error occurs an error may, or may not be posted with CPLError().</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">pszSource</td><td>input multi-byte character string. </td></tr> <tr><td class="paramname">pszSrcEncoding</td><td>source encoding, typically CPL_ENC_UTF8. </td></tr> <tr><td class="paramname">pszDstEncoding</td><td>destination encoding, typically CPL_ENC_UCS2.</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>the zero terminated wchar_t string (to be freed with CPLFree()) or NULL on error.</dd></dl> <dl class="section since"><dt>Since</dt><dd>GDAL 1.6.0 </dd></dl> </div> </div> <a class="anchor" id="a068017b75019d39ea9d74ed55218d40d"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">size_t CPL_DLL CPLStrlcat </td> <td>(</td> <td class="paramtype">char * </td> <td class="paramname"><em>pszDest</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszSrc</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">size_t </td> <td class="paramname"><em>nDestSize</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Appends a source string to a destination buffer.</p> <p>This function ensures that the destination buffer is always NUL terminated (provided that its length is at least 1 and that there is at least one byte free in pszDest, that is to say strlen(pszDest_before) < nDestSize)</p> <p>This function is designed to be a safer, more consistent, and less error prone replacement for strncat. Its contract is identical to libbsd's strlcat.</p> <p>Truncation can be detected by testing if the return value of CPLStrlcat is greater or equal to nDestSize.</p> <pre class="fragment">char szDest[5]; CPLStrlcpy(szDest, "ab", sizeof(szDest)); if (CPLStrlcat(szDest, "cde", sizeof(szDest)) >= sizeof(szDest)) fprintf(stderr, "truncation occured !\n"); </pre><dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">pszDest</td><td>destination buffer. Must be NUL terminated before running CPLStrlcat </td></tr> <tr><td class="paramname">pszSrc</td><td>source string. Must be NUL terminated </td></tr> <tr><td class="paramname">nDestSize</td><td>size of destination buffer (including space for the NUL terminator character)</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>the thoretical length of the destination string after concatenation (=strlen(pszDest_before) + strlen(pszSrc)). If strlen(pszDest_before) >= nDestSize, then it returns nDestSize + strlen(pszSrc)</dd></dl> <dl class="section since"><dt>Since</dt><dd>GDAL 1.7.0 </dd></dl> </div> </div> <a class="anchor" id="a23730792907209d78ed81a6d218e371a"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">size_t CPL_DLL CPLStrlcpy </td> <td>(</td> <td class="paramtype">char * </td> <td class="paramname"><em>pszDest</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszSrc</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">size_t </td> <td class="paramname"><em>nDestSize</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Copy source string to a destination buffer.</p> <p>This function ensures that the destination buffer is always NUL terminated (provided that its length is at least 1).</p> <p>This function is designed to be a safer, more consistent, and less error prone replacement for strncpy. Its contract is identical to libbsd's strlcpy.</p> <p>Truncation can be detected by testing if the return value of CPLStrlcpy is greater or equal to nDestSize.</p> <pre class="fragment">char szDest[5]; if (CPLStrlcpy(szDest, "abcde", sizeof(szDest)) >= sizeof(szDest)) fprintf(stderr, "truncation occured !\n"); </pre><dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">pszDest</td><td>destination buffer </td></tr> <tr><td class="paramname">pszSrc</td><td>source string. Must be NUL terminated </td></tr> <tr><td class="paramname">nDestSize</td><td>size of destination buffer (including space for the NUL terminator character)</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>the length of the source string (=strlen(pszSrc))</dd></dl> <dl class="section since"><dt>Since</dt><dd>GDAL 1.7.0 </dd></dl> </div> </div> <a class="anchor" id="ab283c4518e6210d5cc7294e3c5cfaf33"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int CPL_DLL CPLStrlenUTF8 </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszUTF8Str</em></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p>Return the number of UTF-8 characters of a nul-terminated string.</p> <p>This is different from strlen() which returns the number of bytes.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">pszUTF8Str</td><td>a nul-terminated UTF-8 string</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>the number of UTF-8 characters. </dd></dl> </div> </div> <a class="anchor" id="a0ac300fe626b6e9132fcac05f2d428f2"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">size_t CPL_DLL CPLStrnlen </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszStr</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">size_t </td> <td class="paramname"><em>nMaxLen</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Returns the length of a NUL terminated string by reading at most the specified number of bytes.</p> <p>The <a class="el" href="cpl__string_8h.html#a0ac300fe626b6e9132fcac05f2d428f2">CPLStrnlen()</a> function returns MIN(strlen(pszStr), nMaxLen). Only the first nMaxLen bytes of the string will be read. Usefull to test if a string contains at least nMaxLen characters without reading the full string up to the NUL terminating character.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">pszStr</td><td>a NUL terminated string </td></tr> <tr><td class="paramname">nMaxLen</td><td>maximum number of bytes to read in pszStr</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>strlen(pszStr) if the length is lesser than nMaxLen, otherwise nMaxLen if the NUL character has not been found in the first nMaxLen bytes.</dd></dl> <dl class="section since"><dt>Since</dt><dd>GDAL 1.7.0 </dd></dl> </div> </div> <a class="anchor" id="a707ed9e3b3350b5d995b2206e7ea3235"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">char CPL_DLL* CPLUnescapeString </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszInput</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int * </td> <td class="paramname"><em>pnLength</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int </td> <td class="paramname"><em>nScheme</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Unescape a string.</p> <p>This function does the opposite of <a class="el" href="cpl__string_8h.html#ab74e751ef08df91189b4c3f6845760eb">CPLEscapeString()</a>. Given a string with special values escaped according to some scheme, it will return a new copy of the string returned to it's original form.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">pszInput</td><td>the input string. This is a zero terminated string. </td></tr> <tr><td class="paramname">pnLength</td><td>location to return the length of the unescaped string, which may in some cases include embedded '\0' characters. </td></tr> <tr><td class="paramname">nScheme</td><td>the escaped scheme to undo (see <a class="el" href="cpl__string_8h.html#ab74e751ef08df91189b4c3f6845760eb">CPLEscapeString()</a> for a list).</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>a copy of the unescaped string that should be freed by the application using CPLFree() when no longer needed. </dd></dl> </div> </div> <a class="anchor" id="a96ed5f2caeffc83ca3ada153970ef282"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int CPL_DLL CSLCount </td> <td>(</td> <td class="paramtype">char ** </td> <td class="paramname"><em>papszStrList</em></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p>Return number of items in a string list.</p> <p>Returns the number of items in a string list, not counting the terminating NULL. Passing in NULL is safe, and will result in a count of zero.</p> <p>Lists are counted by iterating through them so long lists will take more time than short lists. Care should be taken to avoid using <a class="el" href="cpl__string_8h.html#a96ed5f2caeffc83ca3ada153970ef282">CSLCount()</a> as an end condition for loops as it will result in O(n^2) behavior.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">papszStrList</td><td>the string list to count.</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>the number of entries. </dd></dl> </div> </div> <a class="anchor" id="ace6799a8ba4bbb58318f17aecd9f55dd"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void CPL_DLL CPL_STDCALL CSLDestroy </td> <td>(</td> <td class="paramtype">char ** </td> <td class="paramname"><em>papszStrList</em></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p>Free string list.</p> <p>Frees the passed string list (null terminated array of strings). It is safe to pass NULL.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">papszStrList</td><td>the list to free. </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="aee4f268f0d07b8f93f0a28609d36916b"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">char CPL_DLL** CSLDuplicate </td> <td>(</td> <td class="paramtype">char ** </td> <td class="paramname"><em>papszStrList</em></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p>Clone a string list.</p> <p>Efficiently allocates a copy of a string list. The returned list is owned by the caller and should be freed with <a class="el" href="cpl__string_8h.html#ace6799a8ba4bbb58318f17aecd9f55dd">CSLDestroy()</a>.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">papszStrList</td><td>the input string list.</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>newly allocated copy. </dd></dl> </div> </div> <a class="anchor" id="ae9340238e2dfe853b82b7e35be8202cb"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int CPL_DLL CSLFindName </td> <td>(</td> <td class="paramtype">char ** </td> <td class="paramname"><em>papszStrList</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszName</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Find StringList entry with given key name.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">papszStrList</td><td>the string list to search. </td></tr> <tr><td class="paramname">pszName</td><td>the key value to look for (case insensitive).</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>-1 on failure or the list index of the first occurance matching the given key. </dd></dl> </div> </div> <a class="anchor" id="ab8d50a9c6645f8cd176febb7a4ea41ce"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int CPL_DLL CSLFindString </td> <td>(</td> <td class="paramtype">char ** </td> <td class="paramname"><em>papszList</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszTarget</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Find a string within a string list.</p> <p>Returns the index of the entry in the string list that contains the target string. The string in the string list must be a full match for the target, but the search is case insensitive.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">papszList</td><td>the string list to be searched. </td></tr> <tr><td class="paramname">pszTarget</td><td>the string to be searched for.</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>the index of the string within the list or -1 on failure. </dd></dl> </div> </div> <a class="anchor" id="af7e9cd880b5891a50db53c7c8ea6b2cf"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">char CPL_DLL** CSLLoad </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszFname</em></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p>Load a text file into a string list.</p> <p>The VSI*L API is used, so <a class="el" href="cpl__vsi_8h.html#a8cd4933a84fe46b00733ecae85dd75f4" title="Open file. ">VSIFOpenL()</a> supported objects that aren't physical files can also be accessed. Files are returned as a string list, with one item in the string list per line. End of line markers are stripped (by <a class="el" href="cpl__conv_8h.html#ab38aa2bd6fad1221d899a74ff45b33f2">CPLReadLineL()</a>).</p> <p>If reading the file fails a CPLError() will be issued and NULL returned.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">pszFname</td><td>the name of the file to read.</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>a string list with the files lines, now owned by caller. To be freed with <a class="el" href="cpl__string_8h.html#ace6799a8ba4bbb58318f17aecd9f55dd">CSLDestroy()</a> </dd></dl> </div> </div> <a class="anchor" id="a78b15b98755ff10f2f8f239ddff9ac66"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">char CPL_DLL** CSLLoad2 </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszFname</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int </td> <td class="paramname"><em>nMaxLines</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int </td> <td class="paramname"><em>nMaxCols</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">char ** </td> <td class="paramname"><em>papszOptions</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Load a text file into a string list.</p> <p>The VSI*L API is used, so <a class="el" href="cpl__vsi_8h.html#a8cd4933a84fe46b00733ecae85dd75f4" title="Open file. ">VSIFOpenL()</a> supported objects that aren't physical files can also be accessed. Files are returned as a string list, with one item in the string list per line. End of line markers are stripped (by <a class="el" href="cpl__conv_8h.html#ab38aa2bd6fad1221d899a74ff45b33f2">CPLReadLineL()</a>).</p> <p>If reading the file fails a CPLError() will be issued and NULL returned.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">pszFname</td><td>the name of the file to read. </td></tr> <tr><td class="paramname">nMaxLines</td><td>maximum number of lines to read before stopping, or -1 for no limit. </td></tr> <tr><td class="paramname">nMaxCols</td><td>maximum number of characters in a line before stopping, or -1 for no limit. </td></tr> <tr><td class="paramname">papszOptions</td><td>NULL-terminated array of options. Unused for now.</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>a string list with the files lines, now owned by caller. To be freed with <a class="el" href="cpl__string_8h.html#ace6799a8ba4bbb58318f17aecd9f55dd">CSLDestroy()</a></dd></dl> <dl class="section since"><dt>Since</dt><dd>GDAL 1.7.0 </dd></dl> </div> </div> <a class="anchor" id="a086854aa18fc7bbad86d64af501a4927"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">char CPL_DLL** CSLMerge </td> <td>(</td> <td class="paramtype">char ** </td> <td class="paramname"><em>papszOrig</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">char ** </td> <td class="paramname"><em>papszOverride</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Merge two lists. </p> <p>The two lists are merged, ensuring that if any keys appear in both that the value from the second (papszOverride) list take precidence.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">papszOrig</td><td>the original list, being modified. </td></tr> <tr><td class="paramname">papszOverride</td><td>the list of items being merged in. This list is unaltered and remains owned by the caller.</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>updated list. </dd></dl> </div> </div> <a class="anchor" id="a1b1b6eda40b063071fc1de336ae1f19a"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int CPL_DLL CSLPartialFindString </td> <td>(</td> <td class="paramtype">char ** </td> <td class="paramname"><em>papszHaystack</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszNeedle</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Find a substring within a string list.</p> <p>Returns the index of the entry in the string list that contains the target string as a substring. The search is case sensitive (unlike <a class="el" href="cpl__string_8h.html#ab8d50a9c6645f8cd176febb7a4ea41ce">CSLFindString()</a>).</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">papszHaystack</td><td>the string list to be searched. </td></tr> <tr><td class="paramname">pszNeedle</td><td>the substring to be searched for.</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>the index of the string within the list or -1 on failure. </dd></dl> </div> </div> <a class="anchor" id="a7cace9e31474df1e83493f5d8d7b1019"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">char CPL_DLL** CSLSetNameValue </td> <td>(</td> <td class="paramtype">char ** </td> <td class="paramname"><em>papszList</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszName</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszValue</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Assign value to name in StringList.</p> <p>Set the value for a given name in a StringList of "Name=Value" pairs ("Name:Value" pairs are also supported for backward compatibility with older stuff.)</p> <p>If there is already a value for that name in the list then the value is changed, otherwise a new "Name=Value" pair is added.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">papszList</td><td>the original list, the modified version is returned. </td></tr> <tr><td class="paramname">pszName</td><td>the name to be assigned a value. This should be a well formed token (no spaces or very special characters). </td></tr> <tr><td class="paramname">pszValue</td><td>the value to assign to the name. This should not contain any newlines (CR or LF) but is otherwise pretty much unconstrained. If NULL any corresponding value will be removed.</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>modified stringlist. </dd></dl> </div> </div> <a class="anchor" id="a2e7670421e44ece23a49af78556eb96d"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void CPL_DLL CSLSetNameValueSeparator </td> <td>(</td> <td class="paramtype">char ** </td> <td class="paramname"><em>papszList</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszSeparator</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Replace the default separator (":" or "=") with the passed separator in the given name/value list.</p> <p>Note that if a separator other than ":" or "=" is used, the resulting list will not be manipulatable by the CSL name/value functions any more.</p> <p>The <a class="el" href="cpl__string_8h.html#a9b0956ead51f6795ee28dbdc8e1121fd">CPLParseNameValue()</a> function is used to break the existing lines, and it also strips white space from around the existing delimiter, thus the old separator, and any white space will be replaced by the new separator. For formatting purposes it may be desireable to include some white space in the new separator. eg. ": " or " = ".</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">papszList</td><td>the list to update. Component strings may be freed but the list array will remain at the same location.</td></tr> <tr><td class="paramname">pszSeparator</td><td>the new separator string to insert. </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="affaa0f415488e88b1f729fda33eae311"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int CPL_DLL CSLTestBoolean </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszValue</em></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p>Test what boolean value contained in the string.</p> <p>If pszValue is "NO", "FALSE", "OFF" or "0" will be returned FALSE. Otherwise, TRUE will be returned.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">pszValue</td><td>the string should be tested.</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>TRUE or FALSE. </dd></dl> </div> </div> <a class="anchor" id="ae43588e11ec022600694aa71c64abeee"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">char CPL_DLL** CSLTokenizeString2 </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszString</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"><em>pszDelimiters</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int </td> <td class="paramname"><em>nCSLTFlags</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Tokenize a string.</p> <p>This function will split a string into tokens based on specified' delimeter(s) with a variety of options. The returned result is a string list that should be freed with <a class="el" href="cpl__string_8h.html#ace6799a8ba4bbb58318f17aecd9f55dd">CSLDestroy()</a> when no longer needed.</p> <p>The available parsing options are:</p> <ul> <li>CSLT_ALLOWEMPTYTOKENS: allow the return of empty tokens when two delimiters in a row occur with no other text between them. If not set, empty tokens will be discarded;</li> <li>CSLT_STRIPLEADSPACES: strip leading space characters from the token (as reported by isspace());</li> <li>CSLT_STRIPENDSPACES: strip ending space characters from the token (as reported by isspace());</li> <li>CSLT_HONOURSTRINGS: double quotes can be used to hold values that should not be broken into multiple tokens;</li> <li>CSLT_PRESERVEQUOTES: string quotes are carried into the tokens when this is set, otherwise they are removed;</li> <li>CSLT_PRESERVEESCAPES: if set backslash escapes (for backslash itself, and for literal double quotes) will be preserved in the tokens, otherwise the backslashes will be removed in processing.</li> </ul> <p><b>Example:</b> </p> <p>Parse a string into tokens based on various white space (space, newline, tab) and then print out results and cleanup. Quotes may be used to hold white space in tokens.</p> <div class="fragment"><div class="line"><span class="keywordtype">char</span> **papszTokens;</div> <div class="line"><span class="keywordtype">int</span> i;</div> <div class="line"></div> <div class="line">papszTokens = </div> <div class="line"> <a class="code" href="cpl__string_8h.html#ae43588e11ec022600694aa71c64abeee">CSLTokenizeString2</a>( pszCommand, <span class="stringliteral">" \t\n"</span>, </div> <div class="line"> CSLT_HONOURSTRINGS | CSLT_ALLOWEMPTYTOKENS );</div> <div class="line"></div> <div class="line"><span class="keywordflow">for</span>( i = 0; papszTokens != NULL && papszTokens[i] != NULL; i++ )</div> <div class="line"> printf( <span class="stringliteral">"arg %d: '%s'"</span>, papszTokens[i] );</div> <div class="line"><a class="code" href="cpl__string_8h.html#ace6799a8ba4bbb58318f17aecd9f55dd">CSLDestroy</a>( papszTokens );</div> </div><!-- fragment --><dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">pszString</td><td>the string to be split into tokens. </td></tr> <tr><td class="paramname">pszDelimiters</td><td>one or more characters to be used as token delimeters. </td></tr> <tr><td class="paramname">nCSLTFlags</td><td>an ORing of one or more of the CSLT_ flag values.</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>a string list of tokens owned by the caller. </dd></dl> </div> </div> </div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.5 </small></address> </body> </html>