本文整理汇总了C++中BString::ICompare方法的典型用法代码示例。如果您正苦于以下问题:C++ BString::ICompare方法的具体用法?C++ BString::ICompare怎么用?C++ BString::ICompare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BString
的用法示例。
在下文中一共展示了BString::ICompare方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
status_t
write_read_attr(BNode& node, read_flags flag)
{
if (node.WriteAttr(B_MAIL_ATTR_READ, B_INT32_TYPE, 0, &flag, sizeof(int32))
< 0)
return B_ERROR;
#if R5_COMPATIBLE
// manage the status string only if it currently has a "read" status
BString currentStatus;
if (node.ReadAttrString(B_MAIL_ATTR_STATUS, ¤tStatus) == B_OK) {
if (currentStatus.ICompare("New") != 0
&& currentStatus.ICompare("Read") != 0
&& currentStatus.ICompare("Seen") != 0)
return B_OK;
}
const char* statusString = (flag == B_READ) ? "Read"
: (flag == B_SEEN) ? "Seen" : "New";
if (node.WriteAttr(B_MAIL_ATTR_STATUS, B_STRING_TYPE, 0, statusString,
strlen(statusString)) < 0)
return B_ERROR;
#endif
return B_OK;
}
示例2: entry_ref
entry_ref
SourceTypeC::CreateSourceFile(const char *dir, const char *name, uint32 options)
{
if (!dir || !name)
return entry_ref();
BString folderstr(dir);
if (folderstr.ByteAt(folderstr.CountChars() - 1) != '/')
folderstr << "/";
DPath folder(folderstr.String()), filename(name);
bool is_cpp = false;
bool is_header = false;
bool create_pair = ((options & SOURCEFILE_PAIR) != 0);
BString ext = filename.GetExtension();
if ( (ext.ICompare("cpp") == 0) || (ext.ICompare("c") == 0) ||
(ext.ICompare("cxx") == 0) || (ext.ICompare("cc") == 0) )
is_cpp = true;
else if ((ext.ICompare("h") == 0) || (ext.ICompare("hxx") == 0) ||
(ext.ICompare("hpp") == 0) || (ext.ICompare("h++") == 0))
is_header = true;
if (!is_cpp && !is_header)
return entry_ref();
BString sourceName, headerName;
if (is_cpp)
{
sourceName = filename.GetFileName();
headerName = filename.GetBaseName();
headerName << ".h";
}
else
{
sourceName = filename.GetBaseName();
sourceName << ".cpp";
headerName = filename.GetFileName();
}
entry_ref sourceRef, headerRef;
BString data;
if (is_cpp || create_pair)
{
if (create_pair)
data << "#include \"" << headerName << "\"\n\n";
sourceRef = MakeProjectFile(folder.GetFullPath(),sourceName.String(),data.String());
}
if (is_header || create_pair)
{
data = MakeHeaderGuard(headerName.String());
headerRef = MakeProjectFile(folder.GetFullPath(),headerName.String(),data.String());
}
return is_cpp ? sourceRef : headerRef;
}
示例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;
}
示例4: entry_ref
entry_ref
SourceTypeShell::CreateSourceFile(const char *dir, const char *name, uint32 options)
{
if (!dir || !name)
return entry_ref();
BString folderstr(dir);
if (folderstr.ByteAt(folderstr.CountChars() - 1) != '/')
folderstr << "/";
DPath folder(folderstr.String()), filename(name);
BString ext = filename.GetExtension();
if (ext.ICompare("sh") != 0)
return entry_ref();
BString fileData = "#!/bin/sh\n\n";
entry_ref outRef = MakeProjectFile(folder, filename.GetFileName(),
fileData.String(), "text/x-source-code");
BFile file(&outRef, B_READ_WRITE);
if (file.InitCheck() == B_OK)
{
mode_t perms;
file.GetPermissions(&perms);
file.SetPermissions(perms | S_IXUSR | S_IXGRP);
}
return outRef;
}
示例5: encoding
void
AppWindowPrefsView::MessageReceived (BMessage *msg)
{
switch (msg->what)
{
case M_APPWINDOWPREFS_ENCODING_CHANGED:
{
BMenuItem *source (NULL);
msg->FindPointer ("source", reinterpret_cast<void **>(&source));
source->SetMarked(true);
int32 encoding (msg->FindInt32("encoding"));
vision_app->SetInt32("encoding", encoding);
}
break;
case M_APPWINDOWPREFS_SETTING_CHANGED:
{
BControl *source (NULL);
msg->FindPointer ("source", reinterpret_cast<void **>(&source));
BString setting;
msg->FindString ("setting", &setting);
int32 value (source->Value() == B_CONTROL_ON);
if ((setting.ICompare ("versionParanoid") == 0))
value = !value;
vision_app->SetBool (setting.String(), value);
}
break;
default:
BView::MessageReceived(msg);
break;
}
}
示例6: catch
bool
ListCommand::HandleUntagged(Response& response)
{
if (response.IsCommand(_Command()) && response.IsStringAt(2)
&& response.IsStringAt(3)) {
fSeparator = response.StringAt(2);
BString folder = response.StringAt(3);
if (folder == "")
return true;
try {
folder = fEncoding.Decode(folder);
// The folder INBOX is always case insensitive
if (folder.ICompare("INBOX") == 0)
folder = "Inbox";
fFolders.push_back(folder);
} catch (ParseException& exception) {
// Decoding failed, just add the plain text
fprintf(stderr, "Decoding \"%s\" failed: %s\n", folder.String(),
exception.Message());
fFolders.push_back(folder);
}
return true;
}
return false;
}
示例7: MessageReceived
/*!
\internal
Messages received from the BeOS roster concerning application startup and termination are similar to the
one below, which was taken from the launch of the restart_daemon.
BMessage: what = BRAS (0x42524153, or 1112686931)
entry be:signature, type='CSTR', c=1, size=37, data[0]: "application/x-vnd.bls-restart_daemon"
entry be:team, type='LONG', c=1, size= 4, data[0]: 0xea4 (3748, '')
entry be:thread, type='LONG', c=1, size= 4, data[0]: 0x22a9 (8873, '')
entry be:flags, type='LONG', c=1, size= 4, data[0]: 0x10000009 (268435465, '')
entry be:ref, type='RREF', c=1, size=27, data[0]: device=7, directory=7653630, name="restart_daemon", path="/zanos/programming/restart_daemon/output/restart_daemon"
*/
void MicroRestarterApp::MessageReceived(BMessage *msg)
{
switch(msg->what)
{
/*
BMessage from the roster that some program has quit. We parse the BMessage to see if the
message contains the application signature of the restart_daemon.
*/
case B_SOME_APP_QUIT:
{
BString sig;
msg->FindString("be:signature",&sig);
if (sig.ICompare(APP1SIG)==0)
{
//The restart daemon has quit; launch it again.
entry_ref ref;
msg->FindRef("be:ref",&ref);
team_id team=-1;
status_t status=B_ERROR;
status=be_roster->Launch(&ref,(BMessage*)NULL,&team);
if (team==-1)
{
//some error checking and handling should go here... obviously...
(new BAlert("mr","Couldn't restart restart_daemon...","WTF?"))->Go(NULL);
}
}
}break;
/*
BMessage from the roster that some program has started. Again we parse the BMessage to see if
the message contains the application signature of the restart_daemon.
*/
case B_SOME_APP_LAUNCHED:
{
BString sig;
msg->FindString("be:signature",&sig);
if (sig.ICompare(APP1SIG)==0)
{//our partner (the restart_daemon application) has started; we are no longer needed. commit seppuku.
be_app_messenger.SendMessage(B_QUIT_REQUESTED);
}
}break;
default:
BApplication::MessageReceived(msg);
}
}
示例8: strlen
bool
DecisionProvider::YesNoDecisionNeeded(const BString& description,
const BString& question, const BString& yes, const BString& no,
const BString& defaultChoice)
{
if (description.Length() > 0)
printf("%s\n", description.String());
bool haveDefault = defaultChoice.Length() > 0;
while (true) {
printf("%s [%s/%s]%s: ", question.String(), yes.String(), no.String(),
haveDefault
? (BString(" (") << defaultChoice << ") ").String() : "");
if (!fInteractive) {
printf("%s\n", yes.String());
return true;
}
char buffer[32];
if (fgets(buffer, 32, stdin)) {
if (haveDefault && (buffer[0] == '\n' || buffer[0] == '\0'))
return defaultChoice == yes;
int length = strlen(buffer);
for (int i = 1; i <= length; ++i) {
if (yes.ICompare(buffer, i) == 0) {
if (no.ICompare(buffer, i) != 0)
return true;
} else if (no.Compare(buffer, i) == 0) {
if (yes.ICompare(buffer, i) != 0)
return false;
} else
break;
}
fprintf(stderr, "*** please enter '%s' or '%s'\n", yes.String(),
no.String());
}
}
}
示例9: opener
bool
Model::Mimeset(bool force)
{
BString oldType = MimeType();
BPath path;
GetPath(&path);
update_mime_info(path.Path(), 0, 1, force ? 2 : 0);
ModelNodeLazyOpener opener(this);
opener.OpenNode();
AttrChanged(NULL);
return !oldType.ICompare(MimeType());
}
示例10:
bool
FindMessageParameter(const char *name, const BMessage& message, BMessage *save,
int32 *startIndex)
{
// XXX: this should be removed when we can replace BMessage with something better
BString string;
int32 index = startIndex ? *startIndex : 0;
for(; message.FindMessage(MDSU_PARAMETERS, index, save) == B_OK; index++) {
if(save->FindString(MDSU_NAME, &string) == B_OK
&& string.ICompare(name) == 0) {
if(startIndex)
*startIndex = index;
return true;
}
}
return false;
}
示例11: 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;
}
示例12: sizeof
status_t
read_read_attr(BNode& node, read_flags& flag)
{
if (node.ReadAttr(B_MAIL_ATTR_READ, B_INT32_TYPE, 0, &flag, sizeof(int32))
== sizeof(int32))
return B_OK;
#if R5_COMPATIBLE
BString statusString;
if (node.ReadAttrString(B_MAIL_ATTR_STATUS, &statusString) == B_OK) {
if (statusString.ICompare("New"))
flag = B_UNREAD;
else
flag = B_READ;
return B_OK;
}
#endif
return B_ERROR;
}
示例13: opener
bool
Model::Mimeset(bool force)
{
BString oldType = MimeType();
ModelNodeLazyOpener opener(this);
BPath path;
GetPath(&path);
if (force) {
if (opener.OpenNode(true) != B_OK)
return false;
Node()->RemoveAttr(kAttrMIMEType);
update_mime_info(path.Path(), 0, 1, 1);
} else
update_mime_info(path.Path(), 0, 1, 0);
AttrChanged(0);
return !oldType.ICompare(MimeType());
}
示例14: strlen
status_t
BDefaultChoiceList::GetMatch(const char *prefix, int32 startIndex,
int32 *matchIndex, const char **completionText)
{
BString *str;
int32 len = strlen(prefix);
int32 choices = fList->CountItems();
for (int32 i = startIndex; i < choices; i++) {
str = fList->ItemAt(i);
if (!str->ICompare(prefix, len)) {
// prefix matches
*matchIndex = i;
*completionText = str->String() + len;
return B_OK;
}
}
*matchIndex = -1;
*completionText = NULL;
return B_ERROR;
}
示例15: entry
//.........这里部分代码省略.........
AddFile(srcfile, srcgroup);
}
else if (entry == "DEPENDENCY")
{
if (srcfile)
srcfile->fDependencies = value;
}
else if (entry == "LOCALINCLUDE")
{
ProjectPath include(fPath.GetFolder(), value.String());
AddLocalInclude(include.Absolute().String());
}
else if (entry == "SYSTEMINCLUDE")
AddSystemInclude(value.String());
else if (entry == "LIBRARY")
{
if (actualPlatform == fPlatform)
AddLibrary(value.String());
else
ImportLibrary(value.String(),actualPlatform);
}
else if (entry == "GROUP")
srcgroup = AddGroup(value.String());
else if (entry == "EXPANDGROUP")
{
if (srcgroup)
srcgroup->expanded = value == "yes" ? true : false;
}
else if (entry == "TARGETNAME")
fTargetName = value;
else if (entry == "CCDEBUG")
fDebug = value == "yes" ? true : false;
else if (entry == "CCPROFILE")
fProfile = value == "yes" ? true : false;
else if (entry == "CCOPSIZE")
fOpSize = value == "yes" ? true : false;
else if (entry == "CCOPLEVEL")
fOpLevel = atoi(value.String());
else if (entry == "CCTARGETTYPE")
fTargetType = atoi(value.String());
else if (entry == "CCEXTRA")
fExtraCompilerOptions = value;
else if (entry == "LDEXTRA")
fExtraLinkerOptions = value;
else if (entry == "RUNARGS")
fRunArgs = value;
else if (entry == "SCM")
{
if (value.ICompare("hg") == 0)
fSCMType = SCM_HG;
else if (value.ICompare("git") == 0)
fSCMType = SCM_GIT;
else if (value.ICompare("svn") == 0)
fSCMType = SCM_SVN;
else
fSCMType = SCM_NONE;
}
else if (entry == "PLATFORM")
{
if (value.ICompare("Haiku") == 0)
fPlatform = PLATFORM_HAIKU;
else if (value.ICompare("HaikuGCC4") == 0)
fPlatform = PLATFORM_HAIKU_GCC4;
else if (value.ICompare("Zeta") == 0)
fPlatform = PLATFORM_ZETA;
else
fPlatform = PLATFORM_R5;
}
}
line = file.ReadLine();
}
// Fix one of my pet peeves when changing platforms: having to add libsupc++.so whenever
// I change to Haiku GCC4 or GCC4hybrid from any other platform
if (actualPlatform == PLATFORM_HAIKU_GCC4 && actualPlatform != fPlatform)
{
BPath libpath;
find_directory(B_USER_DEVELOP_DIRECTORY,&libpath);
libpath.Append("lib/x86/libsupc++.so");
AddLibrary(libpath.Path());
}
fObjectPath = fPath.GetFolder();
BString objfolder("(Objects.");
objfolder << GetName() << ")";
fObjectPath.Append(objfolder.String());
UpdateBuildInfo();
// We now set the platform to whatever we're building on. fPlatform is only used
// in the project loading code to be able to help cover over issues with changing platforms.
// Most of the time this is just the differences in libraries, but there may be other
// unforeseen issues that will come to light in the future.
fPlatform = actualPlatform;
return B_OK;
}