-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathldap_sf.cpp
More file actions
59 lines (47 loc) · 1.53 KB
/
ldap_sf.cpp
File metadata and controls
59 lines (47 loc) · 1.53 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* =============================================================================
*
* Filename: ldap_sf.cpp
*
* Description: LDAP Search Filter
*
* Version: 1.0
* Created: 26.02.2015 20:53:52
* Revision: none
* Compiler: gcc
*
* Author: Alexey Radkov (),
* Company:
*
* =============================================================================
*/
#include <stdexcept>
#include "ldap_sf.h"
namespace ldap
{
sf::Node SearchFilter::buildQuery( const std::string & query ) const
{
GrammarIterator begin( query.begin() );
GrammarIterator end( query.end() );
sf::Node ast;
if ( ! sf::phrase_parse( begin, end, grammar_, space_, ast ) ||
begin != end )
throw std::runtime_error( "Failed to build a query '" + query + "'" );
return ast;
}
RecordListPtr SearchFilter::operator()( const sf::Node & ast,
const RecordList & records,
sf::Eval::Collator::ECollationStrength strength,
const sf::Eval::Locale & loc ) const
{
return eval_( ast, records, strength, loc );
}
RecordListPtr SearchFilter::operator()( const std::string & query,
const RecordList & records,
sf::Eval::Collator::ECollationStrength strength,
const sf::Eval::Locale & loc ) const
{
sf::Node ast( buildQuery( query ) );
return eval_( ast, records, strength, loc );
}
} // namespace ldap