comparison OrthancServer/OrthancFindRequestHandler.cpp @ 690:2e67366aab83

case-insensitive matching of Application Entity Titles
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 04 Feb 2014 15:54:46 +0100
parents 2d0a347e8cfc
children 6a1dbba0cca7
comparison
equal deleted inserted replaced
689:2d0a347e8cfc 690:2e67366aab83
46 constraint.find('*') != std::string::npos || 46 constraint.find('*') != std::string::npos ||
47 constraint.find('\\') != std::string::npos || 47 constraint.find('\\') != std::string::npos ||
48 constraint.find('?') != std::string::npos); 48 constraint.find('?') != std::string::npos);
49 } 49 }
50 50
51 static std::string ToLowerCase(const std::string& s)
52 {
53 std::string result = s;
54 Toolbox::ToLowerCase(result);
55 return result;
56 }
57
58 static bool ApplyRangeConstraint(const std::string& value, 51 static bool ApplyRangeConstraint(const std::string& value,
59 const std::string& constraint) 52 const std::string& constraint)
60 { 53 {
61 size_t separator = constraint.find('-'); 54 size_t separator = constraint.find('-');
62 std::string lower = ToLowerCase(constraint.substr(0, separator)); 55 std::string lower, upper, v;
63 std::string upper = ToLowerCase(constraint.substr(separator + 1)); 56 Toolbox::ToLowerCase(lower, constraint.substr(0, separator));
64 std::string v = ToLowerCase(value); 57 Toolbox::ToLowerCase(upper, constraint.substr(separator + 1));
58 Toolbox::ToLowerCase(v, value);
65 59
66 if (lower.size() == 0 && upper.size() == 0) 60 if (lower.size() == 0 && upper.size() == 0)
67 { 61 {
68 return false; 62 return false;
69 } 63 }
83 77
84 78
85 static bool ApplyListConstraint(const std::string& value, 79 static bool ApplyListConstraint(const std::string& value,
86 const std::string& constraint) 80 const std::string& constraint)
87 { 81 {
88 std::string v1 = ToLowerCase(value); 82 std::string v1;
83 Toolbox::ToLowerCase(v1, value);
89 84
90 std::vector<std::string> items; 85 std::vector<std::string> items;
91 Toolbox::TokenizeString(items, constraint, '\\'); 86 Toolbox::TokenizeString(items, constraint, '\\');
92 87
93 for (size_t i = 0; i < items.size(); i++) 88 for (size_t i = 0; i < items.size(); i++)
94 { 89 {
95 Toolbox::ToLowerCase(items[i]); 90 std::string lower;
96 if (items[i] == v1) 91 Toolbox::ToLowerCase(lower, items[i]);
92 if (lower == v1)
97 { 93 {
98 return true; 94 return true;
99 } 95 }
100 } 96 }
101 97
127 boost::regex::icase /* case insensitive search */); 123 boost::regex::icase /* case insensitive search */);
128 return boost::regex_match(value, pattern); 124 return boost::regex_match(value, pattern);
129 } 125 }
130 else 126 else
131 { 127 {
132 return ToLowerCase(value) == ToLowerCase(constraint); 128 std::string v, c;
129 Toolbox::ToLowerCase(v, value);
130 Toolbox::ToLowerCase(c, constraint);
131 return v == c;
133 } 132 }
134 } 133 }
135 134
136 135
137 static bool LookupOneInstance(std::string& result, 136 static bool LookupOneInstance(std::string& result,