Author: astitcher
Date: Thu Jul  3 20:25:24 2014
New Revision: 1607738

URL: http://svn.apache.org/r1607738
Log:
QPID-5806: Allow quoted syntax for non standard selector identifiers
- This matches the Java broker syntax for selectors

Modified:
    qpid/trunk/qpid/cpp/src/qpid/broker/SelectorToken.cpp
    qpid/trunk/qpid/cpp/src/tests/Selector.cpp

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/SelectorToken.cpp
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/SelectorToken.cpp?rev=1607738&r1=1607737&r2=1607738&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/SelectorToken.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/SelectorToken.cpp Thu Jul  3 20:25:24 
2014
@@ -113,26 +113,26 @@ bool tokeniseReservedWord(Token& tok)
     return true;
 }
 
-// parsing strings is complicated by the need to allow "''" as an embedded 
single quote
-bool processString(std::string::const_iterator& s, 
std::string::const_iterator& e, Token& tok)
+// parsing strings is complicated by the need to allow embedded quotes by 
doubling the quote character
+bool processString(std::string::const_iterator& s, 
std::string::const_iterator& e, char quoteChar, TokenType type, Token& tok)
 {
     // We only get here once the tokeniser recognises the initial quote for a 
string
     // so we don't need to check for it again.
-    std::string::const_iterator q = std::find(s+1, e, '\'');
+    std::string::const_iterator q = std::find(s+1, e, quoteChar);
     if ( q==e ) return false;
 
     std::string content(s+1, q);
     ++q;
 
-    while ( q!=e && *q=='\'' ) {
+    while ( q!=e && *q==quoteChar ) {
         std::string::const_iterator p = q;
-        q = std::find(p+1, e, '\'');
+        q = std::find(p+1, e, quoteChar);
         if ( q==e ) return false;
         content += std::string(p, q);
         ++q;
     }
 
-    tok = Token(T_STRING, s, content);
+    tok = Token(type, s, content);
     s = q;
     return true;
 }
@@ -198,7 +198,8 @@ bool tokenise(std::string::const_iterato
             break;
         }
         if (isIdentifierStart(*t)) {++t; state = IDENTIFIER;}
-        else if (*t=='\'') {return processString(s, e, tok);}
+        else if (*t=='\'') {return processString(s, e, '\'', T_STRING, tok);}
+        else if (*t=='\"') {return processString(s, e, '\"', T_IDENTIFIER, 
tok);}
         else if (std::isdigit(*t)) {++t; state = DIGIT;}
         else if (*t=='.') {++t; state = DECIMAL_START;}
         else state = REJECT;

Modified: qpid/trunk/qpid/cpp/src/tests/Selector.cpp
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/Selector.cpp?rev=1607738&r1=1607737&r2=1607738&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/Selector.cpp (original)
+++ qpid/trunk/qpid/cpp/src/tests/Selector.cpp Thu Jul  3 20:25:24 2014
@@ -152,7 +152,8 @@ QPID_AUTO_TEST_CASE(tokeniseSuccess)
 {
     verifyTokeniserSuccess(&tokenise, "", qb::T_EOS, "", "");
     verifyTokeniserSuccess(&tokenise, "null_123+blah", qb::T_IDENTIFIER, 
"null_123", "+blah");
-    verifyTokeniserSuccess(&tokenise, "null_123+blah", qb::T_IDENTIFIER, 
"null_123", "+blah");
+    verifyTokeniserSuccess(&tokenise, "\"null-123\"+blah", qb::T_IDENTIFIER, 
"null-123", "+blah");
+    verifyTokeniserSuccess(&tokenise, "\"This is an \"\"odd!\"\" 
identifier\"+blah", qb::T_IDENTIFIER, "This is an \"odd!\" identifier", 
"+blah");
     verifyTokeniserSuccess(&tokenise, "null+blah", qb::T_NULL, "null", 
"+blah");
     verifyTokeniserSuccess(&tokenise, "null+blah", qb::T_NULL, "null", 
"+blah");
     verifyTokeniserSuccess(&tokenise, "Is nOt null", qb::T_IS, "Is", " nOt 
null");



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to