ScummVM API documentation
unicode-bidi.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef COMMON_STRING_BIDI_H
23 #define COMMON_STRING_BIDI_H
24 
25 #include "common/str.h"
26 #include "common/ustr.h"
27 #include "common/language.h"
28 
29 namespace Common {
30 
35  BIDI_PAR_ON = 0,
36  BIDI_PAR_RTL = 1,
37  BIDI_PAR_LTR = 2
38 };
39 
41 private:
42  uint32 *_log_to_vis_index; // from fribidi conversion
43  uint32 *_vis_to_log_index; // from fribidi conversion
44  void initWithU32String(const Common::U32String &str);
45  Common::String bidiByLine(Common::String line, va_list args);
46 public:
47  const Common::U32String logical; // original string, ordered logically
48  Common::U32String visual; // from fribidi conversion, ordered visually
49  uint32 _pbase_dir;
50 
51  UnicodeBiDiText(const Common::U32String &str, BiDiParagraph dir = BIDI_PAR_ON);
52  /* This constructor shouldn't be used outside of unicode-bidi.cpp file */
53  UnicodeBiDiText(const Common::String &str, const Common::CodePage page, uint32 *pbase_dir);
54  ~UnicodeBiDiText();
55 
59  operator const U32String &() const { return visual; }
60 
61  uint32 getVisualPosition(uint32 logicalPos) const;
62  uint32 getLogicalPosition(uint32 visualPos) const;
63  uint32 size() const { return logical.size(); }
64 };
65 
66 /* just call the constructor for convenience */
67 UnicodeBiDiText convertBiDiU32String(const U32String &input, BiDiParagraph dir = BIDI_PAR_ON);
68 String convertBiDiString(const String &input, const Common::Language lang, BiDiParagraph dir = BIDI_PAR_ON);
69 String convertBiDiString(const String &input, const Common::CodePage page, BiDiParagraph dir = BIDI_PAR_ON);
70 
71 // calls convertBiDiString for each line in isolation
72 String convertBiDiStringByLines(const String &input, const Common::CodePage page, BiDiParagraph dir = BIDI_PAR_ON);
73 
74 } // End of namespace Common
75 
76 #endif
Definition: str.h:59
Definition: ustr.h:57
Definition: algorithm.h:29
Definition: unicode-bidi.h:40
BiDiParagraph
Definition: unicode-bidi.h:34
Language
Definition: language.h:45