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


C++ BString::CountChars方法代码示例

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


在下文中一共展示了BString::CountChars方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setMessage

void StatusView::setMessage(
	BString &title,
	BString &details,
	status_t error) {
	D_OPERATION(("StatusView::setMessage(%s)\n", title.String()));

	// get the tip manager instance and reset
	TipManager *manager = TipManager::Instance();
	manager->removeAll(this);

	// append error string
	if (error) {
		title << " (" << strerror(error) << ")";
	}

	// truncate if necessary
	bool truncated = false;
	m_fullText = title;
	if (be_plain_font->StringWidth(title.String()) > Bounds().Width() - 25.0) {
		be_plain_font->TruncateString(&title, B_TRUNCATE_END,
									  Bounds().Width() - 25.0);
		truncated = true;
	}
	BStringView::SetText(title.String());

	if (truncated || details.CountChars() > 0) {
		BString tip = m_fullText;
		if (details.CountChars() > 0) {
			tip << "\n" << details;
		}
		manager->setTip(tip.String(), this);
	}

	if (error) {
		beep();
		// set icon
		if (m_icon) {
			delete m_icon;
			m_icon = 0;
		}
		BRect iconRect(0.0, 0.0, 7.0, 11.0);
		m_icon = new BBitmap(iconRect, B_CMAP8);
		m_icon->SetBits(ERROR_ICON_BITS, 96, 0, B_CMAP8);
	}
	else {
		// set icon
		if (m_icon) {
			delete m_icon;
			m_icon = 0;
		}
		BRect iconRect(0.0, 0.0, 7.0, 11.0);
		m_icon = new BBitmap(iconRect, B_CMAP8);
		m_icon->SetBits(INFO_ICON_BITS, 96, 0, B_CMAP8);
	}
	m_dirty = true;
	startFade();
	Invalidate();
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:58,代码来源:StatusView.cpp

示例2: entry

int32_t
PRosterGetAppInfo(void *pobject, void *in, void *out, void *ptr)
{
	if (!pobject || !in || !out)
		return B_ERROR;
	
	PRoster *roster = static_cast<PRoster*>(pobject);
	if (!roster)
		return B_BAD_TYPE;
	
	PArgs *args = static_cast<PArgs*>(in);
	
	BString path;
	if (args->FindString("path", &path) != B_OK)
		path = "";
	
	BString signature;
	if (args->FindString("signature", &signature) != B_OK)
		signature = "";
	
	app_info info;
	status_t status;
	if (path.CountChars() > 1)
	{
		entry_ref pathRef;
		BEntry entry(path.String());
		entry.GetRef(&pathRef);
		
		status = be_roster->GetAppInfo(&pathRef, &info);
	}
	else if(signature.CountChars() < 1)
	{
		status = be_roster->GetAppInfo(signature.String(), &info);
	}
	else
		return B_ERROR;
	
	PArgs infoList;
	infoList.AddInt32("thread", info.thread);
	infoList.AddInt32("team", info.team);
	infoList.AddInt32("port", info.port);
	infoList.AddInt32("flags", info.flags);
	infoList.AddRef("entry_ref", info.ref);
	infoList.AddString("signature", info.signature);
	
	PArgs *outArgs = static_cast<PArgs*>(out);
	outArgs->MakeEmpty();
	outArgs->AddPArg("app_info", infoList);
	outArgs->AddInt32("status", status);
	
	return B_OK;
}
开发者ID:HaikuArchives,项目名称:PDesigner,代码行数:52,代码来源:PRoster.cpp

示例3: if

bool
StringCompare(const BString &from, const BString &to, const char *mode,
			const bool &match_case)
{
	if (!mode)
	{
		debugger("NULL mode in StringCompare");
		return false;
	}
	
	if (strcmp(mode,"is") == 0)
		if (match_case)
			return from.Compare(to) == 0;
		else
			return from.ICompare(to) == 0;
	else if (strcmp(mode,"is not") == 0)
		if (match_case)
			return from.Compare(to) != 0;
		else
			return from.ICompare(to) != 0;
	else if (strcmp(mode,"contains") == 0)
		if (match_case)
			return to.FindFirst(from) >= 0;
		else
			return to.IFindFirst(from) >= 0;
	else if (strcmp(mode,"does not contain") == 0)
		if (match_case)
			return to.FindFirst(from) < 0;
		else
			return to.IFindFirst(from) < 0;
	else if (strcmp(mode,"starts with") == 0)
		if (match_case)
			return to.FindFirst(from) == 0;
		else
			return to.IFindFirst(from) == 0;
	else if (strcmp(mode,"ends with") == 0)
	{
		int32 pos;
		if (match_case)
			pos = to.FindLast(from);
		else
			pos = to.IFindLast(from);
		
		return (to.CountChars() - from.CountChars() == pos);
	}	
	
	return false;
}
开发者ID:puckipedia,项目名称:Filer,代码行数:48,代码来源:RuleRunner.cpp

示例4: lock

status_t
BLocale::FormatTime(BString* string, time_t time, BString format,
	const BTimeZone* timeZone) const
{
	BAutolock lock(fLock);
	if (!lock.IsLocked())
		return B_ERROR;

	if (format == NULL || format.CountChars() <= 0)
		return B_BAD_VALUE;

	ObjectDeleter<DateFormat> timeFormatter(_CreateTimeFormatter(format));
	if (timeFormatter.Get() == NULL)
		return B_NO_MEMORY;

	if (timeZone != NULL) {
		ObjectDeleter<TimeZone> icuTimeZone(
			TimeZone::createTimeZone(timeZone->ID().String()));
		if (icuTimeZone.Get() == NULL)
			return B_NO_MEMORY;
		timeFormatter->setTimeZone(*icuTimeZone.Get());
	}

	UnicodeString icuString;
	timeFormatter->format((UDate)time * 1000, icuString);

	string->Truncate(0);
	BStringByteSink stringConverter(string);
	icuString.toUTF8(stringConverter);

	return B_OK;
}
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:32,代码来源:Locale.cpp

示例5:

BString
DNSTools::ConvertToDNSName(const BString& string)
{
	BString outString = string;
	int32 dot, lastDot, diff;

	dot = string.FindFirst(".");
	if (dot != B_ERROR) {
		outString.Prepend((char*)&dot, 1);
		// because we prepend a char add 1 more
		lastDot = dot + 1;

		while (true) {
			dot = outString.FindFirst(".", lastDot + 1);
			if (dot == B_ERROR)
				break;

			// set a counts to the dot
			diff =  dot - 1 - lastDot;
			outString[lastDot] = (char)diff;
			lastDot = dot;
		}
	} else
		lastDot = 0;

	diff = outString.CountChars() - 1 - lastDot;
	outString[lastDot] = (char)diff;

	return outString;
}
开发者ID:mariuz,项目名称:haiku,代码行数:30,代码来源:DNSQuery.cpp

示例6:

int32_t
PTextViewDisallowChars(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;
	
	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BTextView *backend = (BTextView*)parent->GetView();
	
	PArgs *inArgs = static_cast<PArgs*>(in);
	BString string;
	if (inArgs->FindString("chars", &string) != B_OK)
		return B_ERROR;
	
	if (backend->Window())
		backend->Window()->Lock();
	
	for (int32 i = 0; i < string.CountChars(); i++)
	{
		char c = string.ByteAt(i);
		if (c)
			backend->DisallowChar(c);
	}
	
	if (backend->Window())
		backend->Window()->Unlock();
	
	return B_OK;
}
开发者ID:HaikuArchives,项目名称:PDesigner,代码行数:32,代码来源:PTextView.cpp

示例7:

void
BHttpRequest::_ParseStatus()
{
	// Status line should be formatted like: HTTP/M.m SSS ...
	// With:   M = Major version of the protocol
	//         m = Minor version of the protocol
	//       SSS = three-digit status code of the response
	//       ... = additional text info
	BString statusLine;
	if (_GetLine(statusLine) == B_ERROR)
		return;

	if (statusLine.CountChars() < 12)
		return;

	fRequestStatus = kRequestStatusReceived;

	BString statusCodeStr;
	BString statusText;
	statusLine.CopyInto(statusCodeStr, 9, 3);
	_SetResultStatusCode(atoi(statusCodeStr.String()));

	statusLine.CopyInto(_ResultStatusText(), 13, statusLine.Length() - 13);

	_EmitDebug(B_URL_PROTOCOL_DEBUG_TEXT, "Status line received: Code %d (%s)",
		atoi(statusCodeStr.String()), _ResultStatusText().String());
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:27,代码来源:HttpRequest.cpp

示例8: UpdateFileList

void AddTorrentWindow::UpdateFileList()
{	
	//
	//
	int 	 fileCount = fTorrent->Info()->fileCount;
	tr_file* fileList  = fTorrent->Info()->files;
	
	for( int i = 0; i < fileCount; i++ )
	{
		char FormatBuffer[128] = { 0 };
		BRow* row = new BRow(FILE_COLUMN_HEIGHT);
		
		const char* name = fTorrent->IsFolder() ? (strchr(fileList[i].name, '/') + 1) : fileList[i].name;
		
		//
		//
		//
		BString FileExtension = B_EMPTY_STRING;
		BString FilePath = fileList[i].name;
		FilePath.CopyInto(FileExtension, FilePath.FindLast('.') + 1, FilePath.CountChars());
		
		
		const char* info = tr_formatter_mem_B(FormatBuffer, fileList[i].length, sizeof(FormatBuffer));;
		const BBitmap* icon = GetIconFromExtension(FileExtension);
		
		row->SetField(new FileField(icon, name, info), COLUMN_FILE_NAME);
		row->SetField(new CheckBoxField(true), COLUMN_FILE_DOWNLOAD);
		////row->SetField(new BIntegerField(PeerStatus[i].progress * 100.0), COLUMN_PEER_PROGRESS);
		
		fFileList->AddRow(row, i);

	} 	
}
开发者ID:Prodito,项目名称:Torrentor,代码行数:33,代码来源:AddTorrentWindow.cpp

示例9:

TextSpan::TextSpan(const BString& text, const TextStyle& style)
	:
	fText(text),
	fCharCount(text.CountChars()),
	fStyle(style)
{
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例10: BMessage

FindOpenFileWindow::FindOpenFileWindow(const char* panelText)
	:
	DWindow(BRect(0, 0, 0, 0), TR("Find and open file"), B_TITLED_WINDOW,
		B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
{
	AddCommonFilter(new EscapeCancelFilter());

	BView* top = GetBackgroundView();

	fNameTextControl = new AutoTextControl("nameText", TR("Open: "), "",
		new BMessage);
	fNameTextControl->SetExplicitMinSize(
		BSize(fNameTextControl->StringWidth("M") * 20, B_SIZE_UNSET));
	fSystemCheckBox = new BCheckBox("systembox", TR("Search only system folders"),
		new BMessage);

	BButton* cancel = new BButton("cancel", TR("Cancel"),
		new BMessage(B_QUIT_REQUESTED));

	BButton* open = new BButton("open", TR("Open"), new BMessage(M_FIND_FILE));

	BLayoutBuilder::Group<>(top, B_VERTICAL)
		.AddGrid(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
			.Add(fNameTextControl->CreateLabelLayoutItem(), 0, 0)
			.Add(fNameTextControl->CreateTextViewLayoutItem(), 1, 0)
			.Add(fSystemCheckBox, 1, 1)
			.End()
		.AddGlue()
		.AddGroup(B_HORIZONTAL)
			.AddGlue()
			.Add(cancel)
			.Add(open)
			.End()
		.SetInsets(B_USE_WINDOW_INSETS)
		.End();

	BString text = panelText;
	if (text.CountChars() > 1) {
		fNameTextControl->SetText(text.String());
		int32 position = text.FindLast(".");
		if (position > 0)
			fNameTextControl->TextView()->Select(0, position);
		else
			fNameTextControl->TextView()->SelectAll();
	} else {
		fNameTextControl->SetText(".h");
		fNameTextControl->TextView()->GoToLine(0);
	}

	open->MakeDefault(true);

	fNameTextControl->MakeFocus(true);

	CenterOnScreen();
}
开发者ID:jscipione,项目名称:Paladin,代码行数:55,代码来源:FindOpenFileWindow.cpp

示例11:

BString
DTipWatcherView::GetTip(BView *view)
{
	BString text = fDataMap[view];
	while (view && text.CountChars() < 1)
	{
		view = view->Parent();
		text = fDataMap[view];
	}
	return text;
}
开发者ID:HaikuArchives,项目名称:LibWalter,代码行数:11,代码来源:DToolTip.cpp

示例12: if

void
Project::CompileFile(SourceFile *file)
{
	if (!file)
	{
		return;
	}
	
	BString compileString;
	if (Debug())
		compileString << "-g -O0 ";
	else
	{
		compileString << "-O" << (int)OpLevel() << " ";
		
		if (OpForSize())
			compileString << "-Os ";
	}
	
	if (Profiling())
		compileString << "-p ";
	
	if (fExtraCompilerOptions.CountChars() > 0)
		compileString << fExtraCompilerOptions << " ";
	
	compileString << "-I '" << fPath.GetFolder() << "' ";
	for (int32 i = 0; i < fLocalIncludeList.CountItems(); i++)
		compileString << "-I '" << fLocalIncludeList.ItemAt(i)->Absolute() << "' ";

	for (int32 i = 0; i < fSystemIncludeList.CountItems(); i++)
	{
		BString item = *fSystemIncludeList.ItemAt(i);
		
		if (item == ".")
			item = GetPath().GetFolder();
		else if (item.CountChars() >= 2 && item[0] == '.' && item[1] == '/')
			item.ReplaceFirst(".",GetPath().GetFolder());
		else if (item[0] != '/')
		{
			item.Prepend("/");
			item.Prepend(GetPath().GetFolder());
		}
		
		compileString << "-I '" << item.String() << "' ";
	}

	DPath projfolder(GetPath().GetFolder());
	file->Compile(fBuildInfo,compileString.String());
}
开发者ID:passick,项目名称:Paladin,代码行数:49,代码来源:Project.cpp

示例13: findText

void
FindWindow::ReplaceAll(void)
{
	// This function is called from the FinderThread function, so locking is
	// required when accessing any member variables.
	
	
	Lock();
	BString errorLog;
	
	BString findText(fFindBox->Text());
	BString replaceText(fReplaceBox->Text());
		
	if (!fIsRegEx)
	{
		findText.CharacterEscape("^$()%.[]*+-?", '\\');
	}
		
	BString replaceTerms;
	replaceTerms << "'" << findText << "' '" << replaceText << "'";
		
	ShellHelper shell;
	shell << "pwd; find ";
	shell.AddEscapedArg(fWorkingDir);
	BString sStr("'s/");
	sStr << findText.String() << "/";
	sStr << replaceText.String() << "/";
	sStr << "'";
	shell << " -type f | xargs sed -i " << sStr.String();
		
	STRACE(2,("Shell command: %s\n",shell.AsString().String()));
		
	Unlock();
	BString out;
	shell.RunInPipe(out,false);
	STRACE(2,("Command output: %s\n",out.String()));
	
	if (errorLog.CountChars() > 0)
	{
		BString errorString = B_TRANSLATE("The following files had problems replacing the search terms:\n");
		errorString << errorLog;
		
		ShowAlert(errorString.String());
	}
	
	PostMessage(M_FIND);
}
开发者ID:humdingerb,项目名称:Paladin,代码行数:47,代码来源:FindWindow.cpp

示例14: node

bool
Project::IsProject(const entry_ref &ref)
{
	BNode node(&ref);
	BString type;
	node.ReadAttrString("BEOS:TYPE",&type);
	if (type.CountChars() > 0 && type == PROJECT_MIME_TYPE)
		return true;
	
	BString extension = BPath(&ref).Path();
	int32 pos = extension.FindLast(".");
	if (pos >= 0)
	{
		extension = extension.String() + pos;
		if (extension.ICompare(".pld") == 0)
			return true;
	}
	return false;
}
开发者ID:passick,项目名称:Paladin,代码行数:19,代码来源:Project.cpp

示例15: targetpath

void
Project::UpdateResources(void)
{
	DPath targetpath(fPath.GetFolder());
	targetpath.Append(GetTargetName());
	
	BString resFileString;
	int32 resCount = 0;

	for (int32 i = 0; i < CountGroups(); i++)
	{
		SourceGroup *group = GroupAt(i);
		
		for (int32 j = 0; j < group->filelist.CountItems(); j++)
		{
			SourceFile *file = group->filelist.ItemAt(j);
			
			if (file->GetResourcePath(fBuildInfo).GetFullPath())
			{
				resFileString << "'" << file->GetResourcePath(fBuildInfo).GetFullPath() << "' ";
				resCount++;
			}
		}
	}
	
	if (resCount > 0)
	{
		BString resString = "xres -o ";
		resString << "'" << targetpath.GetFullPath() << "' " << resFileString;		
		BString errmsg;
		PipeCommand(resString.String(),errmsg);
		
		STRACE(1,("Resources for %s:\n%s\nErrors:%s\n",GetName(),resString.String(),errmsg.String()));
		
		if (errmsg.CountChars() > 0)
			printf("Resource errors: %s\n",errmsg.String());
	}
	else
	{
		STRACE(1,("Resources for %s: No resource files to add\n",GetName()));
	}
}
开发者ID:passick,项目名称:Paladin,代码行数:42,代码来源:Project.cpp


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