Hello All
please help me understand the below code snippet,

LDAPControl** LDAPControlSet::toLDAPControlArray() const{
    DEBUG(LDAP_DEBUG_TRACE, "LDAPControlSet::toLDAPControlArray()" << endl);
    if(data.empty()){
        return 0;
    }else{
        LDAPControl** ret= new LDAPControl*[data.size()+1];
        CtrlList::const_iterator i;
        int j=0;
        for(i=data.begin(); i!=data.end(); i++,j++){
            ret[j] = i->getControlStruct();
        }
        ret[data.size()]=0;
        return ret;
    }
}

please note in the above code,
data and const_iterator are of list type (typedef by CtrlList), which is private member of the class
thanks.

ermithun,

I saw this code or something like this in almost all post started by you. Try to solve your problems with single thread; especially when your program/problem definition is same or minor different.

Yes, I agree to adatapost. Just stick onto one post and then you can ask questions... That way everyone will know what exactly is happening.

Now to your problem,
Firstly, We would like to know where in exactly are you having trouble in understanding the code.

Use the color tags [color="red"] some code in here [/color] To specify those places.

It is also a little hard to know what the function calls of "DEBUG" do as we donot know its implementation.

However the other part is understandable, By Logic though its not by exact understanding.

For example:

LDAPControl

I assume that this is a class but I donot know the members in it nor the functions it has. So I stick onto the assumption.

With that reason, It is hard to tell what exactly going on but we can give you a faint picture which you will have to figure out :) (Given that you specify the places in which you donot understand the code.)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.