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


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

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


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

示例1:

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

示例2: _FindStyle

/*!
	\brief Get the FontStyle object for the name given
	\param style Name of the style to be obtained
	\return The FontStyle object or NULL if none was found.

	The object returned belongs to the family and must not be deleted.
*/
FontStyle*
FontFamily::GetStyle(const char *name) const
{
    if (name == NULL || !name[0])
        return NULL;

    FontStyle* style = _FindStyle(name);
    if (style != NULL)
        return style;

    // try alternative names

    if (!strcmp(name, "Roman") || !strcmp(name, "Regular")
            || !strcmp(name, "Book")) {
        style = _FindStyle("Roman");
        if (style == NULL) {
            style = _FindStyle("Regular");
            if (style == NULL)
                style = _FindStyle("Book");
        }
        return style;
    }

    BString alternative = name;
    if (alternative.FindFirst("Italic") >= 0) {
        alternative.ReplaceFirst("Italic", "Oblique");
        return _FindStyle(alternative.String());
    }
    if (alternative.FindFirst("Oblique") >= 0) {
        alternative.ReplaceFirst("Oblique", "Italic");
        return _FindStyle(alternative.String());
    }

    return NULL;
}
开发者ID:mmanley,项目名称:Antares,代码行数:42,代码来源:FontFamily.cpp

示例3: cmd

bool
SftpClient::PutFile(const string& local, const string& remote, ftp_mode mode)
{
	bool rc = false;
	int len;
	//XXX: handle mode ?
	BString cmd("put");
	cmd << " " << local.c_str() << " " << remote.c_str() << "\n";
	SendCommand(cmd.String());
	BString reply;

	if ((len = ReadReply(&reply)) < 0) {
		fprintf(stderr, _GetReadText(), len);
		return false;
	}
	fprintf(stderr, _GetReplyText(), reply.String());
	if (reply.FindFirst("Uploading") < 0)
		return false;

	if ((len = ReadReply(&reply)) < 0) {
		fprintf(stderr, _GetReadText(), len);
		return false;
	}
	fprintf(stderr, _GetReplyText(), reply.String());
	if (reply.FindFirst("sftp>") < 0)
		return false;

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

示例4:

void
BHttpForm::_ExtractNameValuePair(const BString& formString, int32* index)
{
	// Look for a name=value pair
	int16 firstAmpersand = formString.FindFirst("&", *index);
	int16 firstEqual = formString.FindFirst("=", *index);

	BString name;
	BString value;

	if (firstAmpersand == -1) {
		if (firstEqual != -1) {
			formString.CopyInto(name, *index, firstEqual - *index);
			formString.CopyInto(value, firstEqual + 1,
				formString.Length() - firstEqual - 1);
		} else
			formString.CopyInto(value, *index,
				formString.Length() - *index);

		*index = formString.Length() + 1;
	} else {
		if (firstEqual != -1 && firstEqual < firstAmpersand) {
			formString.CopyInto(name, *index, firstEqual - *index);
			formString.CopyInto(value, firstEqual + 1,
				firstAmpersand - firstEqual - 1);
		} else
			formString.CopyInto(value, *index, firstAmpersand - *index);

		*index = firstAmpersand + 1;
	}

	AddString(name, value);
}
开发者ID:mylegacy,项目名称:haiku,代码行数:33,代码来源:HttpForm.cpp

示例5: if

platform_t
DetectPlatform(void)
{
	platform_t type = PLATFORM_R5;
	
	// While, yes, there is a uname() function in sys/utsname.h, we use spawn a shell
	// so that we can easily avoid the build mess of BONE vs netserver.
	// Use ShellHelper class to avoid problems with popen() causing hangs. :/
	ShellHelper shell;
	BString osname;
	
	shell << "uname" << "-o";
	shell.RunInPipe(osname, false);
	
	if (osname.FindFirst("Haiku\n") == 0)
	{
		BPath libpath;
		find_directory(B_BEOS_LIB_DIRECTORY,&libpath);
		libpath.Append("libsupc++.so");
		type =  BEntry(libpath.Path()).Exists() ? PLATFORM_HAIKU_GCC4 : PLATFORM_HAIKU;
	}
	else if (osname.FindFirst("Zeta\n") == 0)
		type = PLATFORM_ZETA;
	else
		printf("Detected platform from uname: %s\n", osname.String());
	
	return type;
}
开发者ID:passick,项目名称:Paladin,代码行数:28,代码来源:Project.cpp

示例6: rgetcomment

// --------------------------------------------------------------------------------------------- rgetcomment -
BString rgetcomment(BString str)
{
 BString tmp;
 if (str.FindFirst('#')>=0)
 {
  str.CopyInto(tmp,0,str.FindFirst('#'));
 } else tmp=str;
 return tmp;
}
开发者ID:HaikuArchives,项目名称:Globe,代码行数:10,代码来源:RHTML_options.cpp

示例7: GetFortune

status_t FortuneAccess::GetFortune(BString *target)
{
	if(!target)
		return B_BAD_VALUE;
	
	if(fRefList.CountItems()<1)
		return B_ERROR;
	
	int32 index = int32(float(rand()) / RAND_MAX * fRefList.CountItems());
	
	entry_ref *ref = (entry_ref*)fRefList.ItemAt(index);
	
	BFile file(ref,B_READ_ONLY);
	if(file.InitCheck()!=B_OK)
		return file.InitCheck();
	
	fLastFile = ref->name;
	
	off_t size;
	file.GetSize(&size);
	
	if(size<1)
		return B_ERROR;
	
	BString data;
	
	char *buffer = data.LockBuffer(size + 10);
	file.Read(buffer,size);
	data.UnlockBuffer();
	buffer = NULL;
	
	// We can't depend on a .dat file, so calculate the number of entries manually
	int32 entrycount = 0;
	int32 entrystart = 0;
	
	do
	{
		entrystart = data.FindFirst("%\n",entrystart + 1);
		entrycount++;
	} while(entrystart>0);
	
	int32 entry = int32(float(rand()) / RAND_MAX * (entrycount-1));

	entrystart = 0;
	for(int32 i=0; i<entry; i++)
		entrystart = data.FindFirst("%\n",entrystart + 1);
		
	BString entrydata;
	entrydata = data.String() + entrystart + 2;
	int32 entrylength = entrydata.FindFirst("%\n");
	if(entrylength>0)
		entrydata.Truncate(entrylength);
	
	*target = entrydata;
	return B_OK;
}
开发者ID:HaikuArchives,项目名称:Fortuna,代码行数:56,代码来源:FortuneFunctions.cpp

示例8: 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

示例9: parseMenuItemTrigger

/**
 *	@brief	Reads items array in menu design resource.
 *	@return	trigger character
 */
char BeSkinView::parseMenuItemTrigger(
	const char* sourceLabel,	///< source label string
	BString& outLabel			///< OUTPUT. label string without '&' prefix character.
)
{
	char trigger = 0;
	outLabel = sourceLabel;
	int32 find = 0;
	
	while (true)
	{
		find = outLabel.FindFirst('~', find);
		if (B_ERROR == find)
		{
			break;
		}
		outLabel.Remove(find, 1);
		if (outLabel[find] != '~')
		{
			if (0 == trigger)
			{
				trigger = tolower(outLabel[find]);
			}
		}
		else
		{
			find++;
		}
	}
	
	return trigger;
}
开发者ID:HaikuArchives,项目名称:CoveredCalc,代码行数:36,代码来源:BeSkinView.cpp

示例10:

RuleFilter::RuleFilter(MailProtocol& protocol, AddonSettings* addonSettings)
	:
	MailFilter(protocol, addonSettings)
{
	const BMessage* settings = &addonSettings->Settings();
	// attribute is adapted to our "capitalize-each-word-in-the-header" policy
	settings->FindString("attribute", &fAttribute);
	fAttribute.CapitalizeEachWord();

	BString regex;
	settings->FindString("regex", &regex);
	
	int32 index = regex.FindFirst("REGEX:");
	if (index == B_ERROR || index > 0)
		EscapeRegexTokens(regex);
	else
		regex.RemoveFirst("REGEX:");
		
	fMatcher.SetPattern(regex, false);
	
	settings->FindString("argument",&fArg);
	settings->FindInt32("do_what",(long *)&fDoWhat);
	if (fDoWhat == Z_SET_REPLY)
		settings->FindInt32("argument", &fReplyAccount);
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例11:

void
BUrl::_ExtractRequestAndFragment(const BString& urlString, int16* origin)
{
	// Extract request field from URL
	if (urlString.ByteAt(*origin) == '?') {
		(*origin)++;
		int16 requestEnd = urlString.FindFirst('#', *origin);

		fHasRequest = true;

		if (requestEnd == -1) {
			urlString.CopyInto(fRequest, *origin, urlString.Length() - *origin);
			return;
		} else {
			urlString.CopyInto(fRequest, *origin, requestEnd - *origin);
			*origin = requestEnd;
		}
	}

	// Extract fragment field if needed
	if (urlString.ByteAt(*origin) == '#') {
		(*origin)++;
		urlString.CopyInto(fFragment, *origin, urlString.Length() - *origin);

		fHasFragment = true;
	}
}
开发者ID:mmadia,项目名称:Haiku-services-branch,代码行数:27,代码来源:Url.cpp

示例12: ThemeLocation

bool
ThemeManager::ThemeIsReadOnly(int32 id)
{
	FENTRY;
	status_t err;
	BString s;
	BMessage *theme;
	
	if (id < 0)
		return true;
	
	theme = (BMessage *)fThemeList.ItemAt(id);
	if (!theme)
		return true;
	// imported themes are always RO for now
	if (theme->FindString(Z_THEME_IMPORTER, &s) >= B_OK)
		return true;
	
	err = ThemeLocation(id, s);
	if (err)
		return true;
	if (s.FindFirst("/boot/beos") >= 0)
		return true;
	return false;
}
开发者ID:mmanley,项目名称:Antares,代码行数:25,代码来源:ThemeManager.cpp

示例13: isspace

void
KeyboardLayout::_Trim(BString& string, bool stripComments)
{
	// Strip leading spaces
	int32 i = 0;
	while (isspace(string[i])) {
		i++;
	}
	if (i > 0)
		string.Remove(0, i);

	// Remove comments
	if (stripComments) {
		i = string.FindFirst('#');
		if (i >= 0)
			string.Truncate(i);
	}

	// Strip trailing spaces
	i = string.Length() - 1;
	while (i > 0 && isspace(string[i])) {
		i--;
	}
	string.Truncate(i + 1);
}
开发者ID:Barrett17,项目名称:haiku,代码行数:25,代码来源:KeyboardLayout.cpp

示例14: sizeof

void
MainWindow::_DisplayPartitionError(BString _message,
	const BPartition* partition, status_t error) const
{
	char message[1024];

	if (partition && _message.FindFirst("%s") >= 0) {
		BString name;
		name << "\"" << partition->ContentName() << "\"";
		snprintf(message, sizeof(message), _message.String(), name.String());
	} else {
		_message.ReplaceAll("%s", "");
		snprintf(message, sizeof(message), _message.String());
	}

	if (error < B_OK) {
		BString helper = message;
		const char* errorString
			= B_TRANSLATE_COMMENT("Error: ", "in any error alert");
		snprintf(message, sizeof(message), "%s\n\n%s%s", helper.String(),
			errorString, strerror(error));
	}

	BAlert* alert = new BAlert("error", message, B_TRANSLATE("OK"), NULL, NULL,
		B_WIDTH_FROM_WIDEST, error < B_OK ? B_STOP_ALERT : B_INFO_ALERT);
	alert->Go(NULL);
}
开发者ID:,项目名称:,代码行数:27,代码来源:

示例15: LoadDataFile

bool DataFile::LoadDataFile(BString filename)
////////////////////////////////////////////////////////////////////////
{
	BString line;
	int	sign;		// itt van az '=' jel
	int len;
	BString key;
	BString value;

	if (Read(filename))
	{
		while (GetLine(line))
		{
			RemoveComment(line);
			sign = line.FindFirst('=');
			if (sign >= 1)
			{
				len = line.Length();
				line.CopyInto(key, 0, sign);
				line.CopyInto(value, sign+1, len-sign-1);
				Trim(key);
				Trim(value);
				AddEntry(key, value);
			}				
		}
	}
	else
		return false;
		
	return true;
}
开发者ID:PZsolt27,项目名称:GenesisCommander,代码行数:31,代码来源:Settings.cpp


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