Back to index

openldap  2.4.31
LDAPSearchResults.cpp
Go to the documentation of this file.
00001 // $OpenLDAP$
00002 /*
00003  * Copyright 2000-2012 The OpenLDAP Foundation, All Rights Reserved.
00004  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
00005  */
00006 
00007 
00008 #include "LDAPException.h"
00009 #include "LDAPSearchResult.h"
00010 #include "LDAPResult.h"
00011 
00012 #include "LDAPSearchResults.h"
00013 
00014 LDAPSearchResults::LDAPSearchResults(){
00015     entryPos = entryList.begin();
00016     refPos = refList.begin();
00017 }
00018 
00019 LDAPResult* LDAPSearchResults::readMessageQueue(LDAPMessageQueue* msg){
00020     if(msg != 0){
00021         LDAPMsg* res=0;
00022         for(;;){
00023             try{
00024                 res = msg->getNext();
00025             }catch (LDAPException e){
00026                 throw;
00027             }
00028             switch(res->getMessageType()){ 
00029                 case LDAPMsg::SEARCH_ENTRY :
00030                     entryList.addEntry(*((LDAPSearchResult*)res)->getEntry());
00031                 break;
00032                 case LDAPMsg::SEARCH_REFERENCE :
00033                     refList.addReference(*((LDAPSearchReference*)res));
00034                 break;
00035                 default:
00036                     entryPos=entryList.begin();
00037                     refPos=refList.begin();
00038                     return ((LDAPResult*) res);
00039             }
00040             delete res;
00041             res=0;
00042         }
00043     }
00044     return 0;
00045 }
00046 
00047 LDAPEntry* LDAPSearchResults::getNext(){
00048     if( entryPos != entryList.end() ){
00049         LDAPEntry* ret= new LDAPEntry(*entryPos);
00050         entryPos++;
00051         return ret;
00052     }
00053     if( refPos != refList.end() ){
00054         LDAPUrlList urls= refPos->getUrls();
00055         refPos++;
00056         throw(LDAPReferralException(urls));
00057     }
00058     return 0;
00059 }
00060