• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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 // Functions to compress and decompress low entropy entries in the model.
18 
19 #ifndef LIBTEXTCLASSIFIER_ACTIONS_ZLIB_UTILS_H_
20 #define LIBTEXTCLASSIFIER_ACTIONS_ZLIB_UTILS_H_
21 
22 #include "actions/actions_model_generated.h"
23 #include "utils/zlib/buffer_generated.h"
24 #include "utils/zlib/zlib.h"
25 
26 namespace libtextclassifier3 {
27 
28 // Compresses regex rules in the model in place.
29 bool CompressActionsModel(ActionsModelT* model);
30 
31 // Decompresses regex rules in the model in place.
32 bool DecompressActionsModel(ActionsModelT* model);
33 
34 // Compresses regex rules in the model.
35 std::string CompressSerializedActionsModel(const std::string& model);
36 
37 bool GetUncompressedString(const flatbuffers::String* uncompressed_buffer,
38                            const CompressedBuffer* compressed_buffer,
39                            ZlibDecompressor* decompressor, std::string* out);
40 
41 }  // namespace libtextclassifier3
42 
43 #endif  // LIBTEXTCLASSIFIER_ACTIONS_ZLIB_UTILS_H_
44