1 /* vim:set et ts=4 sts=4:
3 * ibus-pinyin - The Chinese PinYin engine for IBus
5 * Copyright (c) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
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 2, or (at your option)
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.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef __PY_PINYIN_ARRAY_H_
22 #define __PY_PINYIN_ARRAY_H_
29 struct PinyinSegment {
34 PinyinSegment (const Pinyin *pinyin = NULL, guint begin = 0, guint len = 0)
35 : pinyin (pinyin), begin (begin), len (len) { }
37 operator const Pinyin * (void) const
42 const Pinyin * operator-> (void) const
47 gboolean operator == (const PinyinSegment & p) const
49 return (pinyin == p.pinyin) && (begin == p.begin) && (len == p.len);
52 gboolean operator == (const Pinyin *p) const
58 class PinyinArray: public std::vector<PinyinSegment> {
60 PinyinArray (guint init_size = 0)
62 std::vector<PinyinSegment>::reserve (init_size);
65 void append (const Pinyin *pinyin, guint begin, guint len)
67 push_back (PinyinSegment (pinyin, begin, len));