本文整理汇总了C++中ArchiveTreeNode::nChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ ArchiveTreeNode::nChildren方法的具体用法?C++ ArchiveTreeNode::nChildren怎么用?C++ ArchiveTreeNode::nChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArchiveTreeNode
的用法示例。
在下文中一共展示了ArchiveTreeNode::nChildren方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getItemText
// ----------------------------------------------------------------------------
// ArchiveEntryList::getItemText
//
// Called when the widget requests the text for [item] at [column]
// ----------------------------------------------------------------------------
string ArchiveEntryList::getItemText(long item, long column, long index) const
{
// Get entry
ArchiveEntry* entry = getEntry(index, false);
// Check entry
if (!entry)
return "INVALID INDEX";
// Determine what column we want
int col = columnType(column);
if (col == 0)
return entry->getName(); // Name column
else if (col == 1)
{
// Size column
if (entry->getType() == EntryType::folderType())
{
// Entry is a folder, return the number of entries+subdirectories in it
ArchiveTreeNode* dir = nullptr;
// Get selected directory
if (entry == entry_dir_back)
dir = (ArchiveTreeNode*)current_dir->getParent(); // If it's the 'back directory', get the current dir's parent
else
dir = archive->getDir(entry->getName(), current_dir);
// If it's null, return error
if (!dir)
return "INVALID DIRECTORY";
// Return the number of items in the directory
return S_FMT("%d entries", dir->numEntries() + dir->nChildren());
}
else
return entry->getSizeString(); // Not a folder, just return the normal size string
}
else if (col == 2)
return entry->getTypeString(); // Type column
else if (col == 3)
{
// Index column
if (entry->getType() == EntryType::folderType())
return "";
else
return S_FMT("%d", entry->getParentDir()->entryIndex(entry));
}
else
return "INVALID COLUMN"; // Invalid column
}
示例2: entrySize
// ----------------------------------------------------------------------------
// ArchiveEntryList::entrySize
//
// Returns either the size of the entry at [index], or if it is a folder, the
// number of entries+subfolders within it
// ----------------------------------------------------------------------------
int ArchiveEntryList::entrySize(long index)
{
ArchiveEntry* entry = getEntry(index, false);
if (entry->getType() == EntryType::folderType())
{
ArchiveTreeNode* dir = archive->getDir(entry->getName(), current_dir);
if (dir)
return dir->numEntries() + dir->nChildren();
else
return 0;
}
else
return entry->getSize();
}
示例3: if
/* Archive::findAll
* Returns a list of entries matching the search criteria in
* [options]
*******************************************************************/
vector<ArchiveEntry*> Archive::findAll(search_options_t& options)
{
// Init search variables
ArchiveTreeNode* dir = options.dir;
if (!dir) dir = dir_root;
vector<ArchiveEntry*> ret;
options.match_name.MakeLower(); // Force case-insensitive
// Begin search
// Search entries
for (unsigned a = 0; a < dir->numEntries(); a++)
{
ArchiveEntry* entry = dir->getEntry(a);
// Check type
if (options.match_type)
{
if (entry->getType() == EntryType::unknownType())
{
if (!options.match_type->isThisType(entry))
continue;
}
else if (options.match_type != entry->getType())
continue;
}
// Check name
if (!options.match_name.IsEmpty())
{
// Cut extension if ignoring
wxFileName fn(entry->getName());
if (options.ignore_ext)
{
if (!fn.GetName().MakeLower().Matches(options.match_name))
continue;
}
else if (!fn.GetFullName().MakeLower().Matches(options.match_name))
continue;
}
// Check namespace
if (!options.match_namespace.IsEmpty())
{
if (!(S_CMPNOCASE(detectNamespace(entry), options.match_namespace)))
continue;
}
// Entry passed all checks so far, so we found a match
ret.push_back(entry);
}
// Search subdirectories (if needed)
if (options.search_subdirs)
{
for (unsigned a = 0; a < dir->nChildren(); a++)
{
search_options_t opt = options;
opt.dir = (ArchiveTreeNode*)dir->getChild(a);
// Add any matches to the list
vector<ArchiveEntry*> vec = findAll(opt);
ret.insert(ret.end(), vec.begin(), vec.end());
}
}
// Return matches
return ret;
}
示例4: findLast
/* Archive::findLast
* Returns the last entry matching the search criteria in [options],
* or NULL if no matching entry was found
*******************************************************************/
ArchiveEntry* Archive::findLast(search_options_t& options)
{
// Init search variables
ArchiveTreeNode* dir = options.dir;
if (!dir) dir = dir_root;
options.match_name.MakeLower(); // Force case-insensitive
// Begin search
// Search subdirectories (if needed) (bottom-up)
if (options.search_subdirs)
{
for (int a = dir->nChildren() - 1; a >= 0; a--)
{
search_options_t opt = options;
opt.dir = (ArchiveTreeNode*)dir->getChild(a);
ArchiveEntry* match = findLast(opt);
// If a match was found in this subdir, return it
if (match)
return match;
}
}
// Search entries (bottom-up)
for (int a = dir->numEntries() - 1; a >= 0; a--)
{
ArchiveEntry* entry = dir->getEntry(a);
// Check type
if (options.match_type)
{
if (entry->getType() == EntryType::unknownType())
{
if (!options.match_type->isThisType(entry))
continue;
}
else if (options.match_type != entry->getType())
continue;
}
// Check name
if (!options.match_name.IsEmpty())
{
// Cut extension if ignoring
wxFileName fn(entry->getName());
if (options.ignore_ext)
{
if (!options.match_name.Matches(fn.GetName().MakeLower()))
continue;
}
else if (!options.match_name.Matches(fn.GetFullName().MakeLower()))
continue;
}
// Check namespace
if (!options.match_namespace.IsEmpty())
{
if (!(S_CMPNOCASE(detectNamespace(entry), options.match_namespace)))
continue;
}
// Entry passed all checks so far, so we found a match
return entry;
}
// No matches found
return NULL;
}