Back to index

openldap  2.4.31
LDAPAttrType.cpp
Go to the documentation of this file.
00001 // $OpenLDAP$
00002 /*
00003  * Copyright 2003-2012 The OpenLDAP Foundation, All Rights Reserved.
00004  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
00005  */
00006 
00007 #include "debug.h"
00008 #include "LDAPAttrType.h"
00009 
00010 
00011 LDAPAttrType::LDAPAttrType(){
00012     DEBUG(LDAP_DEBUG_CONSTRUCT,
00013             "LDAPAttrType::LDAPAttrType( )" << endl);
00014 
00015     oid = string ();
00016     desc = string ();
00017     names = StringList ();
00018     single = false;
00019     usage = 0;
00020 }
00021 
00022 LDAPAttrType::LDAPAttrType (string at_item, int flags ) { 
00023 
00024     DEBUG(LDAP_DEBUG_CONSTRUCT,
00025             "LDAPAttrType::LDAPAttrType( )" << endl);
00026 
00027     LDAPAttributeType *a;
00028     int ret;
00029     const char *errp;
00030     a = ldap_str2attributetype (at_item.c_str(), &ret, &errp, flags);
00031 
00032     if (a) {
00033        this->setNames( a->at_names );
00034        this->setDesc( a->at_desc );
00035        this->setOid( a->at_oid );
00036        this->setSingle( a->at_single_value );
00037        this->setUsage( a->at_usage );
00038         this->setSuperiorOid( a->at_sup_oid );
00039         this->setEqualityOid( a->at_equality_oid );
00040         this->setOrderingOid( a->at_ordering_oid );
00041         this->setSubstringOid( a->at_substr_oid );
00042         this->setSyntaxOid( a->at_syntax_oid );
00043     }
00044     // else? -> error
00045 }
00046 
00047 LDAPAttrType::~LDAPAttrType() {
00048     DEBUG(LDAP_DEBUG_DESTROY,"LDAPAttrType::~LDAPAttrType()" << endl);
00049 }
00050 
00051 void LDAPAttrType::setSingle (int at_single) {
00052     single = (at_single == 1);
00053 }
00054     
00055 void LDAPAttrType::setNames ( char **at_names ) {
00056     names = StringList(at_names);
00057 }
00058 
00059 void LDAPAttrType::setDesc (const char *at_desc) {
00060     desc = string ();
00061     if (at_desc)
00062        desc = at_desc;
00063 }
00064 
00065 void LDAPAttrType::setOid (const char *at_oid) {
00066     oid = string ();
00067     if (at_oid)
00068        oid = at_oid;
00069 }
00070 
00071 void LDAPAttrType::setUsage (int at_usage) {
00072     usage = at_usage;
00073 }
00074 
00075 void LDAPAttrType::setSuperiorOid( const char *oid ){
00076     if ( oid )
00077         superiorOid = oid;
00078 }
00079 
00080 void LDAPAttrType::setEqualityOid( const char *oid ){
00081     if ( oid )
00082         equalityOid = oid;
00083 }
00084 
00085 void LDAPAttrType::setOrderingOid( const char *oid ){
00086     if ( oid )
00087         orderingOid = oid;
00088 }
00089 
00090 void LDAPAttrType::setSubstringOid( const char *oid ){
00091     if ( oid )
00092         substringOid = oid;
00093 }
00094 
00095 void LDAPAttrType::setSyntaxOid( const char *oid ){
00096     if ( oid )
00097         syntaxOid = oid;
00098 }
00099 
00100 bool LDAPAttrType::isSingle() const {
00101     return single;
00102 } 
00103 
00104 string LDAPAttrType::getOid() const {
00105     return oid;
00106 }
00107 
00108 string LDAPAttrType::getDesc() const {
00109     return desc;
00110 }
00111 
00112 StringList LDAPAttrType::getNames() const {
00113     return names;
00114 }
00115 
00116 string LDAPAttrType::getName() const {
00117 
00118     if (names.empty())
00119        return "";
00120     else
00121        return *(names.begin());
00122 }
00123 
00124 int LDAPAttrType::getUsage() const {
00125     return usage;
00126 }
00127 
00128 std::string LDAPAttrType::getSuperiorOid() const {
00129     return superiorOid;
00130 }
00131 
00132 std::string LDAPAttrType::getEqualityOid() const {
00133     return equalityOid;
00134 }
00135 
00136 std::string LDAPAttrType::getOrderingOid() const {
00137     return orderingOid;
00138 }
00139 
00140 std::string LDAPAttrType::getSubstringOid() const {
00141     return substringOid;
00142 }
00143 
00144 std::string LDAPAttrType::getSyntaxOid() const {
00145     return syntaxOid;
00146 }
00147 
00148