diff options
| author | Andrew Stitcher <astitcher@apache.org> | 2014-07-03 20:25:24 +0000 |
|---|---|---|
| committer | Andrew Stitcher <astitcher@apache.org> | 2014-07-03 20:25:24 +0000 |
| commit | b5b5670d078966443c04f60f64e9b39ad6630cb5 (patch) | |
| tree | 36ddc7370817f07ed164a1c765c1549cc8decf31 /qpid/cpp | |
| parent | 4d44af1d101c17c234b1cb3304373e915ac74b66 (diff) | |
| download | qpid-python-b5b5670d078966443c04f60f64e9b39ad6630cb5.tar.gz | |
QPID-5806: Allow quoted syntax for non standard selector identifiers
- This matches the Java broker syntax for selectors
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1607738 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp')
| -rw-r--r-- | qpid/cpp/src/qpid/broker/SelectorToken.cpp | 15 | ||||
| -rw-r--r-- | qpid/cpp/src/tests/Selector.cpp | 3 |
2 files changed, 10 insertions, 8 deletions
diff --git a/qpid/cpp/src/qpid/broker/SelectorToken.cpp b/qpid/cpp/src/qpid/broker/SelectorToken.cpp index 309c0891df..eb56833178 100644 --- a/qpid/cpp/src/qpid/broker/SelectorToken.cpp +++ b/qpid/cpp/src/qpid/broker/SelectorToken.cpp @@ -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_iterator& s, std::string::const_iterator& e, To 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; diff --git a/qpid/cpp/src/tests/Selector.cpp b/qpid/cpp/src/tests/Selector.cpp index 951f124d3a..23c192bc63 100644 --- a/qpid/cpp/src/tests/Selector.cpp +++ b/qpid/cpp/src/tests/Selector.cpp @@ -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"); |
