本文整理汇总了C++中CItemData::Matches方法的典型用法代码示例。如果您正苦于以下问题:C++ CItemData::Matches方法的具体用法?C++ CItemData::Matches怎么用?C++ CItemData::Matches使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CItemData
的用法示例。
在下文中一共展示了CItemData::Matches方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Compare
void PWScore::Compare(PWScore *pothercore,
const CItemData::FieldBits &bsFields, const bool &subgroup_bset,
const bool &bTreatWhiteSpaceasEmpty, const stringT &subgroup_name,
const int &subgroup_object, const int &subgroup_function,
CompareData &list_OnlyInCurrent, CompareData &list_OnlyInComp,
CompareData &list_Conflicts, CompareData &list_Identical,
bool *pbCancel)
{
/*
Purpose:
Compare entries from comparison database (compCore) with current database (m_core)
Algorithm:
Foreach entry in current database {
Find in comparison database - subject to subgroup checking
if found {
Compare
if match
OK
else
There are conflicts; note them & increment numConflicts
} else {
save & increment numOnlyInCurrent
}
}
Foreach entry in comparison database {
Find in current database - subject to subgroup checking
if not found
save & increment numOnlyInComp
}
*/
CItemData::FieldBits bsConflicts(0);
st_CompareData st_data;
int numOnlyInCurrent(0), numOnlyInComp(0), numConflicts(0), numIdentical(0);
ItemListIter currentPos;
for (currentPos = GetEntryIter();
currentPos != GetEntryEndIter();
currentPos++) {
// See if user has cancelled
if (pbCancel != NULL && *pbCancel) {
return;
}
st_data.Empty();
const CItemData ¤tItem = GetEntry(currentPos);
if (!subgroup_bset ||
currentItem.Matches(std::wstring(subgroup_name), subgroup_object,
subgroup_function)) {
st_data.group = currentItem.GetGroup();
st_data.title = currentItem.GetTitle();
st_data.user = currentItem.GetUser();
StringX sx_original;
Format(sx_original, GROUPTITLEUSERINCHEVRONS,
st_data.group.c_str(), st_data.title.c_str(), st_data.user.c_str());
// Update the Wizard page
UpdateWizard(sx_original.c_str());
ItemListIter foundPos = pothercore->Find(st_data.group,
st_data.title, st_data.user);
if (foundPos != pothercore->GetEntryEndIter()) {
// found a match, see if all other fields also match
// Difference flags:
/*
First byte (values in square brackets taken from ItemData.h)
1... .... NAME [0x00] - n/a - depreciated
.1.. .... UUID [0x01] - n/a - unique
..1. .... GROUP [0x02] - not checked - must be identical
...1 .... TITLE [0x03] - not checked - must be identical
.... 1... USER [0x04] - not checked - must be identical
.... .1.. NOTES [0x05]
.... ..1. PASSWORD [0x06]
.... ...1 CTIME [0x07] - not checked by default
Second byte
1... .... PMTIME [0x08] - not checked by default
.1.. .... ATIME [0x09] - not checked by default
..1. .... XTIME [0x0a] - not checked by default
...1 .... RESERVED [0x0b] - not used
.... 1... RMTIME [0x0c] - not checked by default
.... .1.. URL [0x0d]
.... ..1. AUTOTYPE [0x0e]
.... ...1 PWHIST [0x0f]
Third byte
1... .... POLICY [0x10] - not checked by default
.1.. .... XTIME_INT [0x11] - not checked by default
..1. .... RUNCMD [0x12]
...1 .... DCA [0x13]
.... 1... EMAIL [0x14]
.... .1.. PROTECTED [0x15]
.... ..1. SYMBOLS [0x16]
.... ...1 SHIFTDCA [0x17]
Fourth byte
//.........这里部分代码省略.........
示例2: Synchronize
void PWScore::Synchronize(PWScore *pothercore,
const CItemData::FieldBits &bsFields, const bool &subgroup_bset,
const stringT &subgroup_name,
const int &subgroup_object, const int &subgroup_function,
int &numUpdated, CReport *pRpt, bool *pbCancel)
{
/*
Purpose:
Synchronize entries from otherCore to m_core
Algorithm:
Foreach entry in otherCore
Find in m_core
if find a match
update requested fields
*/
std::vector<StringX> vs_updated;
numUpdated = 0;
MultiCommands *pmulticmds = MultiCommands::Create(this);
Command *pcmd1 = UpdateGUICommand::Create(this, UpdateGUICommand::WN_UNDO,
UpdateGUICommand::GUI_UNDO_MERGESYNC);
pmulticmds->Add(pcmd1);
// Make sure we don't add it multiple times
std::map<StringX, StringX> mapRenamedPolicies;
std::vector<StringX> vs_PoliciesAdded;
const StringX sxSync_DateTime = PWSUtil::GetTimeStamp(true).c_str();
ItemListConstIter otherPos;
for (otherPos = pothercore->GetEntryIter();
otherPos != pothercore->GetEntryEndIter();
otherPos++) {
// See if user has cancelled
if (pbCancel != NULL && *pbCancel) {
delete pmulticmds;
return;
}
CItemData otherItem = pothercore->GetEntry(otherPos);
CItemData::EntryType et = otherItem.GetEntryType();
// Do not process Aliases and Shortcuts
if (et == CItemData::ET_ALIAS || et == CItemData::ET_SHORTCUT)
continue;
if (subgroup_bset &&
!otherItem.Matches(subgroup_name, subgroup_object, subgroup_function))
continue;
const StringX sx_otherGroup = otherItem.GetGroup();
const StringX sx_otherTitle = otherItem.GetTitle();
const StringX sx_otherUser = otherItem.GetUser();
StringX sx_mergedentry;
Format(sx_mergedentry, GROUPTITLEUSERINCHEVRONS,
sx_otherGroup.c_str(), sx_otherTitle.c_str(), sx_otherUser.c_str());
ItemListConstIter foundPos = Find(sx_otherGroup, sx_otherTitle, sx_otherUser);
if (foundPos != GetEntryEndIter()) {
// found a match
CItemData curItem = GetEntry(foundPos);
// Don't update if entry is protected
if (curItem.IsProtected())
continue;
CItemData updItem(curItem);
updItem.SetDisplayInfo(NULL);
if (curItem.GetUUID() != otherItem.GetUUID()) {
pws_os::Trace(_T("Synchronize: Mis-match UUIDs for [%ls:%ls:%ls]\n"),
sx_otherGroup.c_str(), sx_otherTitle.c_str(), sx_otherUser.c_str());
}
bool bUpdated(false);
// Do not try and change GROUPTITLE = 0x00 (use GROUP & TITLE separately) or UUID = 0x01
for (size_t i = 2; i < bsFields.size(); i++) {
if (bsFields.test(i)) {
StringX sxValue = otherItem.GetFieldValue(static_cast<CItemData::FieldType>(i));
// Special processing for password policies (default & named)
if (static_cast<CItemData::FieldType>(i) == CItemData::POLICYNAME) {
Command *pPolicyCmd = ProcessPolicyName(pothercore, updItem,
mapRenamedPolicies, vs_PoliciesAdded,
sxValue, bUpdated,
sxSync_DateTime, IDSC_SYNCPOLICY);
if (pPolicyCmd != NULL)
pmulticmds->Add(pPolicyCmd);
} else {
if (sxValue != updItem.GetFieldValue(static_cast<CItemData::FieldType>(i))) {
bUpdated = true;
updItem.SetFieldValue(static_cast<CItemData::FieldType>(i), sxValue);
}
}
}
}
//.........这里部分代码省略.........
示例3: Merge
stringT PWScore::Merge(PWScore *pothercore,
const bool &subgroup_bset,
const stringT &subgroup_name,
const int &subgroup_object, const int &subgroup_function,
CReport *pRpt, bool *pbCancel)
{
std::vector<StringX> vs_added;
std::vector<StringX> vs_AliasesAdded;
std::vector<StringX> vs_ShortcutsAdded;
std::vector<StringX> vs_PoliciesAdded;
std::map<StringX, StringX> mapRenamedPolicies;
const StringX sxMerge_DateTime = PWSUtil::GetTimeStamp(true).c_str();
stringT str_timestring; // To append to title if already in current database
str_timestring = sxMerge_DateTime.c_str();
Remove(str_timestring, _T('/'));
Remove(str_timestring, _T(':'));
/*
Purpose:
Merge entries from otherCore to m_core
Algorithm:
Foreach entry in otherCore
Find in m_core based on group/title/username
if match found {
if all other fields match {
no merge
} else {
add to m_core with new title suffixed with -merged-YYYYMMDD-HHMMSS
}
} else {
add to m_core directly
}
*/
int numAdded = 0;
int numConflicts = 0;
int numAliasesAdded = 0;
int numShortcutsAdded = 0;
uuid_array_t base_uuid, new_base_uuid;
bool bTitleRenamed(false);
StringX sx_merged;
LoadAString(sx_merged, IDSC_MERGED);
MultiCommands *pmulticmds = MultiCommands::Create(this);
Command *pcmd1 = UpdateGUICommand::Create(this, UpdateGUICommand::WN_UNDO,
UpdateGUICommand::GUI_UNDO_MERGESYNC);
pmulticmds->Add(pcmd1);
ItemListConstIter otherPos;
for (otherPos = pothercore->GetEntryIter();
otherPos != pothercore->GetEntryEndIter();
otherPos++) {
// See if user has cancelled
if (pbCancel != NULL && *pbCancel) {
delete pmulticmds;
return _T("");
}
CItemData otherItem = pothercore->GetEntry(otherPos);
CItemData::EntryType et = otherItem.GetEntryType();
// Need to check that entry keyboard shortcut not already in use!
int32 iKBShortcut;
otherItem.GetKBShortcut(iKBShortcut);
CUUID kbshortcut_uuid = GetKBShortcut(iKBShortcut);
bool bKBShortcutInUse = (iKBShortcut != 0&& kbshortcut_uuid != CUUID::NullUUID());
// Handle Aliases and Shortcuts when processing their base entries
if (otherItem.IsDependent())
continue;
if (subgroup_bset &&
!otherItem.Matches(subgroup_name, subgroup_object, subgroup_function))
continue;
const StringX sx_otherGroup = otherItem.GetGroup();
const StringX sx_otherTitle = otherItem.GetTitle();
const StringX sx_otherUser = otherItem.GetUser();
StringX sxMergedEntry;
Format(sxMergedEntry, GROUPTITLEUSERINCHEVRONS,
sx_otherGroup.c_str(), sx_otherTitle.c_str(), sx_otherUser.c_str());
ItemListConstIter foundPos = Find(sx_otherGroup, sx_otherTitle, sx_otherUser);
otherItem.GetUUID(base_uuid);
memcpy(new_base_uuid, base_uuid, sizeof(new_base_uuid));
bTitleRenamed = false;
if (foundPos != GetEntryEndIter()) {
// Found a match, see if other fields also match
CItemData curItem = GetEntry(foundPos);
// Can't merge into a protected entry. If we were going to - add instead
unsigned char ucprotected;
curItem.GetProtected(ucprotected);
//.........这里部分代码省略.........