本文整理汇总了C++中BString::FindLast方法的典型用法代码示例。如果您正苦于以下问题:C++ BString::FindLast方法的具体用法?C++ BString::FindLast怎么用?C++ BString::FindLast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BString
的用法示例。
在下文中一共展示了BString::FindLast方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BString
/*static*/ BString
Playlist::_GetExceptExtension(const BString& path)
{
int32 periodPos = path.FindLast('.');
if (periodPos <= path.FindLast('/'))
return path;
return BString(path.String(), periodPos);
}
示例2:
void
TeamDescriptionView::SetItem(TeamListItem* item)
{
fItem = item;
int32 styleStart = 0;
int32 styleEnd = 0;
BTextView* view = NULL;
if (item == NULL) {
BString text;
text.SetToFormat(fInfoString, fSeconds);
fInfoTextView->SetText(text);
if (fRebootRunner != NULL && fSeconds < 4) {
styleStart = text.FindLast('\n');
styleEnd = text.Length();
}
view = fInfoTextView;
} else {
BString text = item->Path()->Path();
if (item->IsSystemServer())
text << "\n" << fSysComponentString;
if (item->IsRefusingToQuit()) {
text << "\n\n" << fQuitOverdueString;
styleStart = text.FindLast('\n');
styleEnd = text.Length();
}
view = fIconTextView;
fIconTextView->SetText(text);
fIconView->SetIcon(item->Path()->Path());
}
if (styleStart != styleEnd && view != NULL) {
BFont font;
view->GetFont(&font);
font.SetFace(B_BOLD_FACE);
view->SetStylable(true);
view->SetFontAndColor(styleStart, styleEnd, &font);
}
if (fLayout == NULL)
return;
if (item == NULL)
fLayout->SetVisibleItem((int32)0);
else
fLayout->SetVisibleItem((int32)1);
Invalidate();
}
示例3: 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);
}
}
示例4: SyncMailbox
void BMailRemoteStorageProtocol::SyncMailbox(const char *mailbox) {
BPath path(runner->Chain()->MetaData()->FindString("path"));
path.Append(mailbox);
BDirectory folder(path.Path());
BEntry entry;
BFile snoodle;
BString string;
uint32 chain;
bool append;
while (folder.GetNextEntry(&entry) == B_OK) {
if (!entry.IsFile())
continue;
while (snoodle.SetTo(&entry,B_READ_WRITE) == B_BUSY) snooze(100);
append = false;
while (snoodle.Lock() != B_OK) snooze(100);
snoodle.Unlock();
if (snoodle.ReadAttr("MAIL:chain",B_INT32_TYPE,0,&chain,sizeof(chain)) < B_OK)
append = true;
if (chain != runner->Chain()->ID())
append = true;
if (snoodle.ReadAttrString("MAIL:unique_id",&string) < B_OK)
append = true;
BString folder(string), id("");
int32 j = string.FindLast('/');
if ((!append) && (j >= 0)) {
folder.Truncate(j);
string.CopyInto(id,j + 1,string.Length());
if (folder == mailbox)
continue;
} else {
append = true;
}
if (append)
AddMessage(mailbox,&snoodle,&id); //---We should check for partial messages here
else
CopyMessage(folder.String(),mailbox,&id);
string = mailbox;
string << '/' << id;
/*snoodle.RemoveAttr("MAIL:unique_id");
snoodle.RemoveAttr("MAIL:chain");*/
chain = runner->Chain()->ID();
snoodle.WriteAttr("MAIL:chain",B_INT32_TYPE,0,&chain,sizeof(chain));
snoodle.WriteAttrString("MAIL:unique_id",&string);
(*manifest) += string.String();
(*unique_ids) += string.String();
string = runner->Chain()->Name();
snoodle.WriteAttrString("MAIL:account",&string);
}
}
示例5:
void
TeamDescriptionView::SetItem(TeamListItem* item)
{
fItem = item;
if (item == NULL) {
int32 styleStart = 0;
int32 styleEnd = 0;
BString text;
text.SetToFormat(fInfoString, fSeconds);
fInfoTextView->SetText(text);
if (fRebootRunner != NULL && fSeconds < 4) {
styleStart = text.FindLast('\n');
styleEnd = text.Length();
}
if (styleStart != styleEnd && fInfoTextView != NULL) {
BFont font;
fInfoTextView->GetFont(&font);
font.SetFace(B_BOLD_FACE);
fInfoTextView->SetStylable(true);
fInfoTextView->SetFontAndColor(styleStart, styleEnd, &font);
}
} else {
fTeamName->SetText(item->Path()->Path());
if (item->IsSystemServer()) {
if (fSysComponent->IsHidden(fSysComponent))
fSysComponent->Show();
} else {
if (!fSysComponent->IsHidden(fSysComponent))
fSysComponent->Hide();
}
if (item->IsRefusingToQuit()) {
if (fQuitOverdue->IsHidden(fQuitOverdue))
fQuitOverdue->Show();
} else {
if (!fQuitOverdue->IsHidden(fQuitOverdue))
fQuitOverdue->Hide();
}
fIconView->SetIcon(item->Path()->Path());
}
if (fLayout == NULL)
return;
if (item == NULL)
fLayout->SetVisibleItem((int32)0);
else
fLayout->SetVisibleItem((int32)1);
Invalidate();
}
示例6: 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();
}
示例7:
BString
FormatResultString(const BString& resultPath)
{
BString result;
int32 end = resultPath.FindFirst("CodeName") - 2;
int32 start = resultPath.FindLast('/', end) + 1;
if (end - start > 1) {
resultPath.CopyInto(result, start, end - start + 1);
result += "::";
result += &resultPath.String()[resultPath.FindLast('/',
resultPath.Length()) + 1];
} else {
int32 secbegin = resultPath.FindLast('/', resultPath.Length()) + 1;
resultPath.CopyInto(result, secbegin, resultPath.Length() - secbegin);
}
return result;
}
示例8: relative
BUrl::BUrl(const BUrl& base, const BString& location)
:
fUrlString(),
fProtocol(),
fUser(),
fPassword(),
fHost(),
fPort(0),
fPath(),
fRequest(),
fHasAuthority(false)
{
// This implements the algorithm in RFC3986, Section 5.2.
BUrl relative(location);
if (relative.HasProtocol()) {
SetProtocol(relative.Protocol());
SetAuthority(relative.Authority());
SetPath(relative.Path()); // TODO _RemoveDotSegments()
SetRequest(relative.Request());
} else {
if (relative.HasAuthority()) {
SetAuthority(relative.Authority());
SetPath(relative.Path()); // TODO _RemoveDotSegments()
SetRequest(relative.Request());
} else {
if (relative.Path().IsEmpty()) {
SetPath(base.Path());
if (relative.HasRequest())
SetRequest(relative.Request());
else
SetRequest(Request());
} else {
if (relative.Path()[0] == '/')
SetPath(relative.Path());
else {
BString path = base.Path();
// Remove last part of path (the file, if any) so we get the
// "current directory"
path.Truncate(path.FindLast('/') + 1);
path += relative.Path();
// TODO _RemoveDotSegments()
SetPath(path);
}
SetRequest(relative.Request());
}
SetAuthority(base.Authority());
}
SetProtocol(base.Protocol());
}
SetFragment(relative.Fragment());
}
示例9:
bool
AutoConfigView::IsValidMailAddress(BString email)
{
int32 atPos = email.FindFirst("@");
if (atPos < 0)
return false;
BString provider;
email.CopyInto(provider, atPos + 1, email.Length() - atPos);
if (provider.FindLast(".") < 0)
return false;
return true;
}
示例10:
OpenPackageAction(PackageInfoRef package, Model* model,
const DeskbarLink& link)
:
PackageAction(PACKAGE_ACTION_OPEN, package, model),
fDeskbarLink(link),
fLabel(B_TRANSLATE("Open %DeskbarLink%"))
{
BString target = fDeskbarLink.link;
int32 lastPathSeparator = target.FindLast('/');
if (lastPathSeparator > 0 && lastPathSeparator + 1 < target.Length())
target.Remove(0, lastPathSeparator + 1);
fLabel.ReplaceAll("%DeskbarLink%", target);
}
示例11: 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;
}
示例12: _SplitNormalizedPath
void _SplitNormalizedPath(const BString& path, BString& _directory,
BString& _name)
{
// handle single component (including root dir) cases
int32 lastSlash = path.FindLast('/');
if (lastSlash < 0 || path.Length() == 1) {
_directory = (const char*)NULL;
_name = path;
return;
}
// handle root dir + one component and multi component cases
if (lastSlash == 0)
_directory = "/";
else
_directory.SetTo(path, lastSlash);
_name = path.String() + (lastSlash + 1);
}
示例13: GotoParent
void PanelView::GotoParent(void)
////////////////////////////////////////////////////////////////////////
{
// To set the cursor to the child entry where we came from...
BString oldpath;
SetPanelMode(PM_NORMAL);
oldpath.SetTo(m_Path.String());
oldpath.Remove(0,oldpath.FindLast('/')+1);
BPath path((const char *)m_Path.String());
if (path.GetParent(&path)==B_OK)
m_Path.SetTo(path.Path());
SetPathStringView();
ClearFileList();
ReadDirectory(oldpath.String());
}
示例14: HashString
BHttpAuthentication&
BUrlContext::GetAuthentication(const BUrl& url)
{
BString domain = url.Host();
domain += url.Path();
BHttpAuthentication* authentication = NULL;
do {
authentication = fAuthenticationMap->Get( HashString(domain.String(),
domain.Length()));
domain.Truncate(domain.FindLast('/'));
} while(authentication == NULL);
return *authentication;
}
示例15: 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;
}