Minor fixes on TString and CTextInStream

This commit is contained in:
parax0 2015-12-31 04:56:58 -07:00
parent efb21f629a
commit 1c80970a04
2 changed files with 13 additions and 3 deletions

View File

@ -229,7 +229,7 @@ public:
_TString Trimmed() const
{
int start, end;
int start = -1, end = -1;
for (u32 iChar = 0; iChar < Size(); iChar++)
{
@ -240,6 +240,9 @@ public:
}
}
// If start is still -1 then there are no non-whitespace characters in this string. Return early.
if (start == -1) return "";
for (int iChar = Size() - 1; iChar >= 0; iChar--)
{
if (!IsWhitespace(mInternalString[iChar]))
@ -259,11 +262,13 @@ public:
inline _TString ChopFront(u32 amount) const
{
if (Size() <= amount) return "";
return SubString(amount, Size() - amount);
}
inline _TString ChopBack(u32 amount) const
{
if (Size() <= amount) return "";
return SubString(0, Size() - amount);
}
@ -712,14 +717,14 @@ public:
}
// Static
static TBasicString<CharType> FromInt32(u32 value, int width = 0, int base = 16)
static TBasicString<CharType> FromInt32(s32 value, int width = 0, int base = 16)
{
std::basic_stringstream<CharType> sstream;
sstream << std::setbase(base) << std::setw(width) << std::setfill('0') << value;
return sstream.str();
}
static TBasicString<CharType> FromInt64(u64 value, int width = 0, int base = 16)
static TBasicString<CharType> FromInt64(s64 value, int width = 0, int base = 16)
{
std::basic_stringstream<CharType> sstream;
sstream << std::setbase(base) << std::setw(width) << std::setfill('0') << value;

View File

@ -2,6 +2,11 @@
#include <stdarg.h>
#include <stdio.h>
CTextInStream::CTextInStream()
{
mpFStream = nullptr;
}
CTextInStream::CTextInStream(const std::string& rkFile)
{
mpFStream = nullptr;