本文整理汇总了C++中BQuery::PushAttr方法的典型用法代码示例。如果您正苦于以下问题:C++ BQuery::PushAttr方法的具体用法?C++ BQuery::PushAttr怎么用?C++ BQuery::PushAttr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BQuery
的用法示例。
在下文中一共展示了BQuery::PushAttr方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
uint32
FetchQuery(query_op op, const char* selection, vector<BString>& results,
bool caseSensitive = false)
{
BQuery query;
query.PushAttr("BEOS:TYPE");
query.PushString("application/x-vnd.Be-doc_bookmark");
query.PushOp(B_EQ);
query.PushAttr("name");
query.PushString(selection, caseSensitive);
query.PushOp(op);
query.PushOp(B_AND);
BVolume vol;
BVolumeRoster roster;
roster.GetBootVolume(&vol);
query.SetVolume(&vol);
if (B_NO_INIT == query.Fetch())
return 0;
BEntry entry;
BPath path;
int32 counter = 0;
while (query.GetNextEntry(&entry) != B_ENTRY_NOT_FOUND) {
if (entry.InitCheck() == B_OK) {
entry.GetPath(&path);
if (path.InitCheck() == B_OK) {
results.push_back(path.Path());
counter++;
}
}
}
return counter;
}
示例2:
void
POP3Protocol::CheckForDeletedMessages()
{
{
// Delete things from the manifest no longer on the server
BStringList list;
NotHere(fUniqueIDs, fManifest, &list);
fManifest.Remove(list);
}
if (!fSettings.FindBool("delete_remote_when_local")
|| fManifest.CountStrings() == 0)
return;
BStringList toDelete;
BStringList queryContents;
BVolumeRoster volumes;
BVolume volume;
while (volumes.GetNextVolume(&volume) == B_OK) {
BQuery fido;
entry_ref entry;
fido.SetVolume(&volume);
fido.PushAttr(B_MAIL_ATTR_ACCOUNT_ID);
fido.PushInt32(fAccountSettings.AccountID());
fido.PushOp(B_EQ);
fido.Fetch();
BString uid;
while (fido.GetNextRef(&entry) == B_OK) {
BNode(&entry).ReadAttrString("MAIL:unique_id", &uid);
queryContents.Add(uid);
}
}
NotHere(queryContents, fManifest, &toDelete);
for (int32 i = 0; i < toDelete.CountStrings(); i++) {
printf("delete mail on server uid %s\n", toDelete.StringAt(i).String());
Delete(fUniqueIDs.IndexOf(toDelete.StringAt(i)));
}
// Don't remove ids from fUniqueIDs, the indices have to stay the same when
// retrieving new messages.
fManifest.Remove(toDelete);
// TODO: at some point the purged manifest should be written to disk
// otherwise it will grow forever
}
示例3: filePath
status_t
TeamWindow::_RetrieveMatchingSourceEntries(const BString& path,
BStringList* _entries)
{
BPath filePath(path);
status_t error = filePath.InitCheck();
if (error != B_OK)
return error;
_entries->MakeEmpty();
BQuery query;
BString predicate;
query.PushAttr("name");
query.PushString(filePath.Leaf());
query.PushOp(B_EQ);
error = query.GetPredicate(&predicate);
if (error != B_OK)
return error;
BVolumeRoster roster;
BVolume volume;
while (roster.GetNextVolume(&volume) == B_OK) {
if (!volume.KnowsQuery())
continue;
if (query.SetVolume(&volume) != B_OK)
continue;
error = query.SetPredicate(predicate.String());
if (error != B_OK)
continue;
if (query.Fetch() != B_OK)
continue;
entry_ref ref;
while (query.GetNextRef(&ref) == B_OK) {
filePath.SetTo(&ref);
_entries->Add(filePath.Path());
}
query.Clear();
}
return B_OK;
}
示例4: file
int32
add_query_menu_items(BMenu* menu, const char* attribute, uint32 what,
const char* format, bool popup)
{
BVolume volume;
BVolumeRoster().GetBootVolume(&volume);
BQuery query;
query.SetVolume(&volume);
query.PushAttr(attribute);
query.PushString("*");
query.PushOp(B_EQ);
query.Fetch();
int32 index = 0;
BEntry entry;
while (query.GetNextEntry(&entry) == B_OK) {
BFile file(&entry, B_READ_ONLY);
if (file.InitCheck() == B_OK) {
BMessage* message = new BMessage(what);
entry_ref ref;
entry.GetRef(&ref);
message->AddRef("ref", &ref);
BString value;
if (file.ReadAttrString(attribute, &value) < B_OK)
continue;
message->AddString("attribute", value.String());
BString name;
if (format != NULL)
name.SetToFormat(format, value.String());
else
name = value;
if (index < 9 && !popup)
menu->AddItem(new BMenuItem(name, message, '1' + index));
else
menu->AddItem(new BMenuItem(name, message));
index++;
}
}
return index;
}
示例5:
bool
TStatusWindow::_Exists(const char* status)
{
BVolume volume;
BVolumeRoster().GetBootVolume(&volume);
BQuery query;
query.SetVolume(&volume);
query.PushAttr(INDEX_STATUS);
query.PushString(status);
query.PushOp(B_EQ);
query.Fetch();
BEntry entry;
if (query.GetNextEntry(&entry) == B_NO_ERROR)
return true;
return false;
}
示例6:
BQuery*
MusicCollectionWindow::_CreateQuery(BString& orgString)
{
BQuery* query = new BQuery;
BString queryString;
CaseInsensitiveString(orgString, queryString);
query->PushAttr("Media:Title");
query->PushString(queryString);
query->PushOp(B_CONTAINS);
query->PushAttr("Audio:Album");
query->PushString(queryString);
query->PushOp(B_CONTAINS);
query->PushOp(B_OR);
query->PushAttr("Audio:Artist");
query->PushString(queryString);
query->PushOp(B_CONTAINS);
query->PushOp(B_OR);
if (queryString == "") {
query->PushAttr("BEOS:TYPE");
query->PushString("audio/");
query->PushOp(B_BEGINS_WITH);
query->PushOp(B_OR);
}
query->PushAttr("BEOS:TYPE");
query->PushString("audio/");
query->PushOp(B_BEGINS_WITH);
query->PushAttr("name");
query->PushString(queryString);
query->PushOp(B_CONTAINS);
query->PushOp(B_AND);
query->PushOp(B_OR);
return query;
}
示例7: ProgressWindow
void
ApplicationTypesWindow::_RemoveUninstalled()
{
// Note: this runs in the looper's thread, which isn't that nice
int32 removed = 0;
volatile bool quit = false;
BWindow* progressWindow =
new ProgressWindow(
B_TRANSLATE("Removing uninstalled application types"),
fTypeListView->FullListCountItems(), &quit);
progressWindow->AddToSubset(this);
progressWindow->Show();
for (int32 i = fTypeListView->FullListCountItems(); i-- > 0 && !quit;) {
MimeTypeItem* item = dynamic_cast<MimeTypeItem*>
(fTypeListView->FullListItemAt(i));
progressWindow->PostMessage(B_UPDATE_STATUS_BAR);
if (item == NULL)
continue;
// search for application on all volumes
bool found = false;
BVolumeRoster volumeRoster;
BVolume volume;
while (volumeRoster.GetNextVolume(&volume) == B_OK) {
if (!volume.KnowsQuery())
continue;
BQuery query;
query.PushAttr("BEOS:APP_SIG");
query.PushString(item->Type());
query.PushOp(B_EQ);
query.SetVolume(&volume);
query.Fetch();
entry_ref ref;
if (query.GetNextRef(&ref) == B_OK) {
found = true;
break;
}
}
if (!found) {
BMimeType mimeType(item->Type());
mimeType.Delete();
removed++;
// We're blocking the message loop that received the MIME changes,
// so we dequeue all waiting messages from time to time
if (removed % 10 == 0)
UpdateIfNeeded();
}
}
progressWindow->PostMessage(B_QUIT_REQUESTED);
static BMessageFormat format(B_TRANSLATE("{0, plural, "
"one{# Application type could be removed} "
"other{# Application types could be removed}}"));
BString message;
format.Format(message, removed);
error_alert(message, B_OK, B_INFO_ALERT);
}
示例8: BQuery
/*! \brief Search the filesystem for additional categories.
* \details Starts a whole-filesystem query for the Event files with
* categories which may be copied to the system and not appear
* in the Categories' database.
*/
static
void SearchFilesystemForAdditionalCategories( void )
{
BQuery* categoryQuery = NULL; //!< The way to fill the previously-uncatched categories.
Category* pCategory = NULL; //!< Used to traverse the list of categories
status_t status; //!< Result of the last action.
ssize_t bytesTransferred; //!< Used in I/O operations
entry_ref fileToReadAttributesFrom; //!< This is the reference to file with unknown category.
BFile* file = NULL; //!< This file will be initialized with fileToGetTheAttributesFrom.
attr_info attribute_info; //!< Information about the attribute.
rgb_color catColor; //!< Category color
char buffer[ 255 ]; //!< I'll use this buffer to read Categories from files
categoryQuery = new BQuery();
if ( !categoryQuery ) {
/* Nothing to do */
return;
}
// For initialization of the BQuery, we need to find the Volume with user's data.
BVolumeRoster volumeRoster;
BVolume bootVolume;
volumeRoster.GetBootVolume( &bootVolume );
// Setting the query to look in the boot volume
categoryQuery->SetVolume( &bootVolume );
/* First item of the predicate is the type of the file.
*/
categoryQuery->PushAttr( "BEOS:TYPE" );
categoryQuery->PushString( kEventFileMIMEType );
categoryQuery->PushOp( B_EQ );
/* Check the category attribute type's name.
*/
int i = 0;
BString categoryAttributeInternalName;
while ( AttributesArray[ i ].internalName != 0 )
{
if ( strcmp( AttributesArray[ i ].humanReadableName, "Category" ) == 0 )
{
// Found the correct attribute! Now, let's take its internal name...
break;
}
++i;
}
/* Build the query predicate.
* This is meaningful only if global list of categories contains any items,
* and if we succeeded to find the attribute with human-readable name "Category".
*/
if ( ! global_ListOfCategories.IsEmpty() &&
( AttributesArray[ i ].internalName != NULL ) )
{
for ( int i = 0, limit = global_ListOfCategories.CountItems();
i < limit;
++i )
{
pCategory = ( Category* )global_ListOfCategories.ItemAt( i );
if ( !pCategory )
continue;
categoryQuery->PushAttr( AttributesArray[ i ].internalName );
categoryQuery->PushString( pCategory->categoryName.String(), true );
categoryQuery->PushOp( B_NE );
categoryQuery->PushOp( B_AND );
} // <-- end of "for ( all currently known categories )"
} // <-- end of "if ( there are any items in the list of known categories )"
/* The predicate that we currently have looks like this:
* ((( type is Eventual ) && ( category != "Cat1" )) && ( category != "Cat2" )) && ...
* The order does not matter, since we're using "AND".
*
* Well, let's fire and see what comes...
*/
categoryQuery->Fetch();
while ( ( status = categoryQuery->GetNextRef( &fileToReadAttributesFrom ) ) == B_OK )
{
// Successfully retrieved next entry
file = new BFile( &fileToReadAttributesFrom, B_READ_ONLY );
if ( !file || file->InitCheck() != B_OK )
continue;
status = file->GetAttrInfo( AttributesArray[ i ].internalName,
&attribute_info );
if ( status != B_OK )
continue;
status = file->ReadAttr( AttributesArray[ i ].internalName,
attribute_info.type,
0,
//.........这里部分代码省略.........