Revering stringutil (don't you hate it when ector is right?;)

And small compile fix on linux


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2434 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
nakeee 2009-02-25 13:31:13 +00:00
parent bec2a115d8
commit 4812f02b69
3 changed files with 35 additions and 31 deletions

View File

@ -200,25 +200,33 @@ std::string ArrayToString(const u8 *data, u32 size, u32 offset, int line_len, bo
// ================ // ================
// Turns " hej " into "hej". Also handles tabs and newlines. // Turns " hej " into "hej". Also handles tabs.
std::string StripSpaces(const std::string &str) std::string StripSpaces(const std::string &str)
{ {
std::string temp = str; std::string s = str;
int i;
for (i = 0; i < (int)s.size(); i++)
{
if ((s[i] != ' ') && (s[i] != 9))
{
break;
}
}
// Find first non space char s = s.substr(i);
u32 firstChar = str.find_first_not_of(" \t\n");
// Last char which is not whitespace for (i = (int)s.size() - 1; i > 0; i--)
u32 lastChar = str.find_last_not_of(" \t\n"); {
if ((s[i] != ' ') && (s[i] != 9))
{
break;
}
}
if (firstChar != std::string::npos) return s.substr(0, i + 1);
temp.resize(firstChar, lastChar);
else
temp = "";
return temp;
} }
// "\"hello\"" is turned to "hello" // "\"hello\"" is turned to "hello"
// This one assumes that the string has already been space stripped in both // This one assumes that the string has already been space stripped in both
// ends, as done by StripSpaces above, for example. // ends, as done by StripSpaces above, for example.
@ -230,6 +238,19 @@ std::string StripQuotes(const std::string& s)
return s; return s;
} }
// "\"hello\"" is turned to "hello"
// This one assumes that the string has already been space stripped in both
// ends, as done by StripSpaces above, for example.
std::string StripNewline(const std::string& s)
{
if (!s.size())
return s;
else if (s[s.size() - 1] == '\n')
return s.substr(0, s.size() - 1);
else
return s;
}
bool TryParseInt(const char* str, int* outVal) bool TryParseInt(const char* str, int* outVal)
{ {
const char* s = str; const char* s = str;
@ -440,21 +461,3 @@ std::string ThS(int Integer, bool Unsigned)
} }
// Remove trailing whitespaces from begining and end of string
std::string Trim(const std::string& str)
{
std::string temp = str;
// Find first non space char
u32 firstChar = str.find_first_not_of(" \t\n");
// Last char which is not whitespace
u32 lastChar = str.find_last_not_of(" \t\n");
if (firstChar != std::string::npos)
temp.resize(firstChar, lastChar);
else
temp = "";
return temp;
}

View File

@ -49,6 +49,7 @@ inline void CharArrayFromFormat(char (& out)[Count], const char* format, ...)
std::string StripSpaces(const std::string &s); std::string StripSpaces(const std::string &s);
std::string StripQuotes(const std::string &s); std::string StripQuotes(const std::string &s);
std::string StripNewline(const std::string &s);
std::string ThS(int a, bool b = true); // thousand separator std::string ThS(int a, bool b = true); // thousand separator

View File

@ -342,7 +342,7 @@ public:
u64 TitleID = Memory::Read_U64(Buffer.InBuffer[0].m_Address); u64 TitleID = Memory::Read_U64(Buffer.InBuffer[0].m_Address);
u32 Count = Memory::Read_U32(Buffer.InBuffer[1].m_Address); u32 Count = Memory::Read_U32(Buffer.InBuffer[1].m_Address);
_dbg_assert_msg_(WII_IPC_HLE, TitleID==0x0000000100000002, "IOCTL_ES_GETVIEWS: TitleID != 00000001/00000002"); _dbg_assert_msg_(WII_IPC_HLE, TitleID==0x0000000100000002ull, "IOCTL_ES_GETVIEWS: TitleID != 00000001/00000002");
/* write ticket data... hmmm /* write ticket data... hmmm
typedef struct _tikview { typedef struct _tikview {