]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPSchema.cpp
add getKind method
[openldap] / contrib / ldapc++ / src / LDAPSchema.cpp
1 /*
2  * Copyright 2003, OpenLDAP Foundation, All Rights Reserved.
3  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
4  */
5
6 #include "debug.h"
7 #include "StringList.h"
8 #include "LDAPSchema.h"
9
10 using namespace std;
11
12 LDAPSchema::LDAPSchema(){
13     DEBUG(LDAP_DEBUG_CONSTRUCT,
14             "LDAPSchema::LDAPSchema( )" << endl);
15 }
16
17 LDAPSchema::~LDAPSchema() {
18     DEBUG(LDAP_DEBUG_DESTROY,"LDAPSchema::~LDAPSchema()" << endl);
19 }
20
21 void LDAPSchema::setObjectClasses (const StringList &ocs) {
22     DEBUG(LDAP_DEBUG_TRACE,"LDAPSchema::setObjectClasses()" << endl);
23     
24     // parse the stringlist and save it to global map...
25     StringList::const_iterator i,j;
26     for (i = ocs.begin(); i != ocs.end(); i++) {
27         LDAPObjClass oc ( (*i) );
28         StringList names = oc.getNames();
29         // there could be more names for one object...
30         for (j = names.begin(); j != names.end(); j++) {
31             object_classes [(*j)] = LDAPObjClass (oc);
32         }
33     }
34 }
35
36 void LDAPSchema::setAttributeTypes (const StringList &ats) {
37     DEBUG(LDAP_DEBUG_TRACE,"LDAPSchema::setAttributeTypes()" << endl);
38     
39     // parse the stringlist and save it to global map...
40     StringList::const_iterator i,j;
41     for (i = ats.begin(); i != ats.end(); i++) {
42         LDAPAttrType at ( (*i) );
43         StringList names = at.getNames();
44         // there could be more names for one object...
45         for (j = names.begin(); j != names.end(); j++) {
46             attr_types [(*j)] = LDAPAttrType (at);
47         }
48     }
49 }
50
51 LDAPObjClass LDAPSchema::getObjectClassByName (string name) {
52
53     return object_classes [name];
54 }
55
56 LDAPAttrType LDAPSchema::getAttributeTypeByName (string name) {
57
58     return attr_types [name];
59 }