]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPAttributeList.cpp
b4ab735d2c5de3252e404876c7e4682e36c54e2d
[openldap] / contrib / ldapc++ / src / LDAPAttributeList.cpp
1 /*
2  * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
3  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
4  */
5
6 // $Id: LDAPAttributeList.cpp,v 1.6 2000/08/31 17:43:48 rhafer Exp $
7
8 #include "debug.h"
9 #include "LDAPAttributeList.h"
10
11 LDAPAttributeList::LDAPAttributeList(){
12 }
13
14 LDAPAttributeList::LDAPAttributeList(const LDAPAttributeList& al){
15         m_attrs=al.m_attrs;
16 }
17
18 LDAPAttributeList::LDAPAttributeList(const LDAPAsynConnection *ld, 
19         LDAPMessage *msg){
20         BerElement *ptr;
21         char *name;
22         for     (name=ldap_first_attribute(ld->getSessionHandle(), msg, &ptr);
23                         name !=0;
24                         name=ldap_next_attribute(ld->getSessionHandle(),msg,ptr) ){
25                 BerValue **values=ldap_get_values_len(ld->getSessionHandle(),
26                 msg, name);
27                 this->addAttribute(LDAPAttribute(name, values));
28         }
29 }
30
31
32 void LDAPAttributeList::addAttribute(const LDAPAttribute& attr){
33         m_attrs.push_back(attr);
34 }
35
36 LDAPAttributeList::~LDAPAttributeList(){
37         DEBUG(LDAP_DEBUG_TRACE,"LDAPAttributeList::~LDAPAttributList()" << endl);
38 }
39
40 void LDAPAttributeList::find(char *name){
41 }
42
43 LDAPMod** LDAPAttributeList::toLDAPModArray(){
44         LDAPMod **ret = new LDAPMod*[m_attrs.size()+1];
45         AttrList::const_iterator i;
46         int j=0;
47         for (i=m_attrs.begin(); i!= m_attrs.end(); i++, j++){
48                 ret[j]=i->toLDAPMod();
49         }
50         ret[m_attrs.size()]=0;
51         return ret;
52 }
53
54 ostream& operator << (ostream& s, const LDAPAttributeList& al){
55         AttrList::const_iterator i;
56         for(i=al.m_attrs.begin(); i!=al.m_attrs.end(); i++){
57                 s << *i << "; ";
58         }
59         return s;
60 }