forked from lyokha/ldapsf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathldap_sf.cpp
More file actions
42 lines (33 loc) · 1.33 KB
/
ldap_sf.cpp
File metadata and controls
42 lines (33 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "ldap_sf.h"
#include <iterator>
#include <stdexcept>
namespace ldap {
using ::boost::spirit::qi::phrase_parse;
using ::boost::spirit::unicode::space;
sf::Node SearchFilter::buildQuery(std::string const & query) const
{
sf::Node ast;
auto begin = std::cbegin(query);
auto end = std::cend(query);
if (!phrase_parse(begin, end, grammar_, space, ast) ||
begin != end) {
throw std::runtime_error{"Failed to build a query '" + query + "'"};
}
return ast;
}
RecordListPtr SearchFilter::operator()(sf::Node const & ast,
RecordList const & records,
sf::Eval::Collator::ECollationStrength strength,
sf::Eval::Locale const & loc) const
{
return eval_(ast, records, strength, loc);
}
RecordListPtr SearchFilter::operator()(std::string const & query,
RecordList const & records,
sf::Eval::Collator::ECollationStrength strength,
sf::Eval::Locale const & loc) const
{
auto ast = buildQuery(query);
return eval_(ast, records, strength, loc);
}
} // namespace ldap