00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef _CPL_STRING_H_INCLUDED
00032 #define _CPL_STRING_H_INCLUDED
00033
00034 #include "cpl_vsi.h"
00035 #include "cpl_error.h"
00036 #include "cpl_conv.h"
00037
00056 CPL_C_START
00057
00058 char CPL_DLL **CSLAddString(char **papszStrList, const char *pszNewString);
00059 int CPL_DLL CSLCount(char **papszStrList);
00060 const char CPL_DLL *CSLGetField( char **, int );
00061 void CPL_DLL CPL_STDCALL CSLDestroy(char **papszStrList);
00062 char CPL_DLL **CSLDuplicate(char **papszStrList);
00063 char CPL_DLL **CSLMerge( char **papszOrig, char **papszOverride );
00064
00065 char CPL_DLL **CSLTokenizeString(const char *pszString );
00066 char CPL_DLL **CSLTokenizeStringComplex(const char *pszString,
00067 const char *pszDelimiter,
00068 int bHonourStrings, int bAllowEmptyTokens );
00069 char CPL_DLL **CSLTokenizeString2( const char *pszString,
00070 const char *pszDelimeter,
00071 int nCSLTFlags );
00072
00073 #define CSLT_HONOURSTRINGS 0x0001
00074 #define CSLT_ALLOWEMPTYTOKENS 0x0002
00075 #define CSLT_PRESERVEQUOTES 0x0004
00076 #define CSLT_PRESERVEESCAPES 0x0008
00077
00078 int CPL_DLL CSLPrint(char **papszStrList, FILE *fpOut);
00079 char CPL_DLL **CSLLoad(const char *pszFname);
00080 int CPL_DLL CSLSave(char **papszStrList, const char *pszFname);
00081
00082 char CPL_DLL **CSLInsertStrings(char **papszStrList, int nInsertAtLineNo,
00083 char **papszNewLines);
00084 char CPL_DLL **CSLInsertString(char **papszStrList, int nInsertAtLineNo,
00085 const char *pszNewLine);
00086 char CPL_DLL **CSLRemoveStrings(char **papszStrList, int nFirstLineToDelete,
00087 int nNumToRemove, char ***ppapszRetStrings);
00088 int CPL_DLL CSLFindString( char **, const char * );
00089 int CPL_DLL CSLTestBoolean( const char *pszValue );
00090 int CPL_DLL CSLFetchBoolean( char **papszStrList, const char *pszKey,
00091 int bDefault );
00092
00093 const char CPL_DLL *CPLSPrintf(const char *fmt, ...);
00094 char CPL_DLL **CSLAppendPrintf(char **papszStrList, char *fmt, ...);
00095
00096 const char CPL_DLL *
00097 CPLParseNameValue(const char *pszNameValue, char **ppszKey );
00098 const char CPL_DLL *
00099 CSLFetchNameValue(char **papszStrList, const char *pszName);
00100 char CPL_DLL **
00101 CSLFetchNameValueMultiple(char **papszStrList, const char *pszName);
00102 char CPL_DLL **
00103 CSLAddNameValue(char **papszStrList,
00104 const char *pszName, const char *pszValue);
00105 char CPL_DLL **
00106 CSLSetNameValue(char **papszStrList,
00107 const char *pszName, const char *pszValue);
00108 void CPL_DLL CSLSetNameValueSeparator( char ** papszStrList,
00109 const char *pszSeparator );
00110
00111 #define CPLES_BackslashQuotable 0
00112 #define CPLES_XML 1
00113 #define CPLES_URL 2
00114 #define CPLES_SQL 3
00115 #define CPLES_CSV 4
00116
00117 char CPL_DLL *CPLEscapeString( const char *pszString, int nLength,
00118 int nScheme );
00119 char CPL_DLL *CPLUnescapeString( const char *pszString, int *pnLength,
00120 int nScheme );
00121
00122 char CPL_DLL *CPLBinaryToHex( int nBytes, const GByte *pabyData );
00123 GByte CPL_DLL *CPLHexToBinary( const char *pszHex, int *pnBytes );
00124
00125 CPL_C_END
00126
00127
00128
00129
00130
00131 #ifdef __cplusplus
00132
00133 #include <string>
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 #if (_MSC_VER <= 1202)
00149 # define MSVC_OLD_STUPID_BEHAVIOUR
00150 #endif
00151
00152
00153
00154 #ifdef MSVC_OLD_STUPID_BEHAVIOUR
00155 using std::string;
00156 # define std_string string
00157 #else
00158 # define std_string std::string
00159 #endif
00160
00161
00162 #if defined(WIN32CE)
00163 # pragma warning(disable:4251 4275 4786)
00164 #endif
00165
00166
00167
00168
00169 class CPL_DLL CPLString : public std_string
00170 {
00171 public:
00172
00173 CPLString(void) {}
00174 CPLString( const std::string &oStr ) : std_string( oStr ) {}
00175 CPLString( const char *pszStr ) : std_string( pszStr ) {}
00176
00177 operator const char* (void) const { return c_str(); }
00178
00179 CPLString &Printf( const char *pszFormat, ... );
00180 CPLString &vPrintf( const char *pszFormat, va_list args );
00181 CPLString &Trim();
00182 };
00183
00184 #endif
00185
00186 #endif