#ifndef _SECURITY_KCCURSOR_H_
#define _SECURITY_KCCURSOR_H_
#include <security_keychain/StorageManager.h>
namespace Security
{
namespace KeychainCore
{
class KCCursorImpl : public SecCFObject, public CssmAutoQuery
{
NOCOPY(KCCursorImpl)
public:
SECCFFUNCTIONS(KCCursorImpl, SecKeychainSearchRef, errSecInvalidSearchRef, gTypes().KCCursorImpl)
friend class KCCursor;
protected:
KCCursorImpl(const StorageManager::KeychainList &searchList, SecItemClass itemClass, const SecKeychainAttributeList *attrList, CSSM_DB_CONJUNCTIVE dbConjunctive, CSSM_DB_OPERATOR dbOperator);
KCCursorImpl(const StorageManager::KeychainList &searchList, const SecKeychainAttributeList *attrList);
public:
virtual ~KCCursorImpl() throw();
bool next(Item &item);
private:
StorageManager::KeychainList mSearchList;
StorageManager::KeychainList::iterator mCurrent;
CssmClient::DbCursor mDbCursor;
bool mAllFailed;
protected:
Mutex mMutex;
};
class KCCursor : public SecPointer<KCCursorImpl>
{
public:
KCCursor() {}
KCCursor(KCCursorImpl *impl) : SecPointer<KCCursorImpl>(impl) {}
KCCursor(const StorageManager::KeychainList &searchList, const SecKeychainAttributeList *attrList)
: SecPointer<KCCursorImpl>(new KCCursorImpl(searchList, attrList)) {}
KCCursor(const StorageManager::KeychainList &searchList, SecItemClass itemClass, const SecKeychainAttributeList *attrList, CSSM_DB_CONJUNCTIVE dbConjunctive=CSSM_DB_AND, CSSM_DB_OPERATOR dbOperator=CSSM_DB_EQUAL)
: SecPointer<KCCursorImpl>(new KCCursorImpl(searchList, itemClass, attrList, dbConjunctive, dbOperator)) {}
typedef KCCursorImpl Impl;
};
}
}
#endif // !_SECURITY_KCCURSOR_H_