Added Insert and Find functions to sf::String

Added implicit constructors to sf::String for converting from single characters (char, wchar_t and Uint32)

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1429 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
LaurentGom 2010-02-26 09:36:38 +00:00
parent 6f6481ef38
commit bb414773d1
3 changed files with 131 additions and 117 deletions

View file

@ -40,6 +40,7 @@ namespace sf
////////////////////////////////////////////////////////////
const Image Shader::CurrentTexture;
////////////////////////////////////////////////////////////
Shader::Shader() :
myShaderProgram (0),

View file

@ -33,12 +33,46 @@
namespace sf
{
////////////////////////////////////////////////////////////
// Static member data
////////////////////////////////////////////////////////////
const std::size_t String::InvalidPos = std::basic_string<Uint32>::npos;
////////////////////////////////////////////////////////////
String::String()
{
}
////////////////////////////////////////////////////////////
String::String(char ansiChar)
{
myString += Utf32::DecodeAnsi(ansiChar);
}
////////////////////////////////////////////////////////////
String::String(char ansiChar, const std::locale& locale)
{
myString += Utf32::DecodeAnsi(ansiChar, locale);
}
////////////////////////////////////////////////////////////
String::String(wchar_t wideChar)
{
myString += Utf32::DecodeWide(wideChar);
}
////////////////////////////////////////////////////////////
String::String(Uint32 utf32Char)
{
myString += utf32Char;
}
////////////////////////////////////////////////////////////
String::String(const char* ansiString)
{
@ -194,30 +228,6 @@ String& String::operator =(const String& right)
}
////////////////////////////////////////////////////////////
String& String::operator +=(char right)
{
myString += Utf32::DecodeAnsi(right);
return *this;
}
////////////////////////////////////////////////////////////
String& String::operator +=(wchar_t right)
{
myString += Utf32::DecodeWide(right);
return *this;
}
////////////////////////////////////////////////////////////
String& String::operator +=(Uint32 right)
{
myString += right;
return *this;
}
////////////////////////////////////////////////////////////
String& String::operator +=(const String& right)
{
@ -268,6 +278,20 @@ void String::Erase(std::size_t position, std::size_t count)
}
////////////////////////////////////////////////////////////
void String::Insert(std::size_t position, const String& str)
{
myString.insert(position, str.myString);
}
////////////////////////////////////////////////////////////
std::size_t String::Find(const String& str, std::size_t start) const
{
return myString.find(str.myString, start);
}
////////////////////////////////////////////////////////////
const Uint32* String::GetData() const
{
@ -345,36 +369,6 @@ bool operator >=(const String& left, const String& right)
}
////////////////////////////////////////////////////////////
String operator +(const String& left, char right)
{
String string = left;
string += right;
return string;
}
////////////////////////////////////////////////////////////
String operator +(const String& left, wchar_t right)
{
String string = left;
string += right;
return string;
}
////////////////////////////////////////////////////////////
String operator +(const String& left, Uint32 right)
{
String string = left;
string += right;
return string;
}
////////////////////////////////////////////////////////////
String operator +(const String& left, const String& right)
{