summaryrefslogtreecommitdiff
path: root/src/string_base.h
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2013-08-05 20:35:31 +0000
committermichi_cc <michi_cc@openttd.org>2013-08-05 20:35:31 +0000
commit76367f6bf1b5b459c9a15faa0cc0ea1dab191c6f (patch)
treeda45ccb0547732c9ff21f670971d5e7979c38f8c /src/string_base.h
parente7dc14b25af4b2802a956dd1cd99c187fb4acb56 (diff)
downloadopenttd-76367f6bf1b5b459c9a15faa0cc0ea1dab191c6f.tar.xz
(svn r25653) -Add: Caret movement by words for CJK languages.
Diffstat (limited to 'src/string_base.h')
-rw-r--r--src/string_base.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/string_base.h b/src/string_base.h
index 73439f639..e1eaed349 100644
--- a/src/string_base.h
+++ b/src/string_base.h
@@ -15,6 +15,12 @@
/** Class for iterating over different kind of parts of a string. */
class StringIterator {
public:
+ /** Type of the iterator. */
+ enum IterType {
+ ITER_CHARACTER, ///< Iterate over characters (or more exactly grapheme clusters).
+ ITER_WORD, ///< Iterate over words.
+ };
+
/** Sentinel to indicate end-of-iteration. */
static const size_t END = SIZE_MAX;
@@ -45,13 +51,13 @@ public:
* Advance the cursor by one iteration unit.
* @return New cursor position (in bytes) or #END if the cursor is already at the end of the string.
*/
- virtual size_t Next() = 0;
+ virtual size_t Next(IterType what = ITER_CHARACTER) = 0;
/**
* Move the cursor back by one iteration unit.
* @return New cursor position (in bytes) or #END if the cursor is already at the start of the string.
*/
- virtual size_t Prev() = 0;
+ virtual size_t Prev(IterType what = ITER_CHARACTER) = 0;
protected:
StringIterator() {}