当前位置: 首页>>代码示例>>C++>>正文


C++ BQuery::PushString方法代码示例

本文整理汇总了C++中BQuery::PushString方法的典型用法代码示例。如果您正苦于以下问题:C++ BQuery::PushString方法的具体用法?C++ BQuery::PushString怎么用?C++ BQuery::PushString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BQuery的用法示例。


在下文中一共展示了BQuery::PushString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
开发者ID:jscipione,项目名称:Paladin,代码行数:40,代码来源:BeBookFetch.cpp

示例2: 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;
}
开发者ID:MaddTheSane,项目名称:haiku,代码行数:48,代码来源:TeamWindow.cpp

示例3: 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;
}
开发者ID:DonCN,项目名称:haiku,代码行数:47,代码来源:MailSupport.cpp

示例4:

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;
}
开发者ID:DonCN,项目名称:haiku,代码行数:19,代码来源:Status.cpp

示例5:

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;
}
开发者ID:veer77,项目名称:Haiku-services-branch,代码行数:41,代码来源:MusicCollectionWindow.cpp

示例6: 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);
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:71,代码来源:ApplicationTypesWindow.cpp

示例7: 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,
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:haiku-pim-svn,代码行数:101,代码来源:CategoriesPreferences.cpp


注:本文中的BQuery::PushString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。