UsbDkHelper: Introduce key iterator for RegAccess
Signed-off-by: Kirill Moizik <kirill@daynix.com> Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
This commit is contained in:
parent
0f2b5bdd48
commit
ae3258facb
3 changed files with 55 additions and 0 deletions
|
|
@ -626,3 +626,15 @@ VOID UsbDkRegAccess::FormatFullRegPath(LPTSTR lpzFullPathBuff, DWORD_PTR dwNumbe
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
VOID UsbDkRegAccess::key_iterator::advance()
|
||||
{
|
||||
assert(!m_End);
|
||||
|
||||
if (!m_Root->ReadKeyName(m_CurrentKeyName,
|
||||
TBUF_SIZEOF(m_CurrentKeyName),
|
||||
m_NextIndex++))
|
||||
{
|
||||
m_End = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,46 @@ public:
|
|||
UsbDkRegAccess(HKEY hNewPrKey, LPCTSTR lpzNewRegPath);
|
||||
virtual ~UsbDkRegAccess();
|
||||
|
||||
class key_iterator
|
||||
{
|
||||
public:
|
||||
key_iterator(const UsbDkRegAccess &Root)
|
||||
: m_Root(&Root)
|
||||
, m_End(false)
|
||||
{
|
||||
advance();
|
||||
}
|
||||
|
||||
key_iterator()
|
||||
{}
|
||||
|
||||
const key_iterator& operator++()
|
||||
{
|
||||
advance();
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator !=(const key_iterator& other) const
|
||||
{ return !m_End || !other.m_End; }
|
||||
|
||||
LPCTSTR operator *()
|
||||
{ return m_CurrentKeyName; }
|
||||
|
||||
private:
|
||||
void advance();
|
||||
|
||||
const UsbDkRegAccess* m_Root = nullptr;
|
||||
TCHAR m_CurrentKeyName[DEFAULT_REG_ENTRY_DATA_LEN] = {};
|
||||
int m_NextIndex = 0;
|
||||
bool m_End = true;
|
||||
};
|
||||
|
||||
key_iterator begin() const
|
||||
{ return key_iterator(*this); }
|
||||
|
||||
key_iterator end() const
|
||||
{ return key_iterator(); }
|
||||
|
||||
VOID SetPrimaryKey(HKEY hNewPrKey);
|
||||
BOOL SetRegPath(LPCTSTR lpzNewRegPath);
|
||||
HKEY GetPrimaryKey(VOID);
|
||||
|
|
|
|||
|
|
@ -50,6 +50,9 @@
|
|||
#include <vector>
|
||||
#include <winscard.h>
|
||||
|
||||
//new behavior: elements of array 'array' will be default initialized
|
||||
#pragma warning(disable : 4351)
|
||||
|
||||
#include "tstrings.h"
|
||||
#include "Exception.h"
|
||||
#include "Utils.h"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue