示例#1
0
/**
	@param sFolder Folder to combine
	@param sPathname Path to combine (probably relative to sFolder)
	@param bAllowAbsoluteOverride true to allow sPathname to have an absolute path, false to make sure it's relative
	@return The combined path
*/
std::tstring ConcatPaths(const std::tstring& sFolder, const std::tstring& sPathname, bool bAllowAbsoluteOverride /* = true */)
{
	// Do we have a folder?
	if (sFolder.empty())
		// No, return the second part alone
		return sPathname;
	// Do we have a path?
	if (sPathname.empty())
		// No, return the first part alone
		return sFolder;

	// Allow overriding paths by using a drive letter and colon (c:) or a UNC path (\\)
	if (bAllowAbsoluteOverride)
		if ((sPathname.size() > 2) && (sPathname[1] == ':') || ((sPathname[0] == '\\') && (sPathname[1] == '\\')))
			return sPathname;

	std::tstring sRet = sFolder;

	// Make sure we have a slash at the end of the folder part
	CHAR c = sFolder[sFolder.size()-1];
	if ((c != '\\') && (c != '/'))
		sRet += _T("\\");

	// Make sure we don't have a slash at the beginning of the path part:
	c = sPathname[0];
	if ((c == '\\') || (c == '/'))
		// We do, jump over it
		sRet += sPathname.substr(1);
	else
		// Just add them
		sRet += sPathname;

	return sRet;
}
示例#2
0
void SpriteFont::DrawText(const std::tstring& text, tt::Vector2 position, const tt::Vector4& color)
{
	if(m_NrOfCharsToDraw += text.size() > sc_MaxNrOfChars)
		throw exception();

	MyServiceLocator::GetInstance()->GetService<IGraphicsService>()->GetSpriteBatch()->AddSpriteFont(this);
	
	m_TextQueue.push_back(TextData(text, position, color));
}
示例#3
0
BOOL CDevCProbe::SetDeviceName( PDeviceDescriptor_t d, const std::tstring& strName ){
	if (d && d->Com && strName.size() <= 15) {
		d->Com->WriteString(TEXT("$PCPILOT,C,SET,"));
		d->Com->WriteString(strName.c_str());
		d->Com->WriteString(TEXT("\r\n"));
		return GetDeviceName(d);
	}
	return FALSE;
}
示例#4
0
void utils::text::treplace_all(std::tstring* data, const std::tstring &from, const std::tstring &to)
{
	std::tstring::size_type position = 0;

	while ((position = data->find(from, position)) != std::tstring::npos)
	{
		data->replace(position, from.size(), to);
		position++;
	}
}