1 // $OpenLDAP$
2 /*
3  * Copyright 2003-2021 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6 
7 #include "debug.h"
8 #include "LDAPObjClass.h"
9 
10 
LDAPObjClass()11 LDAPObjClass::LDAPObjClass(){
12     DEBUG(LDAP_DEBUG_CONSTRUCT,
13             "LDAPObjClass::LDAPObjClass( )" << endl);
14 
15     oid = string ();
16     desc = string ();
17     names = StringList ();
18     must = StringList();
19     may = StringList();
20     sup = StringList();
21 }
22 
LDAPObjClass(const LDAPObjClass & oc)23 LDAPObjClass::LDAPObjClass (const LDAPObjClass &oc){
24     DEBUG(LDAP_DEBUG_CONSTRUCT,
25             "LDAPObjClass::LDAPObjClass( )" << endl);
26 
27     oid = oc.oid;
28     desc = oc.desc;
29     names = oc.names;
30     must = oc.must;
31     may = oc.may;
32     kind = oc.kind;
33     sup = oc.sup;
34 }
35 
LDAPObjClass(string oc_item,int flags)36 LDAPObjClass::LDAPObjClass (string oc_item, int flags ) {
37 
38     DEBUG(LDAP_DEBUG_CONSTRUCT,
39             "LDAPObjClass::LDAPObjClass( )" << endl);
40 
41     LDAPObjectClass *o;
42     int ret;
43     const char *errp;
44     o = ldap_str2objectclass ( oc_item.c_str(), &ret, &errp, flags );
45 
46     if (o) {
47         this->setNames (o->oc_names);
48 	this->setDesc (o->oc_desc);
49         this->setOid (o->oc_oid);
50 	this->setKind (o->oc_kind);
51         this->setMust (o->oc_at_oids_must);
52 	this->setMay (o->oc_at_oids_may);
53         this->setSup (o->oc_sup_oids);
54     }
55     // else? -> error
56 }
57 
~LDAPObjClass()58 LDAPObjClass::~LDAPObjClass() {
59     DEBUG(LDAP_DEBUG_DESTROY,"LDAPObjClass::~LDAPObjClass()" << endl);
60 }
61 
setKind(int oc_kind)62 void LDAPObjClass::setKind (int oc_kind) {
63     kind = oc_kind;
64 }
65 
setNames(char ** oc_names)66 void LDAPObjClass::setNames (char **oc_names) {
67     names = StringList (oc_names);
68 }
69 
setMust(char ** oc_must)70 void LDAPObjClass::setMust (char **oc_must) {
71     must = StringList (oc_must);
72 }
73 
setMay(char ** oc_may)74 void LDAPObjClass::setMay (char **oc_may) {
75     may = StringList (oc_may);
76 }
77 
setSup(char ** oc_sup)78 void LDAPObjClass::setSup (char **oc_sup) {
79     sup = StringList (oc_sup);
80 }
81 
setDesc(char * oc_desc)82 void LDAPObjClass::setDesc (char *oc_desc) {
83     desc = string ();
84     if (oc_desc)
85 	desc = oc_desc;
86 }
87 
setOid(char * oc_oid)88 void LDAPObjClass::setOid (char *oc_oid) {
89     oid = string ();
90     if (oc_oid)
91 	oid = oc_oid;
92 }
93 
getOid() const94 string LDAPObjClass::getOid() const {
95     return oid;
96 }
97 
getDesc() const98 string LDAPObjClass::getDesc() const {
99     return desc;
100 }
101 
getNames() const102 StringList LDAPObjClass::getNames() const {
103     return names;
104 }
105 
getMust() const106 StringList LDAPObjClass::getMust() const {
107     return must;
108 }
109 
getMay() const110 StringList LDAPObjClass::getMay() const {
111     return may;
112 }
113 
getSup() const114 StringList LDAPObjClass::getSup() const {
115     return sup;
116 }
117 
getName() const118 string LDAPObjClass::getName() const {
119 
120     if (names.empty())
121 	return "";
122     else
123 	return *(names.begin());
124 }
125 
getKind() const126 int LDAPObjClass::getKind() const {
127      return kind;
128 }
129 
130 
131