2 * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
10 #include "LDAPAttributeList.h"
12 #include "LDAPException.h"
13 #include "LDAPAttribute.h"
14 #include "LDAPAsynConnection.h"
15 #include "LDAPMessage.h"
17 LDAPAttributeList::LDAPAttributeList(){
18 DEBUG(LDAP_DEBUG_CONSTRUCT,
19 "LDAPAttributeList::LDAPAttributList( )" << endl);
22 LDAPAttributeList::LDAPAttributeList(const LDAPAttributeList& al){
23 DEBUG(LDAP_DEBUG_CONSTRUCT,
24 "LDAPAttributeList::LDAPAttributList(&)" << endl);
28 LDAPAttributeList::LDAPAttributeList(const LDAPAsynConnection *ld,
30 DEBUG(LDAP_DEBUG_CONSTRUCT,
31 "LDAPAttributeList::LDAPAttributList()" << endl);
33 char *name=ldap_first_attribute(ld->getSessionHandle(), msg, &ptr);
35 This code was making problems if no attribute were returned
36 How am I supposed to find decoding errors? ldap_first/next_attribute
37 return 0 in case of error or if there are no more attributes. In either
38 case they set the LDAP* error code to 0x54 (Decoding error) ??? Strange..
40 There will be some changes in the new version of the C-API so that this
41 code should work in the future.
45 throw LDAPException(ld);
49 name=ldap_next_attribute(ld->getSessionHandle(),msg,ptr) ){
50 values=ldap_get_values_len(ld->getSessionHandle(),
52 this->addAttribute(LDAPAttribute(name, values));
54 ldap_value_free_len(values);
60 LDAPAttributeList::~LDAPAttributeList(){
61 DEBUG(LDAP_DEBUG_DESTROY,"LDAPAttributeList::~LDAPAttributList()" << endl);
64 size_t LDAPAttributeList::size() const{
65 DEBUG(LDAP_DEBUG_TRACE,"LDAPAttribute::size()" << endl);
66 return m_attrs.size();
69 bool LDAPAttributeList::empty() const{
70 DEBUG(LDAP_DEBUG_TRACE,"LDAPAttribute::empty()" << endl);
71 return m_attrs.empty();
74 LDAPAttributeList::const_iterator LDAPAttributeList::begin() const{
75 DEBUG(LDAP_DEBUG_TRACE,"LDAPAttribute::begin()" << endl);
76 return m_attrs.begin();
79 LDAPAttributeList::const_iterator LDAPAttributeList::end() const{
80 DEBUG(LDAP_DEBUG_TRACE,"LDAPAttribute::end()" << endl);
84 void LDAPAttributeList::addAttribute(const LDAPAttribute& attr){
85 DEBUG(LDAP_DEBUG_TRACE,"LDAPAttribute::addAttribute()" << endl);
86 DEBUG(LDAP_DEBUG_TRACE | LDAP_DEBUG_PARAMETER,
87 " attr:" << attr << endl);
88 m_attrs.push_back(attr);
92 LDAPMod** LDAPAttributeList::toLDAPModArray() const{
93 DEBUG(LDAP_DEBUG_TRACE,"LDAPAttribute::toLDAPModArray()" << endl);
94 LDAPMod **ret = new LDAPMod*[m_attrs.size()+1];
95 AttrList::const_iterator i;
97 for (i=m_attrs.begin(); i!= m_attrs.end(); i++, j++){
98 ret[j]=i->toLDAPMod();
100 ret[m_attrs.size()]=0;
104 ostream& operator << (ostream& s, const LDAPAttributeList& al){
105 AttrList::const_iterator i;
106 for(i=al.m_attrs.begin(); i!=al.m_attrs.end(); i++){