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


C++ string::IsEmpty方法代码示例

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


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

示例1: replaceAll

/* TextEditor::replaceAll
 * Replaces all occurrences of [find] in the text with [replace].
 * Returns the number of occurrences replaced
 *******************************************************************/
int TextEditor::replaceAll(string find, string replace, int flags)
{
	// Check search string
	if (find.IsEmpty())
		return false;

	// Start at beginning
	SetSelection(0, 0);

	// Loop of death
	int replaced = 0;
	while (true)
	{
		SearchAnchor();
		int found = SearchNext(flags, find);
		if (found < 0)
			break;	// No matches, finished
		else
		{
			// Replace text & increment counter
			Replace(found, found + find.length(), replace);
			replaced++;

			// Continue from end of replaced text
			SetSelection(found + find.length(), found + find.length());
		}
	}

	// Return number of instances replaced
	return replaced;
}
开发者ID:Gaerzi,项目名称:SLADE,代码行数:35,代码来源:TextEditor.cpp

示例2: findNext

/* TextEditor::findNext
 * Finds the next occurrence of the [find] after the caret position,
 * selects it and scrolls to it if needed. Returns false if the
 * [find] was invalid or no match was found, true otherwise
 *******************************************************************/
bool TextEditor::findNext(string find)
{
	// Check search string
	if (find.IsEmpty())
		return false;

	// Setup target range
	SetTargetEnd(GetTextLength());
	SetTargetStart(GetSelectionEnd());

	// Search within current target range
	if (SearchInTarget(find) < 0)
	{
		// None found, search again from start
		SetTargetStart(0);
		SetTargetEnd(GetTextLength());
		if (SearchInTarget(find) < 0)
		{
			// No matches found in entire text
			return false;
		}
	}

	// Select matched text
	SetSelection(GetTargetStart(), GetTargetEnd());

	// Scroll to selection
	EnsureCaretVisible();

	return true;
}
开发者ID:macressler,项目名称:SLADE,代码行数:36,代码来源:TextEditor.cpp

示例3: wxControl

SToolBarButton::SToolBarButton(wxWindow* parent, string action, string icon)
	: wxControl(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxDefaultValidator, "stbutton")
{
	// Init variables
	this->action = theApp->getAction(action);
	this->state = STATE_NORMAL;

	// Set size
	int size = 22;
	SetSizeHints(size, size, size, size);
	SetMinSize(wxSize(size, size));
	SetSize(size, size);

	// Load icon
	if (icon.IsEmpty())
		this->icon = getIcon(this->action->getIconName());
	else
		this->icon = getIcon(icon);

	// Set tooltip
	string tip = this->action->getText();
	tip.Replace("&", "");
	SetToolTip(tip);

	// Bind events
	Bind(wxEVT_PAINT, &SToolBarButton::onPaint, this);
	Bind(wxEVT_ENTER_WINDOW, &SToolBarButton::onMouseEvent, this);
	Bind(wxEVT_LEAVE_WINDOW, &SToolBarButton::onMouseEvent, this);
	Bind(wxEVT_LEFT_DOWN, &SToolBarButton::onMouseEvent, this);
	Bind(wxEVT_LEFT_UP, &SToolBarButton::onMouseEvent, this);
	Bind(wxEVT_KILL_FOCUS, &SToolBarButton::onFocus, this);
	Bind(wxEVT_LEFT_DCLICK, &SToolBarButton::onMouseEvent, this);
	Bind(wxEVT_ERASE_BACKGROUND, &SToolBarButton::onEraseBackground, this);
}
开发者ID:IjonTichy,项目名称:SLADE,代码行数:34,代码来源:SToolBarButton.cpp

示例4: replaceCurrent

/* TextEditor::replaceCurrent
 * Replaces the currently selected occurrence of [find] with
 * [replace], then selects and scrolls to the next occurrence of
 * [find] in the text. Returns false if [find] is invalid or the
 * current selection does not match it, true otherwise
 *******************************************************************/
bool TextEditor::replaceCurrent(string find, string replace)
{
	// Check search string
	if (find.IsEmpty())
		return false;

	// Check that we've done a find previously
	// (by searching for the find string within the current selection)
	if (GetSelectedText().Length() != find.Length())
		return false;
	SetTargetStart(GetSelectionStart());
	SetTargetEnd(GetSelectionEnd());
	if (SearchInTarget(find) < 0)
		return false;

	// Do the replace
	ReplaceTarget(replace);

	// Update selection
	SetSelection(GetTargetStart(), GetTargetEnd());

	// Do find next
	findNext(find);

	return true;
}
开发者ID:macressler,项目名称:SLADE,代码行数:32,代码来源:TextEditor.cpp

示例5: PrepareOptFolder

static void PrepareOptFolder(string &strSrc, int IsLocalPath_FarPath)
{
	if (strSrc.IsEmpty())
	{
		strSrc = g_strFarPath;
		DeleteEndSlash(strSrc);
	}
	else
	{
		apiExpandEnvironmentStrings(strSrc, strSrc);
	}

	if (!StrCmp(strSrc,L"/"))
	{
		strSrc = g_strFarPath;

		if (IsLocalPath_FarPath)
		{
			strSrc.SetLength(2);
			strSrc += L"\\";
		}
	}
	else
	{
		CheckShortcutFolder(&strSrc,FALSE,TRUE);
	}

	//ConvertNameToFull(strSrc,strSrc);
}
开发者ID:alexlav,项目名称:conemu,代码行数:29,代码来源:filepanels.cpp

示例6: replaceAll

/* TextEditor::replaceAll
 * Replaces all occurrences of [find] in the text with [replace].
 * Returns the number of occurrences replaced
 *******************************************************************/
int TextEditor::replaceAll(string find, string replace)
{
	// Check search string
	if (find.IsEmpty())
		return false;

	// Init search target to entire text
	SetTargetStart(0);
	SetTargetEnd(GetTextLength());

	// Loop of death
	int replaced = 0;
	while (1)
	{
		if (SearchInTarget(find) < 0)
			break;	// No matches, finished
		else
		{
			// Replace text & increment counter
			ReplaceTarget(replace);
			replaced++;

			// Continue search from end of replaced text to end of text
			SetTargetStart(GetTargetEnd());
			SetTargetEnd(GetTextLength());
		}
	}

	// Return number of instances replaced
	return replaced;
}
开发者ID:macressler,项目名称:SLADE,代码行数:35,代码来源:TextEditor.cpp

示例7: filterItems

/* BrowserCanvas::filterItems
 * Filters the visible items by [filter], by name
 *******************************************************************/
void BrowserCanvas::filterItems(string filter)
{
	// Clear current filter list
	items_filter.clear();

	// If the filter is empty, just add all items to the filter
	if (filter.IsEmpty())
	{
		for (unsigned a = 0; a < items.size(); a++)
			items_filter.push_back(a);
	}
	else
	{
		// Setup filter string
		filter.MakeLower();
		filter += "*";

		// Go through items
		for (unsigned a = 0; a < items.size(); a++)
		{
			// Add to filter list if name matches
			if (items[a]->getName().Lower().Matches(filter))
				items_filter.push_back(a);
		}
	}

	// Update scrollbar and refresh
	updateScrollBar();
	Refresh();
}
开发者ID:Genghoidal,项目名称:SLADE,代码行数:33,代码来源:BrowserCanvas.cpp

示例8: filterItems

/* BrowserCanvas::filterItems
 * Filters the visible items by [filter], by name
 *******************************************************************/
void BrowserCanvas::filterItems(string filter)
{
	// Find the currently-viewed item before we change the item list
	int viewed_index = getViewedIndex();

	// Clear current filter list
	items_filter.clear();

	// If the filter is empty, just add all items to the filter
	if (filter.IsEmpty())
	{
		for (unsigned a = 0; a < items.size(); a++)
			items_filter.push_back(a);
	}
	else
	{
		// Setup filter string
		filter.MakeLower();
		filter += "*";

		// Go through items
		for (unsigned a = 0; a < items.size(); a++)
		{
			// Add to filter list if name matches
			if (items[a]->getName().Lower().Matches(filter))
				items_filter.push_back(a);
		}
	}

	// Update scrollbar and refresh
	updateLayout(viewed_index);
}
开发者ID:jmickle66666666,项目名称:SLADE,代码行数:35,代码来源:BrowserCanvas.cpp

示例9: save

/* Archive::save
 * This is the general, all-purpose 'save archive' function. Takes
 * into account whether the archive is contained within another,
 * is already on the disk, etc etc. Does a 'save as' if [filename]
 * is specified, unless the archive is contained within another.
 * Returns false if saving was unsuccessful, true otherwise
 *******************************************************************/
bool Archive::save(string filename)
{
	bool success = false;

	// Check if the archive is read-only
	if (read_only)
	{
		Global::error = "Archive is read-only";
		return false;
	}

	// If the archive has a parent ArchiveEntry, just write it to that
	if (parent)
	{
		success = write(parent->getMCData());
		parent->setState(1);
	}
	else
	{
		// Otherwise, file stuff
		if (!filename.IsEmpty())
		{
			// New filename is given (ie 'save as'), write to new file and change archive filename accordingly
			success = write(filename);
			if (success) this->filename = filename;

			// Update variables
			this->on_disk = true;
		}
		else if (!this->filename.IsEmpty())
		{
			// No filename is given, but the archive has a filename, so overwrite it (and make a backup)

			// Create backup
			if (wxFileName::FileExists(this->filename) && save_backup)
			{
				// Copy current file contents to new backup file
				string bakfile = this->filename + ".bak";
				wxLogMessage("Creating backup %s", bakfile);
				wxCopyFile(this->filename, bakfile, true);
			}

			// Write it to the file
			success = write(this->filename);

			// Update variables
			this->on_disk = true;
		}
	}

	// If saving was successful, update variables and announce save
	if (success)
	{
		setModified(false);
		announce("saved");
	}

	return success;
}
开发者ID:Aeyesx,项目名称:SLADE,代码行数:66,代码来源:Archive.cpp

示例10: nExternalExes

/* Executables::nExternalExes
 * Returns the number of external executables for [category], or
 * all if [category] is not specified
 *******************************************************************/
int Executables::nExternalExes(string category)
{
	int num = 0;
	for (auto& exe : external_exes)
		if (category.IsEmpty() || exe.category == category)
			num++;

	return num;
}
开发者ID:Gaerzi,项目名称:SLADE,代码行数:13,代码来源:Executables.cpp

示例11: getExternalExe

/* Executables::getExternalExe
 * Returns the external executable matching [name] and [category].
 * If [category] is empty, it is ignored
 *******************************************************************/
Executables::external_exe_t Executables::getExternalExe(string name, string category)
{
	for (auto& exe : external_exes)
		if (category.IsEmpty() || exe.category == category)
			if (exe.name == name)
				return exe;

	return external_exe_t();
}
开发者ID:Gaerzi,项目名称:SLADE,代码行数:13,代码来源:Executables.cpp

示例12:

/* Executables::getExternalExe
 * Returns a list of all external executables matching [category].
 * If [category] is empty, it is ignored
 *******************************************************************/
vector<Executables::external_exe_t> Executables::getExternalExes(string category)
{
	vector<external_exe_t> ret;
	for (auto& exe : external_exes)
		if (category.IsEmpty() || exe.category == category)
			ret.push_back(exe);

	return ret;
}
开发者ID:Gaerzi,项目名称:SLADE,代码行数:13,代码来源:Executables.cpp

示例13: addPalette

/* PaletteManager::addPalette
 * Adds the palette [pal] to the list of managed palettes, identified
 * by [name]. Returns false if the palette doesn't exist or the name
 * is invalid, true otherwise
 *******************************************************************/
bool PaletteManager::addPalette(Palette8bit* pal, string name)
{
	// Check palette and name were given
	if (!pal || name.IsEmpty())
		return false;

	// Add palette+name
	palettes.push_back(pal);
	pal_names.push_back(name);

	return true;
}
开发者ID:DemolisherOfSouls,项目名称:SLADE,代码行数:17,代码来源:PaletteManager.cpp

示例14: farPrepareFileName

void farPrepareFileName(string& strFileName)
{
	apiExpandEnvironmentStrings(strFileName, strFileName);

	farUnquote(strFileName);
	farTrim(strFileName);

	if ( strFileName.IsEmpty() )
		strFileName = _T(".");

	farGetFullPathName(strFileName, strFileName);
}
开发者ID:CyberShadow,项目名称:FAR,代码行数:12,代码来源:FarApi.cpp

示例15: open

/* SImage::open
 * Detects the format of [data] and, if it's a valid image format,
 * loads it into this image
 *******************************************************************/
bool SImage::open(MemChunk& data, int index, string type_hint)
{
	// Check with type hint format first
	if (!type_hint.IsEmpty())
	{
		SIFormat* format = SIFormat::getFormat(type_hint);
		if (format != SIFormat::unknownFormat() && format->isThisFormat(data))
			return format->loadImage(*this, data, index);
	}

	// No type hint given or didn't match, autodetect format with SIFormat system instead
	return SIFormat::determineFormat(data)->loadImage(*this, data, index);
}
开发者ID:IjonTichy,项目名称:SLADE,代码行数:17,代码来源:SImage.cpp


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