Updating
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <common/string.hpp>
|
||||
#include <common/block.hpp>
|
||||
#include <common/macro.hpp>
|
||||
#include <common/array.hpp>
|
||||
|
||||
String::String(const char *npStr)
|
||||
: mnpStr(0), mLengthBytes(0)
|
||||
@@ -16,7 +17,8 @@ String::String(const char *npStr)
|
||||
except(0,EXCEPTION_EXECUTE_HANDLER){stringLength=0;}
|
||||
#else
|
||||
__try{stringLength=::strlen(npStr);}
|
||||
__except(0,EXCEPTION_EXECUTE_HANDLER){stringLength=0;}
|
||||
// __except(0,EXCEPTION_EXECUTE_HANDLER){stringLength=0;}
|
||||
__except (EXCEPTION_EXECUTE_HANDLER) { stringLength = 0; }
|
||||
#endif
|
||||
if(!stringLength)return;
|
||||
stringLength++;
|
||||
@@ -232,6 +234,23 @@ String String::betweenString(char beginToken,char endToken)const
|
||||
return String(nullString);
|
||||
}
|
||||
|
||||
Block<String> String::split(char delimeter)const
|
||||
{
|
||||
Block<String> stringList = Block<String>();
|
||||
String strDelimeter = String(delimeter);
|
||||
String runningString = String(*this);
|
||||
|
||||
int position = runningString.strpos(strDelimeter);
|
||||
while (-1 != position)
|
||||
{
|
||||
stringList.insert(new String(runningString.substr(0, position - 1)));
|
||||
runningString = runningString.substr(position + 1);
|
||||
position = runningString.strpos(strDelimeter);
|
||||
}
|
||||
if (runningString.length())stringList.insert(new String(runningString));
|
||||
return stringList;
|
||||
}
|
||||
|
||||
WORD String::makeBlock(Block<String> &receiveStrings,const String &tokenString)const
|
||||
{
|
||||
String stringData(*this);
|
||||
@@ -383,7 +402,8 @@ String &String::trimLeft(void)
|
||||
size_t strLen;
|
||||
|
||||
if(isNull()||(0==(strLen=length())))return *this;
|
||||
for(short index=0;index<strLen;index++)if(Blank!=*(mnpStr+index))break;
|
||||
short index=0;
|
||||
for(index=0;index<strLen;index++)if(Blank!=*(mnpStr+index))break;
|
||||
if(!index)return *this;
|
||||
*this=substr(index);
|
||||
return *this;
|
||||
@@ -409,7 +429,8 @@ void String::replaceToken(BYTE tokenFind,BYTE tokenReplace)
|
||||
String tempString;
|
||||
|
||||
if(!length)return;
|
||||
for(int pos=0;pos<length;pos++)if(*(mnpStr+pos)==tokenFind)*(mnpStr+pos)=tokenReplace;
|
||||
int pos=0;
|
||||
for(pos=0;pos<length;pos++)if(*(mnpStr+pos)==tokenFind)*(mnpStr+pos)=tokenReplace;
|
||||
for(pos=0;pos<length;pos++){if((mnpStr+pos))tempString+=*(mnpStr+pos);}
|
||||
*this=tempString;
|
||||
}
|
||||
@@ -571,7 +592,7 @@ short String::toShort(void)const
|
||||
|
||||
unsigned short String::toUShort(void)const
|
||||
{
|
||||
if(isNull())return 0;
|
||||
if (isNull())return 0;
|
||||
return unsigned short(::atoi(str()));
|
||||
}
|
||||
|
||||
@@ -643,6 +664,7 @@ String &String::fromBool(bool boolValue)
|
||||
|
||||
// non-member
|
||||
|
||||
|
||||
istream &operator>>(istream &stream,String &someString)
|
||||
{
|
||||
char charData;
|
||||
@@ -666,6 +688,8 @@ ostream &operator<<(ostream &stream,const String &someString)
|
||||
return stream<<(char*)((String&)someString);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String operator+(const char *str,const String &string)
|
||||
{
|
||||
return String(str)+string;
|
||||
|
||||
Reference in New Issue
Block a user