]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPAttrType.cpp
Happy New Year
[openldap] / contrib / ldapc++ / src / LDAPAttrType.cpp
1 // $OpenLDAP$
2 /*
3  * Copyright 2003-2018 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6
7 #include "debug.h"
8 #include "LDAPAttrType.h"
9
10
11 LDAPAttrType::LDAPAttrType(){
12     DEBUG(LDAP_DEBUG_CONSTRUCT,
13             "LDAPAttrType::LDAPAttrType( )" << endl);
14
15     oid = string ();
16     desc = string ();
17     names = StringList ();
18     single = false;
19     usage = 0;
20 }
21
22 LDAPAttrType::LDAPAttrType (string at_item, int flags ) { 
23
24     DEBUG(LDAP_DEBUG_CONSTRUCT,
25             "LDAPAttrType::LDAPAttrType( )" << endl);
26
27     LDAPAttributeType *a;
28     int ret;
29     const char *errp;
30     a = ldap_str2attributetype (at_item.c_str(), &ret, &errp, flags);
31
32     if (a) {
33         this->setNames( a->at_names );
34         this->setDesc( a->at_desc );
35         this->setOid( a->at_oid );
36         this->setSingle( a->at_single_value );
37         this->setUsage( a->at_usage );
38         this->setSuperiorOid( a->at_sup_oid );
39         this->setEqualityOid( a->at_equality_oid );
40         this->setOrderingOid( a->at_ordering_oid );
41         this->setSubstringOid( a->at_substr_oid );
42         this->setSyntaxOid( a->at_syntax_oid );
43     }
44     // else? -> error
45 }
46
47 LDAPAttrType::~LDAPAttrType() {
48     DEBUG(LDAP_DEBUG_DESTROY,"LDAPAttrType::~LDAPAttrType()" << endl);
49 }
50
51 void LDAPAttrType::setSingle (int at_single) {
52     single = (at_single == 1);
53 }
54     
55 void LDAPAttrType::setNames ( char **at_names ) {
56     names = StringList(at_names);
57 }
58
59 void LDAPAttrType::setDesc (const char *at_desc) {
60     desc = string ();
61     if (at_desc)
62         desc = at_desc;
63 }
64
65 void LDAPAttrType::setOid (const char *at_oid) {
66     oid = string ();
67     if (at_oid)
68         oid = at_oid;
69 }
70
71 void LDAPAttrType::setUsage (int at_usage) {
72     usage = at_usage;
73 }
74
75 void LDAPAttrType::setSuperiorOid( const char *oid ){
76     if ( oid )
77         superiorOid = oid;
78 }
79
80 void LDAPAttrType::setEqualityOid( const char *oid ){
81     if ( oid )
82         equalityOid = oid;
83 }
84
85 void LDAPAttrType::setOrderingOid( const char *oid ){
86     if ( oid )
87         orderingOid = oid;
88 }
89
90 void LDAPAttrType::setSubstringOid( const char *oid ){
91     if ( oid )
92         substringOid = oid;
93 }
94
95 void LDAPAttrType::setSyntaxOid( const char *oid ){
96     if ( oid )
97         syntaxOid = oid;
98 }
99
100 bool LDAPAttrType::isSingle() const {
101     return single;
102
103
104 string LDAPAttrType::getOid() const {
105     return oid;
106 }
107
108 string LDAPAttrType::getDesc() const {
109     return desc;
110 }
111
112 StringList LDAPAttrType::getNames() const {
113     return names;
114 }
115
116 string LDAPAttrType::getName() const {
117
118     if (names.empty())
119         return "";
120     else
121         return *(names.begin());
122 }
123
124 int LDAPAttrType::getUsage() const {
125     return usage;
126 }
127
128 std::string LDAPAttrType::getSuperiorOid() const {
129     return superiorOid;
130 }
131
132 std::string LDAPAttrType::getEqualityOid() const {
133     return equalityOid;
134 }
135
136 std::string LDAPAttrType::getOrderingOid() const {
137     return orderingOid;
138 }
139
140 std::string LDAPAttrType::getSubstringOid() const {
141     return substringOid;
142 }
143
144 std::string LDAPAttrType::getSyntaxOid() const {
145     return syntaxOid;
146 }
147
148