Example #1
0
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;
}
Example #2
0
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
}
Example #3
0
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
}
Example #4
0
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
}
Example #5
0
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;
}
Example #6
0
		bool Path::CreateDir(const String & path)
		{
#if defined(_WIN32)
			return _wmkdir(path.ToWString()) == 0;
#else 
			return mkdir(path.Buffer(), 0777) == 0;
#endif
		}
Example #7
0
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());
}
Example #8
0
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;
}
Example #9
0
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;
}
Example #10
0
		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
		}
Example #11
0
		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();
		}
Example #12
0
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();
}
Example #13
0
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();
}
Example #14
0
		void BaseForm::SetText(String text)
		{
			SetWindowTextW(handle, text.Buffer());
		}
Example #15
0
		int BaseForm::MessageBox(const String & msg, const String & title, unsigned int style)
		{
			return ::MessageBoxW(handle, msg.Buffer(), title.Buffer(), style);
		}
Example #16
0
	HFONT FontsMgr::GetFont(String& _fontId)
	{
		CHECK_ERROR(_fontId.Length(), L"");

		return (*fontsMap_)[_fontId.Buffer()]->GetFont();
	}
Example #17
0
INLINE void Write(String  const &s) {
    Write(s.Buffer(), s.Length());
}