本文整理汇总了C++中CObjectVector::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ CObjectVector::Add方法的具体用法?C++ CObjectVector::Add怎么用?C++ CObjectVector::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CObjectVector
的用法示例。
在下文中一共展示了CObjectVector::Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadPluginInfoList
void ReadPluginInfoList(CObjectVector<CPluginInfo> &plugins)
{
plugins.Clear();
UString baseFolderPrefix;
GetProgramFolderPath(baseFolderPrefix);
{
CPluginInfo pluginInfo;
pluginInfo.FilePath = baseFolderPrefix + L"7-zip.dll";
if (::ReadPluginInfo(pluginInfo, false))
plugins.Add(pluginInfo);
}
UString folderPath = baseFolderPrefix + L"Plugins" WSTRING_PATH_SEPARATOR;
NFind::CEnumeratorW enumerator(folderPath + L"*");
NFind::CFileInfoW fileInfo;
while (enumerator.Next(fileInfo))
{
if (fileInfo.IsDir())
continue;
CPluginInfo pluginInfo;
pluginInfo.FilePath = folderPath + fileInfo.Name;
if (::ReadPluginInfo(pluginInfo, true))
plugins.Add(pluginInfo);
}
}
示例2: UpdateProduce
void UpdateProduce(
const CObjectVector<CDirItem> &dirItems,
const CObjectVector<CArchiveItem> &archiveItems,
const CObjectVector<CUpdatePair> &updatePairs,
const NUpdateArchive::CActionSet &actionSet,
CObjectVector<CUpdatePair2> &operationChain)
{
for(int i = 0; i < updatePairs.Size(); i++)
{
// CUpdateArchiveRange aRange;
const CUpdatePair &pair = updatePairs[i];
CUpdatePair2 pair2;
pair2.IsAnti = false;
pair2.ArchiveItemIndex = pair.ArchiveItemIndex;
pair2.DirItemIndex = pair.DirItemIndex;
pair2.ExistInArchive = (pair.State != NPairState::kOnlyOnDisk);
pair2.ExistOnDisk = (pair.State != NPairState::kOnlyInArchive);
switch(actionSet.StateActions[pair.State])
{
case NPairAction::kIgnore:
/*
if (pair.State != NPairState::kOnlyOnDisk)
IgnoreArchiveItem(m_ArchiveItems[pair.ArchiveItemIndex]);
// cout << "deleting";
*/
break;
case NPairAction::kCopy:
{
if (pair.State == NPairState::kOnlyOnDisk)
throw kUpdateActionSetCollision;
pair2.NewData = pair2.NewProperties = false;
operationChain.Add(pair2);
break;
}
case NPairAction::kCompress:
{
if (pair.State == NPairState::kOnlyInArchive ||
pair.State == NPairState::kNotMasked)
throw kUpdateActionSetCollision;
pair2.NewData = pair2.NewProperties = true;
operationChain.Add(pair2);
break;
}
case NPairAction::kCompressAsAnti:
{
pair2.IsAnti = true;
pair2.NewData = pair2.NewProperties = true;
operationChain.Add(pair2);
break;
}
}
}
}
示例3: MyGetLogicalDriveStrings
bool MyGetLogicalDriveStrings(CObjectVector<FString> &driveStrings)
{
driveStrings.Clear();
#ifndef _UNICODE
if (!g_IsNT)
{
driveStrings.Clear();
UINT32 size = GetLogicalDriveStrings(0, NULL);
if (size == 0)
return false;
CObjArray<char> buf(size);
UINT32 newSize = GetLogicalDriveStrings(size, buf);
if (newSize == 0 || newSize > size)
return false;
AString s;
UINT32 prev = 0;
for (UINT32 i = 0; i < newSize; i++)
{
if (buf[i] == 0)
{
s = buf + prev;
prev = i + 1;
driveStrings.Add(fas2fs(s));
}
}
return prev == newSize;
}
else
#endif
{
UINT32 size = GetLogicalDriveStringsW(0, NULL);
if (size == 0)
return false;
CObjArray<wchar_t> buf(size);
UINT32 newSize = GetLogicalDriveStringsW(size, buf);
if (newSize == 0 || newSize > size)
return false;
UString s;
UINT32 prev = 0;
for (UINT32 i = 0; i < newSize; i++)
{
if (buf[i] == 0)
{
s = buf + prev;
prev = i + 1;
driveStrings.Add(us2fs(s));
}
}
return prev == newSize;
}
}
示例4: ReadInternalAssociations
void ReadInternalAssociations(CObjectVector<CExtInfo> &items)
{
items.Clear();
NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
CKey associationsKey;
if (associationsKey.Open(HKEY_CURRENT_USER, kAssociationsPath, KEY_READ) != ERROR_SUCCESS)
return;
CSysStringVector extNames;
associationsKey.EnumKeys(extNames);
for(int i = 0; i < extNames.Size(); i++)
{
const CSysString extName = extNames[i];
CExtInfo extInfo;
// extInfo.Enabled = false;
extInfo.Ext = GetUnicodeString(extName);
CKey key;
if (key.Open(associationsKey, extName, KEY_READ) != ERROR_SUCCESS)
return;
UString pluginsString;
key.QueryValue(kExtPlugins, pluginsString);
SplitString(pluginsString, extInfo.Plugins);
/*
if (key.QueryValue(kExtEnabled, extInfo.Enabled) != ERROR_SUCCESS)
extInfo.Enabled = false;
*/
items.Add(extInfo);
}
}
示例5: LoadExternalCodecs
HRESULT LoadExternalCodecs(ICompressCodecsInfo *codecsInfo, CObjectVector<CCodecInfoEx> &externalCodecs)
{
UInt32 num;
RINOK(codecsInfo->GetNumberOfMethods(&num));
for (UInt32 i = 0; i < num; i++)
{
CCodecInfoEx info;
NWindows::NCOM::CPropVariant prop;
RINOK(codecsInfo->GetProperty(i, NMethodPropID::kID, &prop));
// if (prop.vt != VT_BSTR)
// info.Id.IDSize = (Byte)SysStringByteLen(prop.bstrVal);
// memmove(info.Id.ID, prop.bstrVal, info.Id.IDSize);
if (prop.vt != VT_UI8)
{
continue; // old Interface
// return E_INVALIDARG;
}
info.Id = prop.uhVal.QuadPart;
prop.Clear();
RINOK(codecsInfo->GetProperty(i, NMethodPropID::kName, &prop));
if (prop.vt == VT_BSTR)
info.Name = prop.bstrVal;
else if (prop.vt != VT_EMPTY)
return E_INVALIDARG;;
RINOK(ReadNumberOfStreams(codecsInfo, i, NMethodPropID::kInStreams, info.NumInStreams));
RINOK(ReadNumberOfStreams(codecsInfo, i, NMethodPropID::kOutStreams, info.NumOutStreams));
RINOK(ReadIsAssignedProp(codecsInfo, i, NMethodPropID::kEncoderIsAssigned, info.EncoderIsAssigned));
RINOK(ReadIsAssignedProp(codecsInfo, i, NMethodPropID::kDecoderIsAssigned, info.DecoderIsAssigned));
externalCodecs.Add(info);
}
return S_OK;
}
示例6: AddProp
static void AddProp(CObjectVector<CProperty> &properties, const UString &name, const UString &value)
{
CProperty prop;
prop.Name = name;
prop.Value = value;
properties.Add(prop);
}
示例7: ControlGetActivePanelSelectedOrCurrentItems
bool CStartupInfo::ControlGetActivePanelSelectedOrCurrentItems(
CObjectVector<PluginPanelItem> &pluginPanelItems)
{
pluginPanelItems.Clear();
PanelInfo panelInfo;
if(!ControlGetActivePanelInfo(panelInfo))
return false;
if(panelInfo.ItemsNumber <= 0)
throw "There are no items";
if (panelInfo.SelectedItemsNumber == 0)
pluginPanelItems.Add(panelInfo.PanelItems[panelInfo.CurrentItem]);
else
for (int i = 0; i < panelInfo.SelectedItemsNumber; i++)
pluginPanelItems.Add(panelInfo.SelectedItems[i]);
return true;
}
示例8: GetTextPairs
static bool GetTextPairs(const UString &srcString, CObjectVector<CTextPair> &pairs)
{
pairs.Clear();
unsigned pos = 0;
if (srcString.Len() > 0)
{
if (srcString[0] == kBOM)
pos++;
}
while (pos < srcString.Len())
{
unsigned finishPos;
UString id = GetIDString((const wchar_t *)srcString + pos, finishPos);
pos += finishPos;
if (id.IsEmpty())
continue;
UString value = GetValueString((const wchar_t *)srcString + pos, finishPos);
pos += finishPos;
if (!id.IsEmpty())
{
CTextPair pair;
pair.ID = id;
pair.Value = value;
pairs.Add(pair);
}
}
return true;
}
示例9: AddProp
void CFieldPrinter::AddProp(const wchar_t *name, PROPID propID, bool isRawProp)
{
CFieldInfo f;
f.PropID = propID;
f.IsRawProp = isRawProp;
GetPropName(propID, name, f.NameA, f.NameU);
f.NameU.AddAscii(" = ");
if (!f.NameA.IsEmpty())
f.NameA += " = ";
else
{
const UString &s = f.NameU;
AString sA;
unsigned i;
for (i = 0; i < s.Len(); i++)
{
wchar_t c = s[i];
if (c >= 0x80)
break;
sA += (char)c;
}
if (i == s.Len())
f.NameA = sA;
}
_fields.Add(f);
}
示例10: GetTextConfig
bool GetTextConfig(const AString &s, CObjectVector<CTextConfigPair> &pairs)
{
pairs.Clear();
unsigned pos = 0;
/////////////////////
// read strings
for (;;)
{
if (!SkipSpaces(s, pos))
break;
CTextConfigPair pair;
unsigned finishPos;
AString temp = GetIDString(((const char *)s) + pos, finishPos);
if (!ConvertUTF8ToUnicode(temp, pair.ID))
return false;
if (finishPos == 0)
return false;
pos += finishPos;
if (!SkipSpaces(s, pos))
return false;
if (s[pos] != '=')
return false;
pos++;
if (!SkipSpaces(s, pos))
return false;
if (s[pos] != '\"')
return false;
pos++;
AString message;
for (;;)
{
if (pos >= s.Len())
return false;
char c = s[pos++];
if (c == '\"')
break;
if (c == '\\')
{
c = s[pos++];
switch (c)
{
case 'n': message += '\n'; break;
case 't': message += '\t'; break;
case '\\': message += '\\'; break;
case '\"': message += '\"'; break;
default: message += '\\'; message += c; break;
}
}
else
message += c;
}
if (!ConvertUTF8ToUnicode(message, pair.String))
return false;
pairs.Add(pair);
}
return true;
}
示例11: GetNextFile
HRESULT CDirEnumerator::GetNextFile(NFind::CFileInfo &fileInfo, bool &filled, FString &resPath)
{
filled = false;
for (;;)
{
if (Enumerators.IsEmpty())
{
if (Index >= FileNames.Size())
return S_OK;
const FString &path = FileNames[Index];
int pos = path.ReverseFind(FCHAR_PATH_SEPARATOR);
resPath.Empty();
if (pos >= 0)
resPath = path.Left(pos + 1);
#ifdef _WIN32
// it's for "c:" paths/
if (BasePrefix.IsEmpty() && path.Length() == 2 && path[1] == ':')
{
fileInfo.Name = path;
fileInfo.Attrib = FILE_ATTRIBUTE_DIRECTORY;
fileInfo.Size = 0;
}
else
#endif
if (!fileInfo.Find(BasePrefix + path))
{
WRes errorCode = GetNormalizedError();
resPath = path;
return errorCode;
}
Index++;
break;
}
bool found;
if (!Enumerators.Back().Next(fileInfo, found))
{
HRESULT errorCode = GetNormalizedError();
resPath = Prefixes.Back();
return errorCode;
}
if (found)
{
resPath = Prefixes.Back();
break;
}
Enumerators.DeleteBack();
Prefixes.DeleteBack();
}
resPath += fileInfo.Name;
if (!FlatMode && fileInfo.IsDir())
{
FString prefix = resPath + FCHAR_PATH_SEPARATOR;
Enumerators.Add(NFind::CEnumerator(BasePrefix + prefix + FCHAR_ANY_MASK));
Prefixes.Add(prefix);
}
filled = true;
return S_OK;
}
示例12: EnumerateArchiveItems
static HRESULT EnumerateArchiveItems(CAgent *agent,
const CProxyFolder &item,
const UString &prefix,
CObjectVector<CArcItem> &arcItems)
{
int i;
for (i = 0; i < item.Files.Size(); i++)
{
const CProxyFile &fileItem = item.Files[i];
CArcItem ai;
RINOK(::GetFileTime(agent, fileItem.Index, ai.MTime));
CPropVariant property;
agent->GetArchive()->GetProperty(fileItem.Index, kpidSize, &property);
ai.SizeDefined = (property.vt != VT_EMPTY);
if (ai.SizeDefined)
ai.Size = ConvertPropVariantToUInt64(property);
ai.IsDir = false;
ai.Name = prefix + fileItem.Name;
ai.Censored = true; // test it
ai.IndexInServer = fileItem.Index;
arcItems.Add(ai);
}
for (i = 0; i < item.Folders.Size(); i++)
{
const CProxyFolder &dirItem = item.Folders[i];
UString fullName = prefix + dirItem.Name;
if(dirItem.IsLeaf)
{
CArcItem ai;
RINOK(::GetFileTime(agent, dirItem.Index, ai.MTime));
ai.IsDir = true;
ai.SizeDefined = false;
ai.Name = fullName;
ai.Censored = true; // test it
ai.IndexInServer = dirItem.Index;
arcItems.Add(ai);
}
RINOK(EnumerateArchiveItems(agent, dirItem, fullName + UString(WCHAR_PATH_SEPARATOR), arcItems));
}
return S_OK;
}
示例13: SetCompressionMethod
HRESULT CHandler::SetCompressionMethod(
CCompressionMethodMode &methodMode,
CCompressionMethodMode &headerMethod)
{
HRESULT res = SetCompressionMethod(methodMode, _methods
#ifdef COMPRESS_MT
, _numThreads
#endif
);
RINOK(res);
methodMode.Binds = _binds;
if (_compressHeaders)
{
// headerMethod.Methods.Add(methodMode.Methods.Back());
CObjectVector<COneMethodInfo> headerMethodInfoVector;
COneMethodInfo oneMethodInfo;
oneMethodInfo.MethodName = kLZMAMethodName;
{
CProp prop;
prop.Id = NCoderPropID::kMatchFinder;
prop.Value = kLzmaMatchFinderForHeaders;
oneMethodInfo.Props.Add(prop);
}
{
CProp prop;
prop.Id = NCoderPropID::kAlgorithm;
prop.Value = kAlgorithmForHeaders;
oneMethodInfo.Props.Add(prop);
}
{
CProp prop;
prop.Id = NCoderPropID::kNumFastBytes;
prop.Value = (UInt32)kNumFastBytesForHeaders;
oneMethodInfo.Props.Add(prop);
}
{
CProp prop;
prop.Id = NCoderPropID::kDictionarySize;
prop.Value = (UInt32)kDictionaryForHeaders;
oneMethodInfo.Props.Add(prop);
}
headerMethodInfoVector.Add(oneMethodInfo);
HRESULT res = SetCompressionMethod(headerMethod, headerMethodInfoVector
#ifdef COMPRESS_MT
,1
#endif
);
RINOK(res);
}
return S_OK;
}
示例14: ReadUnpackInfo
void CInArchive::ReadUnpackInfo(
const CObjectVector<CByteBuffer> *dataVector,
CObjectVector<CFolder> &folders)
{
WaitAttribute(NID::kFolder);
CNum numFolders = ReadNum();
{
CStreamSwitch streamSwitch;
streamSwitch.Set(this, dataVector);
folders.Clear();
folders.Reserve(numFolders);
for (CNum i = 0; i < numFolders; i++)
{
folders.Add(CFolder());
GetNextFolderItem(folders.Back());
}
}
WaitAttribute(NID::kCodersUnpackSize);
CNum i;
for (i = 0; i < numFolders; i++)
{
CFolder &folder = folders[i];
CNum numOutStreams = folder.GetNumOutStreams();
folder.UnpackSizes.Reserve(numOutStreams);
for (CNum j = 0; j < numOutStreams; j++)
folder.UnpackSizes.Add(ReadNumber());
}
for (;;)
{
UInt64 type = ReadID();
if (type == NID::kEnd)
return;
if (type == NID::kCRC)
{
CBoolVector crcsDefined;
CRecordVector<UInt32> crcs;
ReadHashDigests(numFolders, crcsDefined, crcs);
for (i = 0; i < numFolders; i++)
{
CFolder &folder = folders[i];
folder.UnpackCRCDefined = crcsDefined[i];
folder.UnpackCRC = crcs[i];
}
continue;
}
SkipData();
}
}
示例15: ParseDirItem
static HRESULT ParseDirItem(const Byte *base, size_t pos, size_t size,
const UString &prefix, CObjectVector<CItem> &items)
{
for (;;)
{
if (pos + 8 > size)
return S_FALSE;
const Byte *p = base + pos;
UInt64 length = Get64(p);
if (length == 0)
return S_OK;
if (pos + 102 > size || pos + length + 8 > size || length > ((UInt64)1 << 62))
return S_FALSE;
CItem item;
item.Attrib = Get32(p + 8);
// item.SecurityId = Get32(p + 0xC);
UInt64 subdirOffset = Get64(p + 0x10);
GetFileTimeFromMem(p + 0x28, &item.CTime);
GetFileTimeFromMem(p + 0x30, &item.ATime);
GetFileTimeFromMem(p + 0x38, &item.MTime);
memcpy(item.Hash, p + 0x40, kHashSize);
// UInt16 shortNameLen = Get16(p + 98);
UInt16 fileNameLen = Get16(p + 100);
size_t tempPos = pos + 102;
if (tempPos + fileNameLen > size)
return S_FALSE;
wchar_t *sz = item.Name.GetBuffer(prefix.Length() + fileNameLen / 2 + 1);
MyStringCopy(sz, (const wchar_t *)prefix);
sz += prefix.Length();
for (UInt16 i = 0; i + 2 <= fileNameLen; i += 2)
*sz++ = Get16(base + tempPos + i);
*sz++ = '\0';
item.Name.ReleaseBuffer();
if (fileNameLen == 0 && item.isDir() && !item.HasStream())
{
item.Attrib = 0x10; // some swm archives have system/hidden attributes for root
item.Name.Delete(item.Name.Length() - 1);
}
items.Add(item);
pos += (size_t)length;
if (item.isDir() && (subdirOffset != 0))
{
if (subdirOffset >= size)
return S_FALSE;
RINOK(ParseDirItem(base, (size_t)subdirOffset, size, item.Name + WCHAR_PATH_SEPARATOR, items));
}
}
}