Subversion Repositories spk

Rev

Rev 196 | Rev 285 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 196 Rev 284
Line 204... Line 204...
204
	return atoi(this->c_str()) ? true : false;
204
	return atoi(this->c_str()) ? true : false;
205
}
205
}
206
long SString::toLong() const
206
long SString::toLong() const
207
{
207
{
208
	return static_cast<long>(atoi(this->c_str()));
208
	return static_cast<long>(atoi(this->c_str()));
-
 
209
}
-
 
210
long long SString::toLong64() const
-
 
211
{
-
 
212
	return static_cast<long long>(atoll(this->c_str()));
209
}
213
}
210
int SString::toInt() const
214
int SString::toInt() const
211
{
215
{
212
	return static_cast<int>(atoi(this->c_str()));
216
	return static_cast<int>(atoi(this->c_str()));
213
}
217
}
Line 216... Line 220...
216
	return atof(this->c_str());
220
	return atof(this->c_str());
217
}
221
}
218
float SString::toFloat() const
222
float SString::toFloat() const
219
{
223
{
220
	return (float)atof(this->c_str());
224
	return (float)atof(this->c_str());
221
}
225
}
222

226

223
const Utils::WString SString::toWString() const 
227
const Utils::WString SString::toWString() const 
224
{ 
228
{ 
225
	return s2ws(*this); 
229
	return s2ws(*this); 
226
}
230
}
227

231

-
 
232
const long long SString::lengthLL() const
-
 
233
{
-
 
234
	return static_cast<long long>(this->length());
-
 
235
}
228

236

229
const SString &SString::operator= ( const char *str )				{ this->assign(str); return (*this); }
237
const SString &SString::operator= ( const char *str )				{ this->assign(str); return (*this); }
230
const SString &SString::operator= ( const unsigned char *str )		{ this->assign((const char *)str); return (*this); }
238
const SString &SString::operator= ( const unsigned char *str )		{ this->assign((const char *)str); return (*this); }
231
const SString &SString::operator= ( const SString &str )			{ this->assign((std::string &)str); return (*this); }
239
const SString &SString::operator= ( const SString &str )			{ this->assign((std::string &)str); return (*this); }
232
const SString &SString::operator= ( const std::string &str )		{ this->assign(str); return (*this); }
240
const SString &SString::operator= ( const std::string &str )		{ this->assign(str); return (*this); }
Line 235... Line 243...
235
const SString &SString::operator= ( long l )						{ this->fromLong(l); return (*this); }
243
const SString &SString::operator= ( long l )						{ this->fromLong(l); return (*this); }
236
const SString &SString::operator= ( unsigned long l )				{ this->fromLong(l); return (*this); }
244
const SString &SString::operator= ( unsigned long l )				{ this->fromLong(l); return (*this); }
237
const SString &SString::operator= ( float f )						{ this->fromFloat(f); return (*this); }
245
const SString &SString::operator= ( float f )						{ this->fromFloat(f); return (*this); }
238
const SString &SString::operator= ( double f )						{ this->fromDouble(f); return (*this); }
246
const SString &SString::operator= ( double f )						{ this->fromDouble(f); return (*this); }
239

247

240
const unsigned char SString::operator[] ( int num ) const			{ return this->at(num); }
248
const unsigned char SString::operator[] (size_t num ) const			{ return this->at(num); }
241
unsigned char &SString::operator[] ( int num )						{ return (unsigned char &)this->at(num); }
249
unsigned char &SString::operator[] (size_t num )						{ return (unsigned char &)this->at(num); }
242

250

243
const SString &SString::operator+= ( const char *str )				{ this->append(str); return (*this); }
251
const SString &SString::operator+= ( const char *str )				{ this->append(str); return (*this); }
244
const SString &SString::operator+= ( const unsigned char *str ) 	{ this->append((const char *)str); return (*this); }
252
const SString &SString::operator+= ( const unsigned char *str ) 	{ this->append((const char *)str); return (*this); }
245
const SString &SString::operator+= ( const std::string &str )		{ this->append(str); return (*this); }
253
const SString &SString::operator+= ( const std::string &str )		{ this->append(str); return (*this); }
246
const SString &SString::operator+= ( const SString &str )			{ this->append(str); return (*this); }
254
const SString &SString::operator+= ( const SString &str )			{ this->append(str); return (*this); }
Line 389... Line 397...
389
		// skip past token
397
		// skip past token
390
		size_t i = 0;
398
		size_t i = 0;
391
		size_t max = strlen(token);
399
		size_t max = strlen(token);
392
		lastPos = pos;
400
		lastPos = pos;
393
		while ( (i < max) && (token[i] == this->at(lastPos)) )
401
		while ( (i < max) && (token[i] == this->at(lastPos)) )
394
		{
402
		{
395
			++i;
403
			++i;
396
			++lastPos;
404
			++lastPos;
397
		}
405
		}
398
406
399
		// get the next token
407
		// get the next token
400
		pos = _token_nextPos(token, lastPos);
408
		pos = _token_nextPos(token, lastPos);
401
	}
409
	}
402
	return newstr;
410
	return newstr;
403
}
411
}
404

412

405
SString SString::remToken(const char* token, int from) const
413
SString SString::remToken(const char* token, int from) const
406
{
414
{
Line 585... Line 593...
585
	Utils::SString newstr = *this;
593
	Utils::SString newstr = *this;
586
	Utils::SString::size_type pos = newstr.find(find, 0);
594
	Utils::SString::size_type pos = newstr.find(find, 0);
587
	while ( pos < Utils::SString::npos ) {
595
	while ( pos < Utils::SString::npos ) {
588
		newstr.replace(pos, find.length(), replace);
596
		newstr.replace(pos, find.length(), replace);
589
		pos = newstr.find(find, pos + replace.length());
597
		pos = newstr.find(find, pos + replace.length());
590
	}
598
	}
591

599

592
	return newstr;
600
	return newstr;
593
}
601
}
594

602

595
SString SString::findRemove(const SString &find) const
603
SString SString::findRemove(const SString &find) const
Line 669... Line 677...
669
bool SString::isin(const SString &str, bool bCaseSensative) const
677
bool SString::isin(const SString &str, bool bCaseSensative) const
670
{
678
{
671
	return contains(str, bCaseSensative);
679
	return contains(str, bCaseSensative);
672
}
680
}
673

681

674
int SString::findPos(const SString &find, int iStartPos) const
682
long long SString::findPos(const SString &find, size_t iStartPos) const
675
{
683
{
676
	Utils::SString::size_type pos = this->find(find, iStartPos);
684
	Utils::SString::size_type pos = this->find(find, iStartPos);
677
	if ( pos == Utils::SString::npos ) return -1;
685
	if ( pos == Utils::SString::npos ) return -1;
678
	return pos;
686
	return static_cast<long long>(pos);
679
}
687
}
680

688

681
bool SString::isin(char c, bool bCaseSensative) const
689
bool SString::isin(char c, bool bCaseSensative) const
682
{
690
{
683
	return contains(c, bCaseSensative);
691
	return contains(c, bCaseSensative);
Line 696... Line 704...
696
	return f;
704
	return f;
697
}
705
}
698

706

699
SString SString::between(const SString &before, const SString &after) const
707
SString SString::between(const SString &before, const SString &after) const
700
{
708
{
701
	int pos = this->findPos(before);
709
	long long lPos = this->findPos(before);
702
	if ( pos >= 0 ) {
710
	if (lPos >= 0)
-
 
711
	{
-
 
712
		size_t pos = static_cast<size_t>(lPos);
703
		pos += before.length();
713
		pos += before.length();
704
		int end = this->findPos(after, pos);
714
		long long end = this->findPos(after, pos);
705
		if ( end >= 0 )	return this->substr(pos, end - pos);
715
		if ( end >= 0 )	return this->substr(pos, static_cast<size_t>(end) - pos);
706
	}
716
	}
707
717
708
	return "";
718
	return "";
709
}
719
}
710
720
711
SString SString::mid(int start, int end) const
721
SString SString::mid(long long start, long long end) const
712
{
722
{
713
	if (end <= 0)
723
	if (end <= 0)
714
		end = this->length() + end;
724
		end = this->length() + end;
715
	return this->substr(start, end - start);
725
	return this->substr(start, end - start);
716
}
726
}
717
SString SString::left(long num) const
727
SString SString::left(long long num) const
718
{
728
{
-
 
729
	const long long len = this->lengthLL();
719
	if ( num < 0 )
730
	if ( num < 0 )
720
		num = (long)this->length() + num;
731
		num = len + num;
721
	if ( num > (long)this->length() )
732
	if ( num > len )
722
		num = (long)this->length();
733
		num = len;
723
734
724
	return this->substr(0, num);
735
	return this->substr(0, num);
725
}
736
}
726

737

727
SString SString::right(int num) const
738
SString SString::right(long long num) const
728
{
739
{
729
	if ( num > 0 ) num -= (int)this->length();
740
	const long long len = this->lengthLL();
-
 
741

-
 
742
	if ( num > 0 ) num -= len;
730
	if ( num < -(int)this->length() ) num = -(int)this->length();
743
	if ( num < -len ) num = -len;
731

744

732
	return this->substr(-num);
745
	return this->substr(-num);
733
}
746
}
734

747

735
const SString &SString::readToEndOfLine(FILE *id, int *line, bool upper)
748
const SString &SString::readToEndOfLine(FILE *id, int *line, bool upper)
Line 1018... Line 1031...
1018

1031

1019
	// remove any rc/beta version
1032
	// remove any rc/beta version
1020
	int beta1 = 0;
1033
	int beta1 = 0;
1021
	int beta2 = 0;
1034
	int beta2 = 0;
1022

1035

1023
	int len = 2;
1036
	long long len = 2;
1024
	int pos = thisStr.findPos("rc", 0);
1037
	long long pos = thisStr.findPos("rc", 0);
1025
	if ( pos == -1 ) { pos = thisStr.findPos("beta", 0); len = 4; }
1038
	if ( pos == -1 ) { pos = thisStr.findPos("beta", 0); len = 4; }
1026
//		if ( pos == -1 ) { pos = thisStr.findPos("²", 0); len = 1; }
1039
//		if ( pos == -1 ) { pos = thisStr.findPos("²", 0); len = 1; }
1027
	if ( pos != -1 ) {
1040
	if ( pos != -1 ) {
1028
		beta1 = -(long)thisStr.right(-(pos + len)).remove(' ');
1041
		beta1 = -(long)thisStr.right(-(pos + len)).remove(' ');
1029
		thisStr = thisStr.left(pos).removeEndSpace();
1042
		thisStr = thisStr.left(pos).removeEndSpace();