Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LDAP API improvements #246

Closed
jeffdiclemente opened this issue Oct 23, 2017 · 0 comments
Closed

LDAP API improvements #246

jeffdiclemente opened this issue Oct 23, 2017 · 0 comments
Assignees
Projects

Comments

@jeffdiclemente
Copy link
Member

Use Case

I want to construct long LDAP expressions and conditionally modify them using concise modern C++.

Pain Point

LDAP expressions can be conditionally built however it requires more code than is necessary...

LDAPFilter filter(LDAPProp("key1") == "value1");

if (someCondition) {
    filter = LDAPFilter(LDAPPropExpr(filter.ToString()) || LDAPProp("key2") == "value2");
} else {
    filter = LDAPFilter(LDAPPropExpr(filter.ToString()) || LDAPProp("key3") == "value3");
}

This is not only more code to write for clients, its also wasteful since extra temporary objects need to be created.

Solution

  • Make LDAPPropExpr::operator= and LDAPProp::operator= public.
  • Implement LDAPProp::operator|= andLDAPProp::operator&=

This allows the following to be written...

LDAPPropExpr expr(LDAPProp("key1") == "value1");

if (someCondition) {
    expr = expr || LDAPProp("key2") == "value2"; // or even more conveniently, expr |= LDAPProp("key2") == "value2";
} else {
    expr = expr || LDAPProp("key3") == "value3";
}

And even more concisely...

LDAPPropExpr expr(LDAPProp("key1") == "value1");

if (someCondition) {
    expr |= LDAPProp("key2") == "value2";
} else {
    expr |= LDAPProp("key3") == "value3";
}
@jeffdiclemente jeffdiclemente self-assigned this Oct 23, 2017
jeffdiclemente added a commit that referenced this issue Oct 26, 2017
Fixes #246

Signed-off-by: The Mathworks Inc <Roy.Lurie@mathworks.com>
@jeffdiclemente jeffdiclemente added this to In Progress in Release 3.3 Oct 30, 2017
jeffdiclemente added a commit that referenced this issue Oct 30, 2017
Fixes #246

Signed-off-by: The Mathworks Inc <Roy.Lurie@mathworks.com>
@jeffdiclemente jeffdiclemente moved this from In Progress to Done in Release 3.3 Nov 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

1 participant