Subversion Repositories spk

Rev

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

Rev 86 Rev 94
Line 105... Line 105...
105
	va_end (args);
105
	va_end (args);
106

106

107
	return String(buffer);
107
	return String(buffer);
108
}
108
}
109

109

-
 
110
bool String::toBool() const
-
 
111
{
-
 
112
	return atoi(this->c_str()) ? true : false;
-
 
113
}
110
long String::toLong() const
114
long String::toLong() const
111
{
115
{
112
	return atoi(this->c_str());
116
	return atoi(this->c_str());
113
}
117
}
114
double String::toDouble() const
118
double String::toDouble() const
Line 266... Line 270...
266
			{
270
			{
267
				if ( newstr != "" ) newstr = newstr + token;
271
				if ( newstr != "" ) newstr = newstr + token;
268
				newstr = newstr + this->substr(lastPos, pos - lastPos);
272
				newstr = newstr + this->substr(lastPos, pos - lastPos);
269
			}
273
			}
270
			if ( whichtok > to )
274
			if ( whichtok > to )
271
				break;
275
				break;
272
		}
276
		}
273
		// Found a token, add it to the vector.
277
		// Found a token, add it to the vector.
274
		whichtok++;
278
		whichtok++;
275
279
276
		if ( pos >= this->length() )
280
		if ( pos >= this->length() )
277
			break;
281
			break;
278
282
279
		// skip past token
283
		// skip past token
280
		size_t i = 0;
284
		size_t i = 0;
281
		size_t max = strlen(token);
285
		size_t max = strlen(token);
282
		lastPos = pos;
286
		lastPos = pos;
283
		while ( (i < max) && (token[i] == this->at(lastPos)) )
287
		while ( (i < max) && (token[i] == this->at(lastPos)) )
284
		{
288
		{
285
			++i;
289
			++i;
286
			++lastPos;
290
			++lastPos;
287
		}
291
		}
288
292
289
		// get the next token
293
		// get the next token
290
		pos = _token_nextPos(token, lastPos);
294
		pos = _token_nextPos(token, lastPos);
291
	}
295
	}
292
	return newstr;
296
	return newstr;
293
}
297
}
294

298

295
String String::remToken(const char *token, int from) const
299
String String::remToken(const char *token, int from) const
296
{
300
{
297
	Utils::String newstr;
301
	Utils::String newstr;
298

302

Line 307... Line 311...
307
			if ( newstr != "" ) newstr = newstr + token;
311
			if ( newstr != "" ) newstr = newstr + token;
308
			newstr = newstr + this->substr(lastPos, pos - lastPos);
312
			newstr = newstr + this->substr(lastPos, pos - lastPos);
309
		}
313
		}
310

314

311
		// Found a token, add it to the vector.
315
		// Found a token, add it to the vector.
312
		whichtok++;
316
		whichtok++;
313
317
314
		if ( pos >= this->length() )
318
		if ( pos >= this->length() )
315
			break;
319
			break;
316

320

317
		// skip past token
321
		// skip past token
318
		size_t i = 0;
322
		size_t i = 0;
Line 347... Line 351...
347
	int found = 1;
351
	int found = 1;
348

352

349
	Utils::String tmpstr = *this;
353
	Utils::String tmpstr = *this;
350

354

351
	// ignore the initial spaces
355
	// ignore the initial spaces
352
	Utils::String::size_type pos = this->find_first_not_of(token, 0);
356
	Utils::String::size_type pos = this->find_first_not_of(token, 0);
353
357
354
	// remove end spaces
358
	// remove end spaces
355
	size_t i = tmpstr.size() - 1;
359
	size_t i = tmpstr.size() - 1;
356
	while ( tmpstr[i] == ' ' && i > 0 )
360
	while ( tmpstr[i] == ' ' && i > 0 )
357
		i--;
361
		i--;
358
	if ( i <= 0 ) return 0;
362
	if ( i <= 0 ) return 0;
Line 592... Line 596...
592
String String::replaceToken(const char *token, int from, const String &replace) const
596
String String::replaceToken(const char *token, int from, const String &replace) const
593
{
597
{
594
	Utils::String newstr;
598
	Utils::String newstr;
595

599

596
	int whichtok = 1;
600
	int whichtok = 1;
597
	Utils::String::size_type lastPos = 0;
601
	Utils::String::size_type lastPos = 0;
598
	Utils::String::size_type pos     = _token_nextPos(token, 0);
602
	Utils::String::size_type pos     = _token_nextPos(token, 0);
599

603

600
	while (Utils::String::npos != pos || Utils::String::npos != lastPos)
604
	while (Utils::String::npos != pos || Utils::String::npos != lastPos)
601
	{
605
	{
602
		if ( whichtok == from )
606
		if ( whichtok == from )
Line 747... Line 751...
747
{
751
{
748
	Utils::String::size_type pos = this->find_first_not_of(" \t\f\v\n\r", 0);
752
	Utils::String::size_type pos = this->find_first_not_of(" \t\f\v\n\r", 0);
749
	if ( pos != Utils::String::npos ) {
753
	if ( pos != Utils::String::npos ) {
750
		this->erase(0, pos);
754
		this->erase(0, pos);
751
	}
755
	}
-
 
756
	else
-
 
757
		this->clear();
752
	return (*this);
758
	return (*this);
753
}
759
}
754
const String &String::removeEndSpace()
760
const String &String::removeEndSpace()
755
{
761
{
756
	Utils::String::size_type pos = this->find_last_not_of(" \t\f\v\n\r");
762
	Utils::String::size_type pos = this->find_last_not_of(" \t\f\v\n\r");
757
	if ( pos != Utils::String::npos ) {
763
	if ( pos != Utils::String::npos ) {
758
		this->erase(pos + 1);
764
		this->erase(pos + 1);
759
	}
765
	}
-
 
766
	else
-
 
767
		this->clear();
760
	return (*this);
768
	return (*this);
761
}
769
}
762

770

763
const String &String::truncate(int iNum)
771
const String &String::truncate(int iNum)
764
{
772
{