<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body text="#000000" bgcolor="#FFFFFF">
I ran into a problem where a quoted text string in a OGR Style
String gets lost while interacting with it via an OGRStyleTool.
Using the same style string afterwords causes OGRStyleTool::Parse()
to fail because the quote string contained parentheses which would
have typically been ignored because of the CSLT_HONOURSTRINGS and
CSLT_PRESERVEQUOTES flags that are passed to CSLTokenizeString2.<br>
<br>
Here is a code snippet that exposes the issue that I am seeing:<br>
<blockquote><tt>void testGetStyleString()</tt><tt><br>
</tt><tt>{</tt><tt><br>
</tt><tt> const char* const originalStyleString =
"LABEL(t:\"MyText(1)\")";</tt><tt><br>
</tt><tt> std::cout << "originalStyleString:" <<
originalStyleString << std::endl;</tt><tt><br>
</tt><tt><br>
</tt><tt> ::OGRStyleLabel styleLabel;</tt><tt><br>
</tt><tt> styleLabel.SetStyleString(originalStyleString);</tt><tt><br>
</tt><tt><br>
</tt><tt> const char* const styleStringAfterBeingSet =
styleLabel.GetStyleString();</tt><tt><br>
</tt><tt> std::cout << "styleStringAfterBeingSet:"
<< styleStringAfterBeingSet << std::endl;</tt><tt><br>
</tt><tt><br>
</tt><tt> GBool defaultValue = false;</tt><tt><br>
</tt><tt> const char* const te</tt><tt>x</tt><tt>tString =
styleLabel.TextString(defaultValue);</tt><tt><br>
</tt><tt> std::cout << "textString:" << textString
<< std::endl;</tt><tt><br>
</tt><tt><br>
</tt><tt> const char* const styleStringAfterParsingStage =
styleLabel.GetStyleString();</tt><tt><br>
</tt><tt> std::cout << "styleStringAfterParsingStage:"
<< styleStringAfterParsingStage << std::endl;</tt><tt><br>
</tt><tt><br>
</tt><tt> return;</tt><tt><br>
</tt><tt>}</tt><br>
</blockquote>
Which produces the following output:<br>
<blockquote><tt>originalStyleString:LABEL(t:"MyText(1)")<br>
styleStringAfterBeingSet:LABEL(t:"MyText(1)")<br>
textString:MyText(1)<br>
styleStringAfterParsingStage:LABEL(t:MyText(1))</tt><br>
</blockquote>
So, the main problem I have encountered, as far as I can tell is
that GetStyleString() does not honor the quotes after it has been
set to have been parse and set as modified (StyleModified). I my
case, I didn't even modify the tool, OGRStyleTool::Parse() seems to
be the one who set the style tool as being modified. The modified
flag is why GetStyleString() regenerates the string from the
parameters. So, I have two questions:<br>
<br>
1. Should Parse() set the style tool as modified as it currently
does?<br>
2. Should the parsing of the parameters retain the quotes? It
currently doesn't specify CSLT_PRESERVEQUOTES when splitting <tt>t:"MyText"
at the colon.</tt><br>
<br>
Doing #2 would obviously mean the TextString() would return the
quoted string which it doesn't do currently.<tt><br>
<br>
</tt>Any thoughts?<br>
André<br>
</body>
</html>