MyGUI 3.4.3
MyGUI_TextIterator.h
Go to the documentation of this file.
1/*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7#ifndef MYGUI_TEXT_ITERATOR_H_
8#define MYGUI_TEXT_ITERATOR_H_
9
10#include "MyGUI_Prerequest.h"
11#include "MyGUI_Colour.h"
13#include "MyGUI_IFont.h"
14
15namespace MyGUI
16{
17
18 class MYGUI_EXPORT TextIterator
19 {
20 private:
21 TextIterator();
22
23 public:
24 TextIterator(const UString& _text, VectorChangeInfo* _history = nullptr);
25
26 bool moveNext();
27
28 // возвращает цвет
29 bool getTagColour(UString& _colour) const;
30
31 // удаляет цвет
32 void clearTagColour();
33
34 bool setTagColour(const Colour& _colour);
35
36 bool setTagColour(const UString& _colour);
37
38 // сохраняет текущий итератор
39 bool saveStartPoint();
40
41 // возвращает строку от сохраненного итератора до текущего
42 UString getFromStart() const;
43
44 // удаляет от запомненной точки до текущей
45 bool eraseFromStart();
46
47 // возвращает текущую псевдо позицию
48 size_t getPosition() const;
49
50 UString getText() const;
51
52 void insertText(const UString& _insert, bool _multiLine);
53
54 void clearNewLine(UString& _text);
55
56 //очищает весь текст
57 void clearText();
58
59 // возвращает размер строки
60 size_t getSize() const;
61
62 void setText(const UString& _text, bool _multiLine);
63
64 void cutMaxLength(size_t _max);
65
66 void cutMaxLengthFromBeginning(size_t _max);
67
68 // возвращает текст без тегов
69 static UString getOnlyText(const UString& _text);
70
71 static UString getTextNewLine();
72
73 static UString getTextCharInfo(Char _char);
74
75 // просто конвертируем цвет в строку
76 static UString convertTagColour(const Colour& _colour);
77
78 static UString toTagsString(const UString& _text);
79
80 private:
81 bool getTagColour(UString& _colour, UString::utf32string::iterator& _iter) const;
82
83 bool setTagColour(const UString::utf32string& _colour);
84
85 void insert(UString::utf32string::iterator& _start, const UString::utf32string& _insert);
86
87 UString::utf32string::iterator erase(
88 UString::utf32string::iterator _start,
89 UString::utf32string::iterator _end);
90
91 void clear();
92
93 void normaliseNewLine(UString& _text);
94
95 private:
97 UString::utf32string::iterator mCurrent, mEnd, mSave;
98
99 // позиция и размер
100 size_t mPosition;
101 mutable size_t mSize;
102 bool mFirst;
103
104 VectorChangeInfo* mHistory;
105 };
106
107} // namespace MyGUI
108
109#endif // MYGUI_TEXT_ITERATOR_H_
#define MYGUI_EXPORT
static UString getOnlyText(const UString &_text)
void clearNewLine(UString &_text)
static UString getTextNewLine()
static UString getTextCharInfo(Char _char)
void cutMaxLength(size_t _max)
bool setTagColour(const Colour &_colour)
static UString convertTagColour(const Colour &_colour)
static UString toTagsString(const UString &_text)
void cutMaxLengthFromBeginning(size_t _max)
void setText(const UString &_text, bool _multiLine)
void insertText(const UString &_insert, bool _multiLine)
bool getTagColour(UString &_colour) const
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
std::basic_string< unicode_char > utf32string
string type used for returning UTF-32 formatted data
std::vector< TextCommandInfo > VectorChangeInfo
unsigned int Char
Definition MyGUI_Types.h:50