]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPObjClass.cpp
Added ldif_countlines()
[openldap] / contrib / ldapc++ / src / LDAPObjClass.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 "LDAPObjClass.h"
8
9
10 LDAPObjClass::LDAPObjClass(){
11     DEBUG(LDAP_DEBUG_CONSTRUCT,
12             "LDAPObjClass::LDAPObjClass( )" << endl);
13
14     oid = string ();
15     desc = string ();
16     names = StringList ();
17     must = StringList();
18     may = StringList();
19     sup = StringList();
20 }
21
22 LDAPObjClass::LDAPObjClass (const LDAPObjClass &oc){
23     DEBUG(LDAP_DEBUG_CONSTRUCT,
24             "LDAPObjClass::LDAPObjClass( )" << endl);
25
26     oid = oc.oid;
27     desc = oc.desc;
28     names = oc.names;
29     must = oc.must;
30     may = oc.may;
31     kind = oc.kind;
32     sup = oc.sup;
33 }
34
35 LDAPObjClass::LDAPObjClass (string oc_item) { 
36
37     DEBUG(LDAP_DEBUG_CONSTRUCT,
38             "LDAPObjClass::LDAPObjClass( )" << endl);
39
40     LDAPObjectClass *o;
41     int ret;
42     const char *errp;
43     o = ldap_str2objectclass ( oc_item.c_str(), &ret, &errp, SCHEMA_PARSE_FLAG);
44
45     if (o) {
46         this->setNames (o->oc_names);
47         this->setDesc (o->oc_desc);
48         this->setOid (o->oc_oid);
49         this->setKind (o->oc_kind);
50         this->setMust (o->oc_at_oids_must);
51         this->setMay (o->oc_at_oids_may);
52         this->setSup (o->oc_sup_oids);
53     }
54     // else? -> error
55 }
56
57 LDAPObjClass::~LDAPObjClass() {
58     DEBUG(LDAP_DEBUG_DESTROY,"LDAPObjClass::~LDAPObjClass()" << endl);
59 }
60
61 void LDAPObjClass::setKind (int oc_kind) {
62     kind = oc_kind;
63 }
64     
65 void LDAPObjClass::setNames (char **oc_names) {
66     names = StringList (oc_names);
67 }
68
69 void LDAPObjClass::setMust (char **oc_must) {
70     must = StringList (oc_must);
71 }
72
73 void LDAPObjClass::setMay (char **oc_may) {
74     may = StringList (oc_may);
75 }
76
77 void LDAPObjClass::setSup (char **oc_sup) {
78     sup = StringList (oc_sup);
79 }
80
81 void LDAPObjClass::setDesc (char *oc_desc) {
82     desc = string ();
83     if (oc_desc)
84         desc = oc_desc;
85 }
86
87 void LDAPObjClass::setOid (char *oc_oid) {
88     oid = string ();
89     if (oc_oid)
90         oid = oc_oid;
91 }
92
93 string LDAPObjClass::getOid () {
94     return oid;
95 }
96
97 string LDAPObjClass::getDesc () {
98     return desc;
99 }
100
101 StringList LDAPObjClass::getNames () {
102     return names;
103 }
104
105 StringList LDAPObjClass::getMust () {
106     return must;
107 }
108
109 StringList LDAPObjClass::getMay () {
110     return may;
111 }
112
113 StringList LDAPObjClass::getSup () {
114     return sup;
115 }
116
117 string LDAPObjClass::getName () {
118
119     if (names.empty())
120         return "";
121     else
122         return *(names.begin());
123 }
124
125 int LDAPObjClass::getKind () {
126      return kind;
127 }
128
129