コード例 #1
0
ファイル: string.cpp プロジェクト: reasoning/reason
String & String::Insert(float f, int index)
{
	String string;
	string.Allocate(64);
	string.Format("%g",f);
	return Insert(string,index);
}
コード例 #2
0
String String::Erase(const int pos, int len)
{
    int str_len = Size();
    int len_a = pos;

    // If erase after the length of the string, return.
    if (len_a >= str_len)
        return *this;

    // Prevent erasing after the end of the string.
    if ((len_a + len) > str_len) {
        // Resize the erase length.
        len = str_len - len_a;
    }

    String s;
    int len_b = str_len - len_a - len;
    s.Allocate(len_a + len_b + 1);

    Copy(&s.v[0], &v[0], len_a);
    if (len_b > 0) {
        int offset_b = len_a + len;
        Concatenate(&s.v[0], &v[0 + offset_b]);
    }
    s.v[s.Size()] = 0;
    v = s.v;
    return *this;
}
コード例 #3
0
ファイル: string.cpp プロジェクト: reasoning/reason
String & String::Insert(double d, int index)
{
	String string;
	string.Allocate(512);
	string.Format("%f",d);
	return Insert(string,index);
}
コード例 #4
0
ファイル: string.cpp プロジェクト: reasoning/reason
String & String::Insert(long long ll, int index)
{
	String string;
	string.Allocate(32);
	string.Format("%d",ll);
	return Insert(string,index);
}
コード例 #5
0
ファイル: string.cpp プロジェクト: reasoning/reason
String & String::Construct(float f)
{
	String string;
	string.Allocate(64);
	string.Format("%g",f);
	return Construct(string);

}
コード例 #6
0
ファイル: string.cpp プロジェクト: reasoning/reason
String & String::Replace(double d)
{
	String string;
	string.Allocate(512);
	string.Format("%f",d);
	return Replace(string);

}
コード例 #7
0
ファイル: string.cpp プロジェクト: reasoning/reason
String & String::Prepend(double d)
{
	String string;
	string.Allocate(512);
	string.Format("%f",d);
	return Prepend(string);

}
コード例 #8
0
ファイル: string.cpp プロジェクト: reasoning/reason
String & String::Prepend(float f)
{
	String string;
	string.Allocate(64);
	string.Format("%g",f);
	return Prepend(string);

}
コード例 #9
0
ファイル: string.cpp プロジェクト: reasoning/reason
String & String::Replace(float f)
{
	String string;
	string.Allocate(64);
	string.Format("%g",f);
	return Replace(string);

}
コード例 #10
0
ファイル: string.cpp プロジェクト: reasoning/reason
String & String::Replace(long long ll)
{
	String string;
	string.Allocate(32);
	string.Format("%d",ll);
	return Replace(string);

}
コード例 #11
0
ファイル: String.cpp プロジェクト: kbinani/dxrip
String String::UnsignedIntAsHex(UINT Value)
{
    String S;
    S.Allocate(20);
    sprintf(S.CString(), "%x", Value);
    S.ResizeToCStringLength();
    return S;
}
コード例 #12
0
ファイル: string.cpp プロジェクト: reasoning/reason
String & String::Replace(int i)
{
	String string;
	string.Allocate(32);
	string.Format("%d",i);
	return Replace(string);

}
コード例 #13
0
ファイル: string.cpp プロジェクト: reasoning/reason
String & String::Construct(double d)
{
	String string;
	string.Allocate(512);
	string.Format("%f",d);
	return Construct(string);

}
コード例 #14
0
ファイル: string.cpp プロジェクト: reasoning/reason
String & String::Construct(long long ll)
{
	String string;
	string.Allocate(32);
	string.Format("%lld",ll);
	return Construct(string);

}
コード例 #15
0
ファイル: string.cpp プロジェクト: reasoning/reason
String & String::Prepend(long long ll)
{

	String string;
	string.Allocate(32);
	string.Format("%d",ll);
	return Prepend(string);

}
コード例 #16
0
String String::Erase(const int pos)
{
    String s;
    s.Allocate(pos + 1);
    Copy(&s.v[0], &v[0], pos);
    s.v[s.Size()] = 0;
    v = s.v;
    return *this;
}
コード例 #17
0
ファイル: String.cpp プロジェクト: odanek/saf
		String String::ToLower() const
		{
			String result;			
			if (HasChars())
			{
				result.Allocate(Length());
				Algo::Range::Transform(Begin(), End(), result.MutableBegin(), Algo::Function::FunctorFromMemberRef(&Char::ToLower));
			}

			return result;
		}
コード例 #18
0
ファイル: String.cpp プロジェクト: odanek/saf
		String String::Pad(const Char& ch, Size left, Size right) const
		{
			String result;
			if (Length() + left + right > 0)
			{
				result.Allocate(Length() + left + right);
				Iterator dest = result.MutableBegin();
				dest = Algo::Range::FillFirst(dest, left, ch);
				dest = Algo::Range::Copy(Begin(), End(), dest);
				Algo::Range::Fill(dest, result.MutableEnd(), ch);
			}

			return result;
		}
コード例 #19
0
ファイル: String.cpp プロジェクト: odanek/saf
		String String::Concat(const String& str) const
		{
			String result;

			if (HasChars() || str.HasChars())
			{
				result.Allocate(Length() + str.Length());
				
				Iterator dest = Algo::Range::Copy(Begin(), End(), result.MutableBegin());
				Algo::Range::Copy(str.Begin(), str.End(), dest);
			}

			return result;
		}
コード例 #20
0
ファイル: String.cpp プロジェクト: konlil/kexe
//string operations
String operator + (const String& l, const String& r)
{
	String result;
	const UINT length = l._Length + r._Length;
	result.Allocate(length + 1);
	result._Length = length;
	result._Data[length] = '\0';
	if(l._Length > 0)
		memcpy( result._Data, l._Data, l._Length);

	if(r._Length > 0)
		memcpy( result._Data + l._Length, r._Data, r._Length);

	return result;
}
コード例 #21
0
ファイル: String.cpp プロジェクト: kbinani/dxrip
String operator + (const String &L, const String &R)
{
    String Result;
    const UINT TotalLength = L._Length + R._Length;
    Result.Allocate(TotalLength + 1);
    Result._Length = TotalLength;
    Result._Data[TotalLength] = '\0';
    if(L._Length > 0)
    {
        memcpy(Result._Data, L._Data, L._Length);
    }
    if(R._Length > 0)
    {
        memcpy(Result._Data + L._Length, R._Data, R._Length);
    }
    return Result;
}
コード例 #22
0
ファイル: String.cpp プロジェクト: kbinani/dxrip
String String::ByteStreamToHexString(const BYTE *stream, UINT count)
{
    static const char table[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
    String result;
    result.Allocate(count * 2 + 1);
    result._Length = count * 2;
    char *resultData = result._Data;
    UINT stringIndex = 0;
    for(UINT byteIndex = 0; byteIndex < count; byteIndex++)
    {
        const BYTE curByte = stream[byteIndex];
        resultData[stringIndex++] = table[ curByte       & 0x0F];
        resultData[stringIndex++] = table[(curByte >> 4) & 0x0F];
    }
    resultData[stringIndex++] = '\0';
    return result;
}
コード例 #23
0
ファイル: String.cpp プロジェクト: odanek/saf
		String String::Reverse() const
		{
			if (Length() < 2)
			{
				return String(*this);
			}

			String result;
			result.Allocate(Length());

			Iterator dest = result.MutableEnd();
			for (ConstIterator src = Begin(); src != End(); ++src)
			{
				--dest;
				*dest = *src;
			}

			return result;
		}