[mapserver-commits] r9594 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Mon Dec 7 14:34:43 EST 2009


Author: aboudreault
Date: 2009-12-07 14:34:43 -0500 (Mon, 07 Dec 2009)
New Revision: 9594

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/mapserver.h
   trunk/mapserver/mapstring.c
Log:
Added msStringSplitComplex function (#471)

Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2009-12-07 19:26:09 UTC (rev 9593)
+++ trunk/mapserver/HISTORY.TXT	2009-12-07 19:34:43 UTC (rev 9594)
@@ -14,6 +14,8 @@
 Current Version (SVN trunk):
 ----------------------------
 
+- Added msStringSplitComplex function (#471)
+
 - Mapserver WFS should send maxfeatures to the spatial database (#2605)
 
 - WFS paging support (#2799)

Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h	2009-12-07 19:26:09 UTC (rev 9593)
+++ trunk/mapserver/mapserver.h	2009-12-07 19:34:43 UTC (rev 9594)
@@ -126,6 +126,10 @@
 
 #include <gd.h>
 
+#ifdef USE_GDAL
+#include "cpl_string.h"
+#endif
+
 #if defined USE_PDF
 #include <pdflib.h>
 #endif
@@ -1760,6 +1764,7 @@
 MS_DLL_EXPORT char *msTryBuildPath(char *szReturnPath, const char *abs_path, const char *path);
 MS_DLL_EXPORT char *msTryBuildPath3(char *szReturnPath, const char *abs_path, const char *path1, const char *path2);
 MS_DLL_EXPORT char **msStringSplit(const char *string, char cd, int *num_tokens);
+MS_DLL_EXPORT char **msStringSplitComplex(const char *string, const char *delimiters, int *num_tokens, int CSLTFlags);
 MS_DLL_EXPORT char **msStringTokenize( const char *pszLine, const char *pszDelim, int *num_tokens, int preserve_quote);
 MS_DLL_EXPORT int msCountChars(char *str, char ch);
 MS_DLL_EXPORT char *msLongToString(long value);

Modified: trunk/mapserver/mapstring.c
===================================================================
--- trunk/mapserver/mapstring.c	2009-12-07 19:26:09 UTC (rev 9593)
+++ trunk/mapserver/mapstring.c	2009-12-07 19:34:43 UTC (rev 9594)
@@ -755,6 +755,45 @@
   return(token);
 }
 
+/*
+ If GDAL is not available, msStringSplit is used: flags are ignored and only the 
+ first char of the delimiters variable is passed through msStringSplit.
+ 
+ See the port/cpl_string.cpp file in gdal source for the complete documentation.
+ Available Flags:
+ * - 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;
+ * - CSLT_STRIPLEADSPACES: strip leading space characters from the token (as
+ * reported by isspace());
+ * - CSLT_STRIPENDSPACES: strip ending space characters from the token (as
+ * reported by isspace());
+ * - CSLT_HONOURSTRINGS: double quotes can be used to hold values that should 
+ * not be broken into multiple tokens; 
+ * - CSLT_PRESERVEQUOTES: string quotes are carried into the tokens when this
+ * is set, otherwise they are removed;
+ * - 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.
+ */
+char **msStringSplitComplex(const char *string, const char *delimiters, int *num_tokens, int CSLTFlags) 
+{
+    char **tokens;
+#ifdef USE_GDAL
+    int i;
+    tokens = CSLTokenizeString2(string, delimiters, CSLTFlags);
+    *num_tokens = 0;
+    for (i = 0; tokens != NULL && tokens[i] != NULL; ++i) 
+        ++(*num_tokens);
+#else
+    tokens = msStringSplit(string, 
+                           delimiters ? (char)delimiters[0] : '\0',
+                           num_tokens);
+#endif
+
+    return tokens;
+}
+
 /* This method is similar to msStringSplit but support quoted strings. 
    It also support multi-characters delimiter and allows to preserve quotes */
 char **msStringTokenize( const char *pszLine, const char *pszDelim, 



More information about the mapserver-commits mailing list