Subversion Repositories spk

Rev

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

Rev 159 Rev 160
Line 363... Line 363...
363
		pos = _token_nextPos(token, lastPos);
363
		pos = _token_nextPos(token, lastPos);
364
	}
364
	}
365
	return newstr;
365
	return newstr;
366
}
366
}
367

367

368
String String::remToken(const char *token, int from) const
368
String String::remToken(const char* token, int from) const
369
{
369
{
370
	Utils::String newstr;
370
	Utils::String newstr;
371

371

372
	if (from < 0)
372
	if (from < 0)
373
	{
373
	{
Line 375... Line 375...
375
		from = maxT + (from + 1);
375
		from = maxT + (from + 1);
376
	}
376
	}
377

377

378
	int whichtok = 1;
378
	int whichtok = 1;
379
	Utils::String::size_type lastPos = 0;
379
	Utils::String::size_type lastPos = 0;
380
	Utils::String::size_type pos     = _token_nextPos(token, 0);
380
	Utils::String::size_type pos = _token_nextPos(token, 0);
381

381

382
	while (Utils::String::npos != pos || Utils::String::npos != lastPos)
382
	while (Utils::String::npos != pos || Utils::String::npos != lastPos)
383
	{
383
	{
384
		if ( whichtok != from )
384
		if (whichtok != from)
385
		{
385
		{
386
			if ( newstr != "" ) newstr = newstr + token;
386
			if (newstr != "") newstr = newstr + token;
387
			newstr = newstr + Utils::String(this->substr(lastPos, pos - lastPos));
387
			newstr = newstr + Utils::String(this->substr(lastPos, pos - lastPos));
388
		}
388
		}
389

389

390
		// Found a token, add it to the vector.
390
		// Found a token, add it to the vector.
391
		whichtok++;
391
		whichtok++;
392

392

393
		if ( pos >;= this->length() )
393
		if (pos >;= this->length())
394
			break;
394
			break;
395

395

396
		// skip past token
396
		// skip past token
397
		size_t i = 0;
397
		size_t i = 0;
398
		size_t max = strlen(token);
398
		size_t max = strlen(token);
399
		lastPos = pos;
399
		lastPos = pos;
-
 
400
		while ((i < max) && (token[i] == this->at(lastPos)))
-
 
401
		{
-
 
402
			++i;
-
 
403
			++lastPos;
-
 
404
		}
-
 
405

-
 
406
		// get the next token
-
 
407
		pos = _token_nextPos(token, lastPos);
-
 
408
	}
-
 
409
	return newstr;
-
 
410
}
-
 
411

-
 
412
String String::remTokens(const char* token, int from, int to) const
-
 
413
{
-
 
414
	Utils::String newstr;
-
 
415

-
 
416
	if (from < 0)
-
 
417
	{
-
 
418
		int maxT = this->countToken(token);
-
 
419
		from = maxT + (from + 1);
-
 
420
	}
-
 
421
	if (to < 0)
-
 
422
	{
-
 
423
		int maxT = this->countToken(token);
-
 
424
		to = maxT + (to + 1);
-
 
425
	}
-
 
426

-
 
427
	int whichtok = 1;
-
 
428
	Utils::String::size_type lastPos = 0;
-
 
429
	Utils::String::size_type pos = _token_nextPos(token, 0);
-
 
430

-
 
431
	while (Utils::String::npos != pos || Utils::String::npos != lastPos)
-
 
432
	{
-
 
433
		if (!(whichtok >= from && whichtok <= to))
-
 
434
		{
-
 
435
			if (newstr != "") newstr = newstr + token;
-
 
436
			newstr = newstr + Utils::String(this->substr(lastPos, pos - lastPos));
-
 
437
		}
-
 
438

-
 
439
		// Found a token, add it to the vector.
-
 
440
		whichtok++;
-
 
441

-
 
442
		if (pos >= this->length())
-
 
443
			break;
-
 
444

-
 
445
		// skip past token
-
 
446
		size_t i = 0;
-
 
447
		size_t max = strlen(token);
-
 
448
		lastPos = pos;
400
		while ( (i < max) &;& (token[i] == this->at(lastPos)) )
449
		while ((i < max) &&; (token[i] == this->at(lastPos)))
401
		{
450
		{
402
			++i;
451
			++i;
403
			++lastPos;
452
			++lastPos;
404
		}
453
		}
405

454

Line 622... Line 671...
622
	return "";
671
	return "";
623
}
672
}
624

673

625
String String::mid(int start, int end) const
674
String String::mid(int start, int end) const
626
{
675
{
-
 
676
	if (end <= 0)
-
 
677
		end = this->length() + end;
627
	return this->substr(start, end - start);
678
	return this->substr(start, end - start);
628
}
679
}
629
String String::left(long num) const
680
String String::left(long num) const
630
{
681
{
631
	if ( num < 0 )
682
	if ( num < 0 )