String String::operator + (const String& rhs) const { String ret; ret.Resize(Length() + rhs.Length()); CopyChars(ret.Buffer(), Buffer(), Length()); CopyChars(ret.Buffer() + Length(), rhs.Buffer(), rhs.Length()); return ret; }
void WriteFormat(String const &str, T0 const &p0, T1 const &p1, T2 const &p2, T3 const &p3, T4 const &p4, T5 const &p5) { var s = str.Buffer(); var len = str.Length(); #define CS_P5 #include "../INC/ConsoleWFW.inc" #undef CS_P5 }
void WriteFormat(String const &str, T0 const &p0, T1 const &p1, T2 const &p2, T3 const &p3, T4 const &p4, T5 const &p5, T6 const &p6, T7 const &p7, T8 const &p8, T9 const &p9) { var s = str.Buffer(); var len = str.Length(); #define CS_P9 #include "../INC/ConsoleWFW.inc" #undef CS_P9 }
void WriteFormat(String const &str, T0 const &p0, T1 const &p1) { var s = str.Buffer(); var len = str.Length(); #define CS_P1 #include "../INC/ConsoleWFW.inc" #undef CS_P1 }
size_t String::Find(const String& str, size_t startPos, bool caseSensitive) const { if (!str.Length() || str.Length() > Length()) return NPOS; char first = str.Buffer()[0]; if (!caseSensitive) first = Turso3D::ToLower(first); for (size_t i = startPos; i <= Length() - str.Length(); ++i) { char c = Buffer()[i]; if (!caseSensitive) c = Turso3D::ToLower(c); if (c == first) { size_t skip = NPOS; bool found = true; for (size_t j = 1; j < str.Length(); ++j) { c = Buffer()[i + j]; char d = str.Buffer()[j]; if (!caseSensitive) { c = Turso3D::ToLower(c); d = Turso3D::ToLower(d); } if (skip == NPOS && c == first) skip = i + j - 1; if (c != d) { found = false; if (skip != NPOS) i = skip; break; } } if (found) return i; } } return NPOS; }
bool Path::CreateDir(const String & path) { #if defined(_WIN32) return _wmkdir(path.ToWString()) == 0; #else return mkdir(path.Buffer(), 0777) == 0; #endif }
void String::Replace(size_t pos, size_t numChars, const String& replaceWith) { // If substring is illegal, do nothing if (pos + numChars > Length()) return; Replace(pos, numChars, replaceWith.Buffer(), replaceWith.Length()); }
String String::operator + (const char* rhs) const { size_t rhsLength = CStringLength(rhs); String ret; ret.Resize(Length() + rhsLength); CopyChars(ret.Buffer(), Buffer(), Length()); CopyChars(ret.Buffer() + Length(), rhs, rhsLength); return ret; }
size_t String::FindLast(const String& str, size_t startPos, bool caseSensitive) const { if (!str.Length() || str.Length() > Length()) return NPOS; if (startPos > Length() - str.Length()) startPos = Length() - str.Length(); char first = str.Buffer()[0]; if (!caseSensitive) first = Turso3D::ToLower(first); for (size_t i = startPos; i < Length(); --i) { char c = Buffer()[i]; if (!caseSensitive) c = Turso3D::ToLower(c); if (c == first) { bool found = true; for (size_t j = 1; j < str.Length(); ++j) { c = Buffer()[i + j]; char d = str.Buffer()[j]; if (!caseSensitive) { c = Turso3D::ToLower(c); d = Turso3D::ToLower(d); } if (c != d) { found = false; break; } } if (found) return i; } } return NPOS; }
bool File::Exists(const String & fileName) { #ifdef _WIN32 struct _stat32 statVar; return ::_wstat32(((String)fileName).ToWString(), &statVar) != -1; #else struct stat statVar; return ::stat(fileName.Buffer(), &statVar) == 0; #endif }
String Path::ReplaceExt(const String & path, const char * newExt) { StringBuilder sb(path.Length()+10); int dotPos = path.LastIndexOf('.'); if (dotPos == -1) dotPos = path.Length(); sb.Append(path.Buffer(), dotPos); sb.Append('.'); sb.Append(newExt); return sb.ProduceString(); }
String String::Substring(size_t pos) const { if (pos < Length()) { String ret; ret.Resize(Length() - pos); CopyChars(ret.Buffer(), Buffer() + pos, ret.Length()); return ret; } else return String(); }
String String::Substring(size_t pos, size_t numChars) const { if (pos < Length()) { String ret; if (pos + numChars > Length()) numChars = Length() - pos; ret.Resize(numChars); CopyChars(ret.Buffer(), Buffer() + pos, ret.Length()); return ret; } else return String(); }
void BaseForm::SetText(String text) { SetWindowTextW(handle, text.Buffer()); }
int BaseForm::MessageBox(const String & msg, const String & title, unsigned int style) { return ::MessageBoxW(handle, msg.Buffer(), title.Buffer(), style); }
HFONT FontsMgr::GetFont(String& _fontId) { CHECK_ERROR(_fontId.Length(), L""); return (*fontsMap_)[_fontId.Buffer()]->GetFont(); }
INLINE void Write(String const &s) { Write(s.Buffer(), s.Length()); }