From: Ralf Haferkamp Date: Fri, 7 Sep 2001 17:43:55 +0000 (+0000) Subject: added empty() method to the list classes. (Patch was provided by Dan X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1119 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2941993d8fe5ff58eb0ee2abae97c7a5524fac95;p=openldap added empty() method to the list classes. (Patch was provided by Dan Gohman) --- diff --git a/contrib/ldapc++/src/LDAPAttributeList.cpp b/contrib/ldapc++/src/LDAPAttributeList.cpp index 8eec6f72f0..b2b0a4208c 100644 --- a/contrib/ldapc++/src/LDAPAttributeList.cpp +++ b/contrib/ldapc++/src/LDAPAttributeList.cpp @@ -66,6 +66,11 @@ size_t LDAPAttributeList::size() const{ return m_attrs.size(); } +bool LDAPAttributeList::empty() const{ + DEBUG(LDAP_DEBUG_TRACE,"LDAPAttribute::empty()" << endl); + return m_attrs.empty(); +} + LDAPAttributeList::const_iterator LDAPAttributeList::begin() const{ DEBUG(LDAP_DEBUG_TRACE,"LDAPAttribute::begin()" << endl); return m_attrs.begin(); diff --git a/contrib/ldapc++/src/LDAPAttributeList.h b/contrib/ldapc++/src/LDAPAttributeList.h index a2f3dd655d..3b80b4b765 100644 --- a/contrib/ldapc++/src/LDAPAttributeList.h +++ b/contrib/ldapc++/src/LDAPAttributeList.h @@ -55,6 +55,12 @@ class LDAPAttributeList{ */ size_t size() const; + /** + * @return true if there are zero LDAPAttribute-objects currently + * stored in this list. + */ + bool empty() const; + /** * @return A iterator that points to the first element of the list. */ diff --git a/contrib/ldapc++/src/LDAPControlSet.cpp b/contrib/ldapc++/src/LDAPControlSet.cpp index 08cdddc938..004c69eae9 100644 --- a/contrib/ldapc++/src/LDAPControlSet.cpp +++ b/contrib/ldapc++/src/LDAPControlSet.cpp @@ -33,6 +33,11 @@ size_t LDAPControlSet::size() const { return data.size(); } +bool LDAPControlSet::empty() const { + DEBUG(LDAP_DEBUG_TRACE,"LDAPControlSet::empty()" << endl); + return data.empty(); +} + LDAPControlSet::const_iterator LDAPControlSet::begin() const{ DEBUG(LDAP_DEBUG_TRACE,"LDAPControlSet::begin()" << endl); return data.begin(); @@ -51,7 +56,7 @@ void LDAPControlSet::add(const LDAPCtrl& ctrl){ LDAPControl** LDAPControlSet::toLDAPControlArray() const{ DEBUG(LDAP_DEBUG_TRACE, "LDAPControlSet::toLDAPControlArray()" << endl); - if(data.size() == 0){ + if(data.empty()){ return 0; }else{ LDAPControl** ret= new LDAPControl*[data.size()+1]; diff --git a/contrib/ldapc++/src/LDAPControlSet.h b/contrib/ldapc++/src/LDAPControlSet.h index 8538294e01..081c5373dd 100644 --- a/contrib/ldapc++/src/LDAPControlSet.h +++ b/contrib/ldapc++/src/LDAPControlSet.h @@ -53,6 +53,12 @@ class LDAPControlSet { */ size_t size() const ; + /** + * @return true if there are zero LDAPCtrl-objects currently + * stored in this list. + */ + bool empty() const; + /** * @return A iterator that points to the first element of the list. */ diff --git a/contrib/ldapc++/src/LDAPEntryList.cpp b/contrib/ldapc++/src/LDAPEntryList.cpp index 7cf8aa23a7..9d8d859ccc 100644 --- a/contrib/ldapc++/src/LDAPEntryList.cpp +++ b/contrib/ldapc++/src/LDAPEntryList.cpp @@ -21,6 +21,10 @@ size_t LDAPEntryList::size() const{ return m_entries.size(); } +bool LDAPEntryList::empty() const{ + return m_entries.empty(); +} + LDAPEntryList::const_iterator LDAPEntryList::begin() const{ return m_entries.begin(); } diff --git a/contrib/ldapc++/src/LDAPEntryList.h b/contrib/ldapc++/src/LDAPEntryList.h index 4b459642b7..275818bccf 100644 --- a/contrib/ldapc++/src/LDAPEntryList.h +++ b/contrib/ldapc++/src/LDAPEntryList.h @@ -42,6 +42,11 @@ class LDAPEntryList{ */ size_t size() const; + /** + * @return true if there are zero entries currently stored in the list. + */ + bool empty() const; + /** * @return An iterator pointing to the first element of the list. */ diff --git a/contrib/ldapc++/src/LDAPException.cpp b/contrib/ldapc++/src/LDAPException.cpp index f3022d06eb..2b4d417e49 100644 --- a/contrib/ldapc++/src/LDAPException.cpp +++ b/contrib/ldapc++/src/LDAPException.cpp @@ -46,7 +46,7 @@ const string& LDAPException::getServerMsg() const{ ostream& operator << (ostream& s, LDAPException e){ s << "Error " << e.m_res_code << ": " << e.m_res_string; - if (e.m_err_string.size() > 0) { + if (!e.m_err_string.empty()) { s << endl << "additional info: " << e.m_err_string ; } return s; diff --git a/contrib/ldapc++/src/LDAPReferenceList.cpp b/contrib/ldapc++/src/LDAPReferenceList.cpp index 572c96a45d..dc4f49ea2e 100644 --- a/contrib/ldapc++/src/LDAPReferenceList.cpp +++ b/contrib/ldapc++/src/LDAPReferenceList.cpp @@ -21,6 +21,10 @@ size_t LDAPReferenceList::size() const{ return m_refs.size(); } +bool LDAPReferenceList::empty() const{ + return m_refs.empty(); +} + LDAPReferenceList::const_iterator LDAPReferenceList::begin() const{ return m_refs.begin(); } diff --git a/contrib/ldapc++/src/LDAPReferenceList.h b/contrib/ldapc++/src/LDAPReferenceList.h index 4d26fdc54f..4891e7a9be 100644 --- a/contrib/ldapc++/src/LDAPReferenceList.h +++ b/contrib/ldapc++/src/LDAPReferenceList.h @@ -42,6 +42,12 @@ class LDAPReferenceList{ */ size_t size() const; + /** + * @return true if there are zero LDAPSearchReference-objects + * currently stored in this list. + */ + bool empty() const; + /** * @return A iterator that points to the first element of the list. */ diff --git a/contrib/ldapc++/src/LDAPUrlList.cpp b/contrib/ldapc++/src/LDAPUrlList.cpp index 6e61fa0bcb..38e2c7da0d 100644 --- a/contrib/ldapc++/src/LDAPUrlList.cpp +++ b/contrib/ldapc++/src/LDAPUrlList.cpp @@ -35,6 +35,10 @@ size_t LDAPUrlList::size() const{ return m_urls.size(); } +bool LDAPUrlList::empty() const{ + return m_urls.empty(); +} + LDAPUrlList::const_iterator LDAPUrlList::begin() const{ return m_urls.begin(); } diff --git a/contrib/ldapc++/src/LDAPUrlList.h b/contrib/ldapc++/src/LDAPUrlList.h index 848c4f6c77..f5cd3e4505 100644 --- a/contrib/ldapc++/src/LDAPUrlList.h +++ b/contrib/ldapc++/src/LDAPUrlList.h @@ -48,6 +48,12 @@ class LDAPUrlList{ */ size_t size() const; + /** + * @return true if there are zero LDAPUrl-objects currently + * stored in this list. + */ + bool empty() const; + /** * @return A iterator that points to the first element of the list. */ diff --git a/contrib/ldapc++/src/StringList.cpp b/contrib/ldapc++/src/StringList.cpp index 4189c39200..287547218f 100644 --- a/contrib/ldapc++/src/StringList.cpp +++ b/contrib/ldapc++/src/StringList.cpp @@ -29,7 +29,7 @@ StringList::~StringList(){ } char** StringList::toCharArray() const{ - if(size() > 0){ + if(!empty()){ char** ret = new char*[size()+1]; StringList::const_iterator i; int j=0; @@ -53,6 +53,10 @@ size_t StringList::size() const{ return m_data.size(); } +bool StringList::empty() const{ + return m_data.empty(); +} + StringList::const_iterator StringList::begin() const{ return m_data.begin(); } diff --git a/contrib/ldapc++/src/StringList.h b/contrib/ldapc++/src/StringList.h index dc3d678213..cb0ac0bfd5 100644 --- a/contrib/ldapc++/src/StringList.h +++ b/contrib/ldapc++/src/StringList.h @@ -62,6 +62,12 @@ class StringList{ */ size_t size() const; + /** + * @return true if there are zero strings currently + * stored in this list. + */ + bool empty() const; + /** * @return A iterator that points to the first element of the list. */