summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2014-03-21 10:47:41 +0800
committerPeng Wu <alexepico@gmail.com>2014-03-21 10:48:13 +0800
commit5cd8c2422511251ec0aab14df93ad86232865d78 (patch)
tree0ff185f0e4cfaf8128aac12332c05cfed87bdfe4 /src
parent1ec346ec3ce6dc84dfca3538e14f373c3682869d (diff)
downloadibus-libzhuyin-5cd8c2422511251ec0aab14df93ad86232865d78.tar.gz
ibus-libzhuyin-5cd8c2422511251ec0aab14df93ad86232865d78.tar.xz
ibus-libzhuyin-5cd8c2422511251ec0aab14df93ad86232865d78.zip
add probe_section_quick
Diffstat (limited to 'src')
-rw-r--r--src/ZYEnhancedText.cc14
-rw-r--r--src/ZYEnhancedText.h5
2 files changed, 16 insertions, 3 deletions
diff --git a/src/ZYEnhancedText.cc b/src/ZYEnhancedText.cc
index ab8f62b..3380562 100644
--- a/src/ZYEnhancedText.cc
+++ b/src/ZYEnhancedText.cc
@@ -21,7 +21,6 @@
#include "ZYEnhancedText.h"
#include <assert.h>
-#include <string>
namespace ZY{
@@ -29,6 +28,8 @@ namespace ZY{
const char symbol_lead_char = '`';
const int symbol_parts_num = 3;
+typedef String::const_iterator iterator_t;
+
#if 0
/* template method, to be moved to PhoneticEditor class. */
bool
@@ -174,6 +175,17 @@ probe_section (const String & enhanced_text, size_t offset, size_t & pos)
return PHONETIC_SECTION;
}
+section_t
+probe_section_quick (const String & enhanced_text, size_t pos)
+{
+ iterator_t iter = enhanced_text.begin () + pos;
+
+ if (symbol_lead_char == *iter)
+ return SYMBOL_SECTION;
+ else
+ return PHONETIC_SECTION;
+}
+
bool
get_phonetic_section (const String & enhanced_text,
size_t start_pos, size_t & end_pos, String & section)
diff --git a/src/ZYEnhancedText.h b/src/ZYEnhancedText.h
index 04559d0..214b31e 100644
--- a/src/ZYEnhancedText.h
+++ b/src/ZYEnhancedText.h
@@ -31,8 +31,6 @@ typedef enum {
SYMBOL_SECTION
} section_t;
-typedef String::const_iterator iterator_t;
-
/* all enhanced text should loop from the start to get the correct position. */
size_t
get_enhanced_text_length (const String & enhanced_text);
@@ -42,6 +40,9 @@ get_enhanced_text_length (const String & enhanced_text);
section_t
probe_section (const String & enhanced_text, size_t offset, size_t & pos);
+section_t
+probe_section_quick (const String & enhanced_text, size_t pos);
+
bool
get_phonetic_section (const String & enhanced_text,
size_t start_pos, size_t & end_pos, String & section);