| OLD | NEW |
| (Empty) | |
| 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 "third_party/prediction/defines.h" |
| 23 #include "third_party/prediction/suggest/policyimpl/dictionary/header/header_rea
d_write_utils.h" |
| 24 #include "third_party/prediction/suggest/policyimpl/dictionary/utils/format_util
s.h" |
| 25 |
| 26 namespace latinime { |
| 27 |
| 28 class BufferWithExtendableBuffer; |
| 29 |
| 30 class DictFileWritingUtils { |
| 31 public: |
| 32 static const char* const TEMP_FILE_SUFFIX_FOR_WRITING_DICT_FILE; |
| 33 |
| 34 static bool createEmptyDictFile( |
| 35 const char* const filePath, |
| 36 const int dictVersion, |
| 37 const std::vector<int> localeAsCodePointVector, |
| 38 const DictionaryHeaderStructurePolicy::AttributeMap* const attributeMap); |
| 39 |
| 40 static bool flushBufferToFileWithSuffix( |
| 41 const char* const basePath, |
| 42 const char* const suffix, |
| 43 const BufferWithExtendableBuffer* const buffer); |
| 44 |
| 45 static bool writeBufferToFileTail( |
| 46 FILE* const file, |
| 47 const BufferWithExtendableBuffer* const buffer); |
| 48 |
| 49 private: |
| 50 DISALLOW_IMPLICIT_CONSTRUCTORS(DictFileWritingUtils); |
| 51 |
| 52 static const int SIZE_OF_BUFFER_SIZE_FIELD; |
| 53 |
| 54 static bool createEmptyV401DictFile( |
| 55 const char* const filePath, |
| 56 const std::vector<int> localeAsCodePointVector, |
| 57 const DictionaryHeaderStructurePolicy::AttributeMap* const attributeMap, |
| 58 const FormatUtils::FORMAT_VERSION formatVersion); |
| 59 |
| 60 template <class DictConstants, class DictBuffers, class DictBuffersPtr> |
| 61 static bool createEmptyV4DictFile( |
| 62 const char* const filePath, |
| 63 const std::vector<int> localeAsCodePointVector, |
| 64 const DictionaryHeaderStructurePolicy::AttributeMap* const attributeMap, |
| 65 const FormatUtils::FORMAT_VERSION formatVersion); |
| 66 |
| 67 static bool flushBufferToFile(const char* const filePath, |
| 68 const BufferWithExtendableBuffer* const buffer); |
| 69 |
| 70 static bool writeBufferToFile(FILE* const file, |
| 71 const BufferWithExtendableBuffer* const buffer); |
| 72 }; |
| 73 } // namespace latinime |
| 74 #endif /* LATINIME_DICT_FILE_WRITING_UTILS_H */ |
| OLD | NEW |