Home | History | Annotate | Download | only in utils
      1 /*
      2  * Copyright (C) 2013, 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 LATINIME_DICT_FILE_WRITING_UTILS_H
     18 #define LATINIME_DICT_FILE_WRITING_UTILS_H
     19 
     20 #include <cstdio>
     21 
     22 #include "defines.h"
     23 #include "suggest/policyimpl/dictionary/header/header_read_write_utils.h"
     24 
     25 namespace latinime {
     26 
     27 class BufferWithExtendableBuffer;
     28 
     29 class DictFileWritingUtils {
     30  public:
     31     static bool createEmptyDictFile(const char *const filePath, const int dictVersion,
     32             const HeaderReadWriteUtils::AttributeMap *const attributeMap);
     33 
     34     static bool flushAllHeaderAndBodyToFile(const char *const filePath,
     35             BufferWithExtendableBuffer *const dictHeader,
     36             BufferWithExtendableBuffer *const dictBody);
     37 
     38  private:
     39     DISALLOW_IMPLICIT_CONSTRUCTORS(DictFileWritingUtils);
     40 
     41     static const char *const TEMP_FILE_SUFFIX_FOR_WRITING_DICT_FILE;
     42 
     43     static bool createEmptyV3DictFile(const char *const filePath,
     44             const HeaderReadWriteUtils::AttributeMap *const attributeMap);
     45 
     46     static bool writeBufferToFile(FILE *const file,
     47             const BufferWithExtendableBuffer *const buffer);
     48 };
     49 } // namespace latinime
     50 #endif /* LATINIME_DICT_FILE_WRITING_UTILS_H */
     51