• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2009 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef PINYINIME_INCLUDE_UTF16READER_H__
18 #define PINYINIME_INCLUDE_UTF16READER_H__
19 
20 #include <stdio.h>
21 #include "./utf16char.h"
22 
23 namespace ime_pinyin {
24 
25 class Utf16Reader {
26  private:
27   FILE *fp_;
28   char16 *buffer_;
29   size_t buffer_total_len_;
30   size_t buffer_next_pos_;
31 
32   // Always less than buffer_total_len_ - buffer_next_pos_
33   size_t buffer_valid_len_;
34 
35  public:
36   Utf16Reader();
37   ~Utf16Reader();
38 
39   // filename is the name of the file to open.
40   // buffer_len specifies how long buffer should be allocated to speed up the
41   // future reading
42   bool open(const char* filename, size_t buffer_len);
43   char16* readline(char16* read_buf, size_t max_len);
44   bool close();
45 };
46 }
47 
48 #endif  // PINYINIME_INCLUDE_UTF16READER_H__
49