MCPcopy Create free account
hub / github.com/MyGUI/mygui / cutMaxLength

Method cutMaxLength

MyGUIEngine/src/MyGUI_TextIterator.cpp:450–503  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

448 }
449
450 void TextIterator::cutMaxLength(size_t _max)
451 {
452 if ((mSize != ITEM_NONE) && (mSize <= _max))
453 return;
454 if (mPosition > _max)
455 {
456 // придется считать сначала
457 mSize = mPosition = 0;
458 mCurrent = mText.begin();
459 mEnd = mSave = mText.end();
460 }
461
462 mSize = mPosition;
463
464 for (UString::utf32string::iterator iter = mCurrent; iter != mEnd; ++iter)
465 {
466 if ((*iter) == L'#')
467 {
468 // следующий символ
469 ++iter;
470 if (iter == mEnd)
471 break;
472
473 // тэг цвета
474 if ((*iter) != L'#')
475 {
476 // остальные 5 символов цвета
477 for (size_t pos = 0; pos < 5; pos++)
478 {
479 ++iter;
480 if (iter == mEnd)
481 {
482 --iter;
483 break;
484 }
485 }
486 continue;
487 }
488 }
489
490 // проверяем и обрезаем
491 if (mSize == _max)
492 {
493 mPosition = mSize; // сохраняем
494 mCurrent = erase(iter, mEnd);
495 mSave = mEnd = mText.end();
496 mSize = mPosition; // восстанавливаем
497 return;
498 }
499
500 // увеличиваем
501 mSize++;
502 }
503 }
504
505 void TextIterator::cutMaxLengthFromBeginning(size_t _max)
506 {

Callers 2

setTextMethod · 0.80
insertTextMethod · 0.80

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected