more explicit calls

This commit is contained in:
Markus Gans 2015-05-28 22:48:15 +02:00
parent 7789ee4fba
commit 5ee7d1cf56
2 changed files with 80 additions and 16 deletions

View File

@ -646,7 +646,7 @@ const FString& FString::operator += (const char c)
//----------------------------------------------------------------------
const FString FString::operator + (const FString& s)
{
FString tmp = string;
FString tmp(string);
tmp._insert (length, s.length, s.string);
return (tmp);
}
@ -654,7 +654,7 @@ const FString FString::operator + (const FString& s)
//----------------------------------------------------------------------
const FString FString::operator + (const std::wstring& s)
{
FString tmp = string;
FString tmp(string);
tmp._insert (length, uInt(s.length()), s.c_str());
return (tmp);
}
@ -662,7 +662,7 @@ const FString FString::operator + (const std::wstring& s)
//----------------------------------------------------------------------
const FString FString::operator + (const wchar_t* s)
{
FString tmp = string;
FString tmp(string);
tmp._insert (length, uInt(wcslen(s)), s);
return (tmp);
}
@ -670,7 +670,7 @@ const FString FString::operator + (const wchar_t* s)
//----------------------------------------------------------------------
const FString FString::operator + (const std::string& s)
{
FString tmp = string;
FString tmp(string);
wchar_t* wc_str = c_to_wc_str(s.c_str());
if ( ! wc_str )
return (tmp);
@ -683,7 +683,7 @@ const FString FString::operator + (const std::string& s)
//----------------------------------------------------------------------
const FString FString::operator + (const char* s)
{
FString tmp = string;
FString tmp(string);
wchar_t* wc_str = c_to_wc_str(s);
if ( ! wc_str )
return (tmp);
@ -696,7 +696,7 @@ const FString FString::operator + (const char* s)
//----------------------------------------------------------------------
const FString FString::operator + (const wchar_t c)
{
FString tmp = string;
FString tmp(string);
tmp._insert (length, 1, &c);
return(tmp);
}
@ -705,7 +705,7 @@ const FString FString::operator + (const wchar_t c)
const FString FString::operator + (const char c)
{
const wchar_t wc = static_cast<wchar_t>(c);
FString tmp = string;
FString tmp(string);
tmp._insert (length, 1, &wc);
return(tmp);
}
@ -713,7 +713,7 @@ const FString FString::operator + (const char c)
//----------------------------------------------------------------------
const FString operator + (const FString& s1, const FString& s2)
{
FString tmp = s1;
FString tmp(s1);
tmp._insert ( uInt(wcslen(s1.wc_str())),
uInt(wcslen(s2.wc_str())),
s2.wc_str() );
@ -723,7 +723,7 @@ const FString operator + (const FString& s1, const FString& s2)
//----------------------------------------------------------------------
const FString operator + (const std::wstring& s1, const FString& s2)
{
FString tmp = s1;
FString tmp(s1);
tmp._insert ( uInt(wcslen(s1.c_str())),
uInt(wcslen(s2.wc_str())),
s2.wc_str() );
@ -733,7 +733,7 @@ const FString operator + (const std::wstring& s1, const FString& s2)
//----------------------------------------------------------------------
const FString operator + (const wchar_t* s1, const FString& s2)
{
FString tmp = s1;
FString tmp(s1);
tmp._insert ( uInt(wcslen(s1)),
uInt(wcslen(s2.wc_str())),
s2.wc_str() );
@ -743,7 +743,7 @@ const FString operator + (const wchar_t* s1, const FString& s2)
//----------------------------------------------------------------------
const FString operator + (const std::string& s1, const FString& s2)
{
FString tmp = s1;
FString tmp(s1);
tmp._insert ( tmp.getLength(),
uInt(wcslen(s2.wc_str())),
s2.wc_str() );
@ -789,7 +789,7 @@ wchar_t& FString::operator [] (uInt pos)
const FString FString::operator () (uInt pos, uInt len)
{
assert ( (pos < length) && ((pos+len) <= length) );
FString tmp = L"";
FString tmp(L"");
tmp._insert (0, len, string + pos);
return (tmp);
}
@ -1135,7 +1135,7 @@ std::vector<FString> FString::split (const FString& delimiter)
while ( token )
{
stringList.push_back(token);
stringList.push_back (FString(token));
token = extractToken (&rest, 0, delimiter.wc_str());
}
return stringList;
@ -1379,6 +1379,18 @@ const FString& FString::insert (const char* s, uInt pos)
return (insert(FString(s), pos));
}
//----------------------------------------------------------------------
const FString& FString::insert (const wchar_t c, uInt pos)
{
return (insert(FString(c), pos));
}
//----------------------------------------------------------------------
const FString& FString::insert (const char c, uInt pos)
{
return (insert(FString(c), pos));
}
//----------------------------------------------------------------------
FString FString::replace (const FString& from, const FString& to)
{
@ -1983,3 +1995,21 @@ bool FString::includes (const char* s)
delete[] wc_str;
return (ret);
}
//----------------------------------------------------------------------
bool FString::includes (const wchar_t c)
{
wchar_t s[2];
s[0] = c;
s[1] = L'\0';
return (wcsstr(string, s) != 0);
}
//----------------------------------------------------------------------
bool FString::includes (const char c)
{
wchar_t s[2];
s[0] = wchar_t(c & 0xff);
s[1] = L'\0';
return (wcsstr(string, s) != 0);
}

View File

@ -83,7 +83,7 @@ class FString
FString (const std::string&); // constructor
FString (const char*); // constructor
FString (const wchar_t); // constructor
explicit FString (const char); // constructor
FString (const char); // constructor
virtual ~FString (); // destructor
bool isNull() const;
@ -129,6 +129,12 @@ class FString
FString mid(uInt, uInt) const;
std::vector<FString> split (const FString&);
std::vector<FString> split (std::wstring&);
std::vector<FString> split (const wchar_t*);
std::vector<FString> split (const std::string&);
std::vector<FString> split (const char*);
std::vector<FString> split (const wchar_t);
std::vector<FString> split (const char);
FString& setString (const wchar_t*);
FString& setString (const char*);
@ -199,6 +205,8 @@ class FString
const FString& insert (const FString&, uInt);
const FString& insert (const wchar_t*, uInt);
const FString& insert (const char*, uInt);
const FString& insert (const wchar_t, uInt);
const FString& insert (const char, uInt);
FString replace (const FString&, const FString&);
FString replace (const FString&, const std::wstring&);
@ -263,6 +271,8 @@ class FString
bool includes (const FString&);
bool includes (const wchar_t*);
bool includes (const char*);
bool includes (const wchar_t);
bool includes (const char);
};
@ -317,6 +327,30 @@ inline int FString::toInt() const
inline uInt FString::toUInt() const
{ return uInt( toULong() ); }
//----------------------------------------------------------------------
inline std::vector<FString> FString::split (std::wstring& s)
{ return split(FString(s)); }
//----------------------------------------------------------------------
inline std::vector<FString> FString::split (const wchar_t* s)
{ return split(FString(s)); }
//----------------------------------------------------------------------
inline std::vector<FString> FString::split (const std::string& s)
{ return split(FString(s)); }
//----------------------------------------------------------------------
inline std::vector<FString> FString::split (const char* s)
{ return split(FString(s)); }
//----------------------------------------------------------------------
inline std::vector<FString> FString::split (const wchar_t c)
{ return split(FString(c)); }
//----------------------------------------------------------------------
inline std::vector<FString> FString::split (const char c)
{ return split(FString(c)); }
//----------------------------------------------------------------------
inline FString& FString::setNumber (sInt16 num)
{ return setNumber (long(num)); }