LDAPFilter

std::ostream &cppmicroservices::operator<<(std::ostream &os, const LDAPFilter &filter)

Streams the string representation of filter into the stream os via LDAPFilter::ToString().

cppmicroservices::LDAPPropExpr operator&&(const cppmicroservices::LDAPPropExpr &left, const cppmicroservices::LDAPPropExpr &right)

LDAP logical and ‘&’.

Return
A LDAP expression
Parameters
  • left: A LDAP expression.
  • right: A LDAP expression.

cppmicroservices::LDAPPropExpr operator||(const cppmicroservices::LDAPPropExpr &left, const cppmicroservices::LDAPPropExpr &right)

LDAP logical or ‘|’.

Return
A LDAP expression
Parameters
  • left: A LDAP expression.
  • right: A LDAP expression.

class cppmicroservices::LDAPFilter
#include <cppmicroservices/LDAPFilter.h>

An RFC 1960-based Filter.

A LDAPFilter can be used numerous times to determine if the match argument matches the filter string that was used to create the LDAPFilter.

Some examples of LDAP filters are:

  • “(cn=Babs Jensen)”
  • “(!(cn=Tim Howes))”
  • “(&(” + Constants::OBJECTCLASS + “=Person)(|(sn=Jensen)(cn=Babs J*)))”
  • “(o=univ*of*mich*)”

Remark
This class is thread safe.
See
LDAPProp for a fluent API generating LDAP filter strings

Public Functions

LDAPFilter()

Creates a valid LDAPFilter object that matches nothing.

LDAPFilter(const std::string &filter)

Creates a LDAPFilter object.

This LDAPFilter object may be used to match a ServiceReference object or a ServiceProperties object.

If the filter cannot be parsed, an std::invalid_argument will be thrown with a human readable message where the filter became unparsable.

Return
A LDAPFilter object encapsulating the filter string.
See
“Framework specification for a description of the filter string syntax.” TODO!
Parameters
  • filter: The filter string.
Exceptions
  • std::invalid_argument: If filter contains an invalid filter string that cannot be parsed.

LDAPFilter(const LDAPFilter &other)
~LDAPFilter()
operator bool() const
bool Match(const ServiceReferenceBase &reference) const

Filter using a service’s properties.

This LDAPFilter is executed using the keys and values of the referenced service’s properties. The keys are looked up in a case insensitive manner.

Return
true if the service’s properties match this LDAPFilter false otherwise.
Parameters
  • reference: The reference to the service whose properties are used in the match.

bool Match(const Bundle &bundle) const

Filter using a bundle’s manifest headers.

This LDAPFilter is executed using the keys and values of the bundle’s manifest headers. The keys are looked up in a case insensitive manner.

Return
true if the bundle’s manifest headers match this LDAPFilter false otherwise.
Parameters
  • bundle: The bundle whose manifest’s headers are used in the match.
Exceptions
  • std::runtime_error: If the number of keys of the bundle’s manifest headers exceeds the value returned by std::numeric_limits<int>::max().

bool Match(const AnyMap &dictionary) const

Filter using a AnyMap object with case insensitive key lookup.

This LDAPFilter is executed using the specified AnyMap‘s keys and values. The keys are looked up in a case insensitive manner.

Return
true if the AnyMap‘s values match this filter; false otherwise.
Parameters
  • dictionary: The AnyMap whose key/value pairs are used in the match.
Exceptions
  • std::runtime_error: If the number of keys in the dictionary exceeds the value returned by std::numeric_limits<int>::max().
  • std::runtime_error: If the dictionary contains case variants of the same key name.

bool MatchCase(const AnyMap &dictionary) const

Filter using a AnyMap.

This LDAPFilter is executed using the specified AnyMap‘s keys and values. The keys are looked up in a normal manner respecting case.

Return
true if the AnyMap‘s values match this filter; false otherwise.
Parameters
  • dictionary: The AnyMap whose key/value pairs are used in the match.
Exceptions
  • std::runtime_error: If the number of keys in the dictionary exceeds the value returned by std::numeric_limits<int>::max().
  • std::runtime_error: If the dictionary contains case variants of the same key name.

std::string ToString() const

Returns this LDAPFilter‘s filter string.

The filter string is normalized by removing whitespace which does not affect the meaning of the filter.

Return
This LDAPFilter‘s filter string.

bool operator==(const LDAPFilter &other) const

Compares this LDAPFilter to another LDAPFilter.

This implementation returns the result of calling this->ToString() == other.ToString().

Return
Returns the result of calling this->ToString() == other.ToString().
Parameters
  • other: The object to compare against this LDAPFilter.

LDAPFilter &operator=(const LDAPFilter &filter)

Protected Attributes

SharedDataPointer<LDAPFilterData> d
class cppmicroservices::LDAPProp
#include <cppmicroservices/LDAPProp.h>

A fluent API for creating LDAP filter strings.

Examples for creating LDAPFilter objects:

// This creates the filter "(&(name=Ben)(!(count=1)))"
LDAPFilter filter(LDAPProp("name") == "Ben" && !(LDAPProp("count") == 1));

// This creates the filter "(|(presence=*)(!(absence=*)))"
LDAPFilter filter(LDAPProp("presence") || !LDAPProp("absence"));

// This creates the filter "(&(ge>=-3)(approx~=hi))"
LDAPFilter filter(LDAPProp("ge") >= -3 && LDAPProp("approx").Approx("hi"));

See
LDAPFilter

Unnamed Group

LDAPPropExpr operator==(const std::string &s) const

LDAP equality ‘=’.

Return
A LDAP expression object.
Parameters
  • s: A type convertible to std::string.

LDAPPropExpr operator==(const cppmicroservices::Any &s) const

LDAP equality ‘=’.

Return
A LDAP expression object.
Parameters
  • s: A type convertible to std::string.

LDAPPropExpr operator==(bool b) const

LDAP equality ‘=’.

Return
A LDAP expression object.
Parameters
  • s: A type convertible to std::string.

template <class T>
LDAPPropExpr operator==(const T &s) const

LDAP equality ‘=’.

Return
A LDAP expression object.
Parameters
  • s: A type convertible to std::string.

Unnamed Group

LDAPPropExpr operator!=(const std::string &s) const

Convenience operator for LDAP inequality.

Writing either

LDAPProp("attr") != "val"
or
!(LDAPProp("attr") == "val")
leads to the same string “(!(attr=val))”.

Return
A LDAP expression object.
Parameters
  • s: A type convertible to std::string.

LDAPPropExpr operator!=(const cppmicroservices::Any &s) const

Convenience operator for LDAP inequality.

Writing either

LDAPProp("attr") != "val"
or
!(LDAPProp("attr") == "val")
leads to the same string “(!(attr=val))”.

Return
A LDAP expression object.
Parameters
  • s: A type convertible to std::string.

template <class T>
LDAPPropExpr operator!=(const T &s) const

Convenience operator for LDAP inequality.

Writing either

LDAPProp("attr") != "val"
or
!(LDAPProp("attr") == "val")
leads to the same string “(!(attr=val))”.

Return
A LDAP expression object.
Parameters
  • s: A type convertible to std::string.

Unnamed Group

LDAPPropExpr operator>=(const std::string &s) const

LDAP greater or equal ‘>=’.

Return
A LDAP expression object.
Parameters
  • s: A type convertible to std::string.

LDAPPropExpr operator>=(const cppmicroservices::Any &s) const

LDAP greater or equal ‘>=’.

Return
A LDAP expression object.
Parameters
  • s: A type convertible to std::string.

template <class T>
LDAPPropExpr operator>=(const T &s) const

LDAP greater or equal ‘>=’.

Return
A LDAP expression object.
Parameters
  • s: A type convertible to std::string.

Unnamed Group

LDAPPropExpr operator<=(const std::string &s) const

LDAP less or equal ‘<=’.

Return
A LDAP expression object.
Parameters
  • s: A type convertible to std::string.

LDAPPropExpr operator<=(const cppmicroservices::Any &s) const

LDAP less or equal ‘<=’.

Return
A LDAP expression object.
Parameters
  • s: A type convertible to std::string.

template <class T>
LDAPPropExpr operator<=(const T &s) const

LDAP less or equal ‘<=’.

Return
A LDAP expression object.
Parameters
  • s: A type convertible to std::string.

Unnamed Group

LDAPPropExpr Approx(const std::string &s) const

LDAP approximation ‘~=’.

Return
A LDAP expression object.
Parameters
  • s: A type convertible to std::string.

LDAPPropExpr Approx(const cppmicroservices::Any &s) const

LDAP approximation ‘~=’.

Return
A LDAP expression object.
Parameters
  • s: A type convertible to std::string.

template <class T>
LDAPPropExpr Approx(const T &s) const

LDAP approximation ‘~=’.

Return
A LDAP expression object.
Parameters
  • s: A type convertible to std::string.

Public Functions

LDAPProp(const std::string &property)

Create a LDAPProp instance for the named LDAP property.

Parameters
  • property: The name of the LDAP property.

operator LDAPPropExpr() const
LDAPPropExpr operator!() const

States the absence of the LDAP property.

Return
A LDAP expression object.