diff options
author | Peng Wu <alexepico@gmail.com> | 2014-09-22 15:06:54 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2014-09-22 15:06:54 +0800 |
commit | 91e2dbca77121840393ee991f2e9cbd0d432d906 (patch) | |
tree | 5f68067bb31e2a0c8951d95fcb895945a1e9980a /src | |
parent | bdec4e805455af2a47debb5fb2eeb32de452710f (diff) | |
download | ibus-libzhuyin-91e2dbca77121840393ee991f2e9cbd0d432d906.tar.gz ibus-libzhuyin-91e2dbca77121840393ee991f2e9cbd0d432d906.tar.xz ibus-libzhuyin-91e2dbca77121840393ee991f2e9cbd0d432d906.zip |
fixes class String
Diffstat (limited to 'src')
-rw-r--r-- | src/ZYEditor.cc | 3 | ||||
-rw-r--r-- | src/ZYString.h | 10 | ||||
-rw-r--r-- | src/ZYZPhoneticEditor.cc | 14 |
3 files changed, 16 insertions, 11 deletions
diff --git a/src/ZYEditor.cc b/src/ZYEditor.cc index 3cff304..d30deed 100644 --- a/src/ZYEditor.cc +++ b/src/ZYEditor.cc @@ -24,8 +24,7 @@ namespace ZY { Editor::Editor (ZhuyinProperties & props, Config & config) - : m_text (128), - m_cursor (0), + : m_cursor (0), m_props (props), m_config (config) { diff --git a/src/ZYString.h b/src/ZYString.h index 7ddfb79..3e5cd9d 100644 --- a/src/ZYString.h +++ b/src/ZYString.h @@ -23,6 +23,7 @@ #include <glib.h> #include <stdarg.h> +#include <assert.h> #include <string> namespace ZY { @@ -32,7 +33,8 @@ public: String () : std::string () { } String (const gchar *str) : std::string (str) { } String (const std::string &str) : std::string (str) { } - String (gint len) : std::string () { reserve (len); } + String (gint len) : std::string () { assert (FALSE); } + String (const gchar ch) : std::string (1, ch) { } String & printf (const gchar *fmt, ...) { @@ -149,6 +151,12 @@ public: return *this; } + String & operator= (const gchar ch) + { + assign (1, ch); + return *this; + } + operator const gchar *(void) const { return this->c_str (); diff --git a/src/ZYZPhoneticEditor.cc b/src/ZYZPhoneticEditor.cc index 6dc1dcd..9e67981 100644 --- a/src/ZYZPhoneticEditor.cc +++ b/src/ZYZPhoneticEditor.cc @@ -87,7 +87,6 @@ PhoneticEditor::~PhoneticEditor (void) gboolean PhoneticEditor::loadEasySymbolFile(const gchar * filename) { - printf ("load %s.\n", filename); gboolean retval = m_easy_symbols.loadFromFile (filename); return retval; } @@ -297,8 +296,7 @@ PhoneticEditor::processEasySymbolKey (guint keyval, guint keycode, if (! ('A' <= keyval && keyval <= 'Z')) return FALSE; - String index; - index.append (1, keyval); + String index = (gchar) keyval; String symbol = m_easy_symbols.find (index); if ("" == symbol) @@ -307,7 +305,7 @@ PhoneticEditor::processEasySymbolKey (guint keyval, guint keycode, String lookup; int ch = find_lookup_key (symbol); if (ch != 0) - lookup = ch; + lookup = (gchar) ch; insert_symbol (m_text, m_cursor++, BUILTIN_SYMBOL_TYPE, lookup, symbol); @@ -784,12 +782,12 @@ PhoneticEditor::insertPunct (guint ch) String lookup; int ch = find_lookup_key (choice); if (ch != 0) - lookup = ch; + lookup = (gchar) ch; insert_symbol (m_text, m_cursor++, BUILTIN_SYMBOL_TYPE, lookup, choice); } else { - String choice = ch; + String choice = (gchar)ch; insert_symbol (m_text, m_cursor++, BUILTIN_SYMBOL_TYPE, "", choice); } @@ -812,12 +810,12 @@ PhoneticEditor::insertEnglish (guint ch) String lookup; int ch = find_lookup_key (choice); if (ch != 0) - lookup = ch; + lookup = (gchar) ch; insert_symbol (m_text, m_cursor++, BUILTIN_SYMBOL_TYPE, lookup, choice); } else { - String choice = ch; + String choice = (gchar) ch; insert_symbol (m_text, m_cursor++, BUILTIN_SYMBOL_TYPE, "", choice); } |