Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
schwede
openstructure
Commits
b44dc138
Commit
b44dc138
authored
14 years ago
by
Marco Biasini
Browse files
Options
Downloads
Patches
Plain Diff
also parse queries like 'aname=?G' correctly
parent
d0d84227
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/mol/base/src/impl/query_impl.cc
+7
-2
7 additions, 2 deletions
modules/mol/base/src/impl/query_impl.cc
modules/mol/base/tests/test_query.cc
+4
-0
4 additions, 0 deletions
modules/mol/base/tests/test_query.cc
with
11 additions
and
2 deletions
modules/mol/base/src/impl/query_impl.cc
+
7
−
2
View file @
b44dc138
...
...
@@ -155,15 +155,20 @@ bool is_ident_or_str(char c) {
QueryToken
QueryLexer
::
LexIdentOrStringToken
()
{
static
IdentTokens
ident_tokens
;
size_t
start
=
current_
;
bool
force_string
=
false
;
while
(
current_
<
query_string_
.
length
()
&&
is_ident_or_str
(
query_string_
[
current_
]))
{
if
(
query_string_
[
current_
]
==
'*'
||
query_string_
[
current_
]
==
'?'
)
{
force_string
=
true
;
}
current_
++
;
}
String
ident
=
query_string_
.
substr
(
start
,
current_
-
start
);
if
(
tok
::
Type
*
t
=
find
(
ident_tokens
,
ident
.
c_str
()))
{
return
QueryToken
(
Range
(
start
,
current_
-
start
),
*
t
);
}
return
QueryToken
(
Range
(
start
,
current_
-
start
),
tok
::
Identifier
);
return
QueryToken
(
Range
(
start
,
current_
-
start
),
force_string
?
tok
::
String
:
tok
::
Identifier
);
}
QueryToken
QueryLexer
::
LexToken
()
{
...
...
@@ -174,7 +179,7 @@ QueryToken QueryLexer::LexToken() {
if
(
isdigit
(
current_char
)
||
current_char
==
'-'
)
{
return
this
->
LexNumericToken
();
}
if
(
isalpha
(
current_char
))
{
if
(
isalpha
(
current_char
)
||
current_char
==
'?'
||
current_char
==
'*'
)
{
return
this
->
LexIdentOrStringToken
();
}
switch
(
current_char
)
{
...
...
This diff is collapsed.
Click to expand it.
modules/mol/base/tests/test_query.cc
+
4
−
0
View file @
b44dc138
...
...
@@ -123,6 +123,8 @@ BOOST_AUTO_TEST_CASE(test_query_parse_properties)
BOOST_CHECK
(
Query
(
"grtest:2=8"
).
IsValid
());
BOOST_CHECK
(
Query
(
"gctest:3.0=9"
).
IsValid
());
BOOST_CHECK
(
Query
(
"anita=3"
).
IsValid
()
==
false
);
BOOST_CHECK
(
Query
(
"gc*test=3"
).
IsValid
()
==
false
);
BOOST_CHECK
(
Query
(
"gc?test=3"
).
IsValid
()
==
false
);
}
BOOST_AUTO_TEST_CASE
(
test_query_parse_value_type
)
...
...
@@ -279,8 +281,10 @@ BOOST_AUTO_TEST_CASE(test_glob)
ensure_counts
(
e
,
"rname=ARG and aname=N?1"
,
1
,
1
,
1
);
ensure_counts
(
e
,
"rname=ARG and aname=NH?"
,
1
,
1
,
2
);
ensure_counts
(
e
,
"rname=ARG and aname=
\"
*2
\"
"
,
1
,
1
,
1
);
ensure_counts
(
e
,
"rname=ARG and aname=*2"
,
1
,
1
,
1
);
ensure_counts
(
e
,
"rname=ARG and aname=N?"
,
1
,
1
,
1
);
ensure_counts
(
e
,
"rname=LEU and aname=
\"
?D?
\"
"
,
1
,
1
,
2
);
ensure_counts
(
e
,
"rname=LEU and aname=?D?"
,
1
,
1
,
2
);
}
BOOST_AUTO_TEST_SUITE_END
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment