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


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

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


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

示例1:

void
OutputView::_SetFileNameExtension(const char* newExtension)
{
	// TODO: If fFileExtension contains the wrong extension
	// (for example if the user renamed the file manually)
	// this will fail. For example, outputfile.avi, but 
	// fFileExtension is mkv -> outputfile.avi.mkv
	BString fileName = fFileName->Text();
	BString extension = ".";
	extension.Append(fFileExtension);
	fileName.RemoveLast(extension);
	fFileExtension = newExtension;
	fileName.Append(".");
	fileName.Append(fFileExtension);
	fFileName->SetText(fileName.String());
}
开发者ID:,项目名称:,代码行数:16,代码来源:

示例2: while

void
MessageWindow::TabExpansion (void)
{
  int32 start,
        finish;

  input->TextView()->GetSelection (&start, &finish);

  if (input->TextView()->TextLength()
  &&  start == finish
  &&  start == input->TextView()->TextLength())
  {
    const char *inputText (
                  input->TextView()->Text()
                  + input->TextView()->TextLength());
    const char *place (inputText);
		

    while (place > input->TextView()->Text())
    {
      if (*(place - 1) == '\x20')
        break;
      --place;
    }
		
    BString insertion;

    if (!id.ICompare (place, strlen (place)))
    {
      insertion = id;
      insertion.RemoveLast(" [DCC]");
    }
		
    if (insertion.Length())
    {
      input->TextView()->Delete (
        place - input->TextView()->Text(),
        input->TextView()->TextLength());

      input->TextView()->Insert (insertion.String());
      input->TextView()->Select (
        input->TextView()->TextLength(),
        input->TextView()->TextLength());
    }
  }
}
开发者ID:,项目名称:,代码行数:46,代码来源:

示例3: beep

bool
EthernetSettingsView::_ValidateControl(BTextControl* control)
{
    static const char* pattern = "^(25[0-5]|2[0-4][0-9]|[01][0-9]{2}|[0-9]"
                                 "{1,2})(\\.(25[0-5]|2[0-4][0-9]|[01][0-9]{2}|[0-9]{1,2})){3}$";

    if (control->IsEnabled() && !MatchPattern(control->Text(), pattern)) {
        control->MakeFocus();
        BString errorMessage;
        errorMessage << control->Label();
        errorMessage.RemoveLast(":");
        errorMessage << " is invalid";
        fErrorMessage->SetText(errorMessage.String());
        beep();
        return false;
    }
    return true;
}
开发者ID:,项目名称:,代码行数:18,代码来源:

示例4: main

//---------------------------------------------------------------
int main(int32 argc, char** argv)
{
//We save the execDir to the settings file
BPath path;
BString tmp;
MSave savefile("savefile");
find_directory(B_COMMON_SETTINGS_DIRECTORY, &path);
tmp.SetTo(path.Path());
tmp.Append(SAVE_SETTINGS_PATH);
path.SetTo(tmp.String());
tmp.SetTo(argv[0]);
tmp.RemoveLast(STR_EXEC_FILE_NAME);
savefile.AddString(path, SAVE_FILE_NAME, NAME_EXEC_DIR, tmp.String(), true);

new mApp();
be_app->Run();
return(0);
}
开发者ID:zzzzzzzzz,项目名称:Organizer,代码行数:19,代码来源:main.cpp

示例5: path

void
SourceFileRez::RemoveObjects(BuildInfo &info)
{
	if (BString(GetPath().GetExtension()).ICompare("r") != 0)
		return;
	
	DPath path(GetTempFilePath(info));
	
	BString base = path.GetFolder();
	base << "/" << path.GetBaseName() << ".txt";
	BEntry(base.String()).Remove();

	base = path.GetFolder();
	base << "/" << path.GetBaseName();
	base.RemoveLast(".r");
	base << ".rsrc";
	BEntry(base.String()).Remove();
}
开发者ID:HaikuArchives,项目名称:Paladin,代码行数:18,代码来源:SourceTypeRez.cpp

示例6: entry

/*static*/ void
Playlist::AppendPlaylistToPlaylist(const entry_ref& ref, Playlist* playlist)
{
	BEntry entry(&ref, true);
	if (entry.InitCheck() != B_OK || !entry.Exists())
		return;

	BString mimeString = _MIMEString(&ref);
	if (_IsTextPlaylist(mimeString)) {
		//printf("RunPlaylist thing\n");
		BFile file(&ref, B_READ_ONLY);
		FileReadWrite lineReader(&file);

		BString str;
		entry_ref refPath;
		status_t err;
		BPath path;
		while (lineReader.Next(str)) {
			str = str.RemoveFirst("file://");
			str = str.RemoveLast("..");
			path = BPath(str.String());
			printf("Line %s\n", path.Path());
			if (path.Path() != NULL) {
				if ((err = get_ref_for_path(path.Path(), &refPath)) == B_OK) {
					PlaylistItem* item
						= new (std::nothrow) FilePlaylistItem(refPath);
					if (item == NULL || !playlist->AddItem(item))
						delete item;
				} else
					printf("Error - %s: [%lx]\n", strerror(err), (int32) err);
			} else
				printf("Error - No File Found in playlist\n");
		}
	} else if (_IsBinaryPlaylist(mimeString)) {
		BFile file(&ref, B_READ_ONLY);
		Playlist temp;
		if (temp.Unflatten(&file) == B_OK)
			playlist->AdoptPlaylist(temp, playlist->CountItems());
	}
}
开发者ID:michael-manley,项目名称:haiku,代码行数:40,代码来源:Playlist.cpp

示例7: MountImage

// Mounts the specified image file (filename) assuming it contains the 
// specified file system.
int app::MountImage(const char *filename, const char *filesystem) {
	int	timeout=3;
	int retvalue;
	BString	mountpoint;
	BEntry	entry;
	int mountpoint_counter=0;
	
	do {
		mountpoint="/";
		mountpoint.Append(FindMountPointName(filename));
		while (mountpoint[mountpoint.Length()-1]==0x20)
			mountpoint.RemoveLast(" ");
		if (mountpoint_counter>0)
			mountpoint << " " << mountpoint_counter;
		entry.SetTo(mountpoint.String());
		mountpoint_counter++;
	} while(entry.Exists());
	CreateDirectory(mountpoint.String());
	
	while ((retvalue=mount(filesystem,mountpoint.String(),filename,2,NULL,0))<0) {
		snooze(100000); // omg! ;)
		timeout--;
		if (timeout==0) {
			entry.Remove();
			mountpoint_counter--;
			entry.Unset();
			return -1;
		}
	};
	printf("mounted.\nfilename:\t%s\nfilesystem:\t%s\nmountpoint:\t%s\n", filename, filesystem, mountpoint.String());
	if (retvalue<0) {
		entry.Remove();
		mountpoint_counter--;
	}
	entry.Unset();
	return retvalue;
}
开发者ID:HaikuArchives,项目名称:ImageMounter,代码行数:39,代码来源:app.cpp

示例8: Load

status_t TConfigFile::Load()
{
	int32 textlen;
	char text[2048], *value;
	BString buff;
	config_t *item;
	FILE *fd = fopen(fPathName.String(), "r");
	if (!fd) return errno;
	while (!feof(fd)) {
		if (fgets(text, sizeof(text), fd) == NULL) break;
		buff.Append(text);
		textlen = strlen(text);
		if (text[textlen - 1] == '\n') {
			buff.RemoveLast("\n");
			value = strchr(buff.String(), ' ');
			if (value != NULL) {
				if ((item = (config_t *)calloc(sizeof(config_t), 1)) == NULL) {
					fclose(fd);
					return ENOMEM;
				}
				if (!fList.AddItem(item)) {
					free(item);
					fclose(fd);
					return ENOMEM;
				}
				*value = 0;
				value++;
				strncpy(item->key, buff.String(), sizeof(item->key));
				strncpy(item->value, value, sizeof(item->value));
			}
			buff.SetTo("");
		}
	}
	fclose(fd);
	return B_OK;
}
开发者ID:HaikuArchives,项目名称:FtpPositive,代码行数:36,代码来源:ConfigFile.cpp

示例9: MainLoop

//---------------------------------------------------------------
void ExportWindow::MainLoop()
{
BString fFilePath;
BString fFolderPath;
BString fFileName;
BPath Path;
BEntry Entry("/boot/home");
MSave Load("Load");

find_directory(B_COMMON_SETTINGS_DIRECTORY, &Path);
fFolderPath.SetTo(Path.Path());
fFolderPath.Append(SAVE_NOTE_PATH);

	for (int a = 1; a <= 31; a++)
	{
	fFileName.SetTo("");
	fFileName << a << "-" << fMonth << fYear << "-";
		for (int b = 1; b <= INT_MAXFILES; b++)
		{
		fFileName << b;
		fFilePath.SetTo(fFolderPath);
		fFilePath << fFileName.String();
		Entry.SetTo(fFilePath.String());
			if (Entry.Exists())
			{
			Load.FindString(fFilePath.String(), SAVE_FILE_TYPE, &fType, "M_ERROR");
				
				if (!strcmp(fType.String(), "Note") || !strcmp(fType.String(), "Apointment"))
				{
					//Add the date if it is the first note/apointment of this day
					if (fFirstNoteOfTheDay)
					{
					fContent << "<table width=450 color=\"#FFFFFF\">\n";
					fContent << "<h2>" << a << "." << fMonth << "-" << fYear << "</h2>\n";
					fFirstNoteOfTheDay = false;
					}
					
					//Change the color
					if (!strcmp(TableColor.String(), TableBGColor1.String()))
					{
					TableColor.SetTo(TableBGColor2);
					}
					else
					{
					TableColor.SetTo(TableBGColor1);
					}	
				}
				
				//Its a note
				if (!strcmp(fType.String(), "Note") && _ExportView->mNoteCheckBox->Value())
				{
				Load.FindString(fFilePath.String(), SAVE_FILE_NOTE, &fNote, "M_ERROR");
				Load.FindString(fFilePath.String(), SAVE_FILE_TITLE, &fTitle, "M_ERROR");
				
				fContent << "<tr><td bgcolor=\"" << TableColor.String() << "\" width=430>\n";
				fContent << "<h4>"<< fTitle.String() << "</h4>";
				fNote.ReplaceAll("\n", "<br>");
				fContent << fNote.String() << "\n";
				fContent << "</tr></td>\n";
				}
				
				//Its an apointment
				if (!strcmp(fType.String(), "Apointment") && _ExportView->mApointmentCheckBox->Value())
				{
				Load.FindString(fFilePath.String(), SAVE_FILE_NOTE, &fNote, "M_ERROR");
				Load.FindString(fFilePath.String(), SAVE_FILE_TITLE, &fTitle, "M_ERROR");
				Load.FindString(fFilePath.String(), SAVE_FILE_TIME, &fTime, "M_ERROR");
				
				fContent << "<tr><td bgcolor=\"" << TableColor.String() << "\" width=430>\n";
				fContent << "<h4>"<< fTitle.String() << "";
				
				tmpString.SetTo(fTime);
				tmpString.Remove(0, tmpString.FindFirst(":") + 1);
					if (tmpString.CountChars() == 1)
					{
					fTime.RemoveLast(tmpString.String());
					fTime.Append("0");
					fTime.Append(tmpString.String());
					}
				fContent << "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"<< fTime.String() << "</h4>\n";
				fNote.ReplaceAll("\n", "<br>");
				fContent << fNote.String() << "\n";
				fContent << "</tr></td>\n";
				}
			}
		tmpString.SetTo("");
		tmpString << b;
		fFileName.RemoveLast(tmpString.String());
		}
		if (!fFirstNoteOfTheDay)
		{
		fContent << "</table>\n";
		fContent << "<br>";
		}
	fFirstNoteOfTheDay = true;
	}
}
开发者ID:zzzzzzzzz,项目名称:Organizer,代码行数:98,代码来源:exportWindow.cpp

示例10: app

int
main(int argc, char** argv)
{
	if (argc < 2) {
		printf("usage: %s [-l|-c|decorname]\n", argv[0]);
		printf("\t-l: list available decors\n");
		printf("\t-s: list shortcut names for available decors\n");
		printf("\t-c: give current decor name\n");
		printf("\t-i: detailed information about decor\n");
		printf("\t-p: see preview window\n");
		return 1;
	}

	// combine remaining args into one string:
	BString decoratorName;
	for (int i = 2; i < argc; ++i)
		decoratorName << argv[i] << " ";
	decoratorName.RemoveLast(" ");

	BApplication app("application/x-vnd.Haiku-setdecor");

	DecorInfoUtility* util = new DecorInfoUtility();
	DecorInfo* decor = NULL;

	if (util == NULL) {
		fprintf(stderr, "error instantiating DecoratorInfoUtility (out of"
			" memory?)\n");
		return 1;
	}

	// we want the list
	if (!strcmp(argv[1], "-l")) {
		// Print default decorator:
		print_decor_info_header();
		int32 count = util->CountDecorators();
		for (int32 i = 0; i < count; ++i) {
			decor = util->DecoratorAt(i);
			if (decor == NULL) {
				fprintf(stderr, "error NULL entry @ %li / %li - BUG BUG BUG\n",
					i, count);
				// return 2 to track DecorInfoUtility errors
				return 2;
			}
			print_decor_summary(decor, util->IsCurrentDecorator(decor));
		}

		return 0;
	}

	// we want the current decorator
	if (!strcmp(argv[1], "-c")) {
		decor = util->CurrentDecorator();

		if (decor == NULL) {
			fprintf(stderr, "Unable to determine current decorator, sorry! - "
				"BUG BUG BUG\n");
			return 2;
		}

		print_decor_info_header();
		print_decor_summary(decor, true);
		return 0;
	}


	if (!strcmp(argv[1], "-s")) {

		printf("  Shortcut        Name\n");
		printf("------------------------------------\n");

		int32 count = util->CountDecorators();
		for (int32 i = 0; i < count; ++i) {
			decor = util->DecoratorAt(i);
			if (decor == NULL) {
				fprintf(stderr, "error NULL entry @ %li / %li - BUG BUG BUG\n",
					i, count);
				// return 2 to track DecorInfoUtility errors
				return 2;
			}
			print_decor_shortcut(decor, util->IsCurrentDecorator(decor));
		}

		return 0;
	}

	// we want detailed information for a specific decorator ( by name or path )
	if (!strcmp(argv[1], "-i")) {
		if (argc < 3) {
			fprintf(stderr, "not enough arguments\n");
			return 1;
		}

		decor = util->FindDecorator(decoratorName.String());

		if (decor == NULL) {
			fprintf(stderr, "Can't find decor named \"%s\", try again\n",
				decoratorName.String());
			return 1;
		}

//.........这里部分代码省略.........
开发者ID:AmirAbrams,项目名称:haiku,代码行数:101,代码来源:setdecor.cpp

示例11: GetPath

void
SourceFileC::UpdateDependencies(BuildInfo &info)
{
	BString abspath = GetPath().GetFullPath();
	if (abspath[0] != '/')
	{
		abspath.Prepend("/");
		abspath.Prepend(info.projectFolder.GetFullPath());
	}
	
	BString command;
	
	if (gUseFastDep && gFastDepAvailable)
		command << "fastdep " << info.includeString << " '" << abspath.String() << "'";
	else
		command << "gcc -MM " << info.includeString << " '" << abspath.String() << "'";
	
	BString depstr;
	RunPipedCommand(command.String(), depstr, true);
	
	STRACE(1,("Update Dependencies for %s\nCommand:%s\nOutput:%s\n",
			GetPath().GetFullPath(),command.String(),depstr.String()));
	
	if (gUseFastDep && gFastDepAvailable)
	{
		if (depstr.FindFirst("error ") == 0)
		{
			int32 index, startpos = 0;
			index = depstr.FindFirst("error ", startpos);
			while (index >= 0)
			{
				startpos = index + 6;
				index = depstr.FindFirst("error ", startpos);
			}
			
			index = depstr.FindFirst("\n") + 1;
			depstr = depstr.String() + index;
		}
		
		// The first part of the dependency string should be FileName.o:
		int32 secondlinepos = depstr.FindFirst("\n") + 1;
		
		BString tempstr = depstr;
		depstr = tempstr.String() + secondlinepos;
		
		depstr.ReplaceAll(" \\\n\t","|");
		
		if (depstr.FindLast("\n") == depstr.CountChars() - 1)
			depstr.RemoveLast("\n");
		
		if (depstr.FindFirst(" ") == 0)
			depstr.RemoveFirst(" ");
		
		fDependencies = depstr;
	}
	else
	{
		// The reason that all of this works is because the absolute paths force
		// each file to be on a separate line. Going with relative paths is FAR more
		// of a headache than I want to mess with. Bleah.
		
		if (depstr.FindFirst(" warning: ") >= 0)
		{
			int32 index, startpos = 0;
			index = depstr.FindFirst(" warning: ", startpos);
			while (index >= 0)
			{
				startpos = index + 10;
				index = depstr.FindFirst(" warning: ", startpos);
			}
			
			index = depstr.FindFirst("\n") + 1;
			depstr = depstr.String() + index;
		}
		
		// The first part of the dependency string should be FileName.o:
		BString objfilename = GetPath().GetBaseName();
		objfilename << ".o: ";
		
		int32 filenamepos = depstr.FindFirst(objfilename.String());
		if (filenamepos == 0)
		{
			int32 lineend = depstr.FindFirst("\n",filenamepos);
			if (lineend >= 0)
				fDependencies = depstr.String() + lineend + 2;
		}
		else
			fDependencies = depstr.String();
		
		fDependencies.RemoveSet("\\\n");
		fDependencies.ReplaceAll("  ","|");
		fDependencies.ReplaceAll("| ","|");
		if (fDependencies[0] == ' ')
			fDependencies.RemoveFirst(" ");
	}
}
开发者ID:HaikuArchives,项目名称:Paladin,代码行数:96,代码来源:SourceTypeC.cpp

示例12: firstWord


//.........这里部分代码省略.........
	}
		
	
	if (firstWord == "/DNS")
	{
		BString parms (GetWord(data, 2));
	
		ChannelWindow *window;
		MessageWindow *message;
		
		if ((window = dynamic_cast<ChannelWindow *>(this)))
		{
				int32 count (window->namesList->CountItems());
				
				for (int32 i = 0; i < count; ++i)
				{
					NameItem *item ((NameItem *)(window->namesList->ItemAt (i)));
					
					if (!item->Name().ICompare (parms.String(), strlen (parms.String()))) //nick
					{
						BMessage send (M_SERVER_SEND);
						AddSend (&send, "USERHOST ");
						AddSend (&send, item->Name().String());
						AddSend (&send, endl);
						PostMessage(&send);	
						return true;				
					}
				}
		}
	
		else if ((message = dynamic_cast<MessageWindow *>(this)))
		{
			BString eid (id);
			eid.RemoveLast (" [DCC]");
			if (!ICompare(eid, parms) || !ICompare(myNick, parms))
			{
				BMessage send (M_SERVER_SEND);
				AddSend (&send, "USERHOST ");
				AddSend (&send, parms.String());
				AddSend (&send, endl);
				PostMessage(&send);
				return true;
			}
		}
			
		if (parms != "-9z99")
		{
			BMessage *msg (new BMessage);
			msg->AddString ("lookup", parms.String());
			msg->AddPointer ("client", this);
			
			thread_id lookupThread = spawn_thread (
				DNSLookup,
				"dns_lookup",
				B_LOW_PRIORITY,
				msg);
	
			resume_thread (lookupThread);
		}
		
		return true;
	}
	
	
	if (firstWord == "/PEXEC") // piped exec
	{
开发者ID:,项目名称:,代码行数:67,代码来源:


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