| 1 | /* |
| 2 | * Open Chinese Convert |
| 3 | * |
| 4 | * Copyright 2010-2014 Carbo Kuo <[email protected]> |
| 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | */ |
| 18 | |
| 19 | #pragma once |
| 20 | |
| 21 | #include "Common.hpp" |
| 22 | #include "ResourceProvider.hpp" |
| 23 | |
| 24 | namespace opencc { |
| 25 | |
| 26 | struct OPENCC_EXPORT ConfigLoadOptions { |
| 27 | ConfigLoadOptions() : includeTofuRiskDictionaries(true) {} |
| 28 | |
| 29 | bool includeTofuRiskDictionaries; |
| 30 | }; |
| 31 | |
| 32 | /** |
| 33 | * Configuration loader |
| 34 | * @ingroup opencc_cpp_api |
| 35 | */ |
| 36 | class OPENCC_EXPORT Config { |
| 37 | public: |
| 38 | Config(); |
| 39 | |
| 40 | virtual ~Config(); |
| 41 | |
| 42 | ConverterPtr NewFromString(const std::string& json, |
| 43 | const std::string& configDirectory); |
| 44 | |
| 45 | ConverterPtr NewFromString(const std::string& json, |
| 46 | const std::vector<std::string>& paths); |
| 47 | |
| 48 | ConverterPtr NewFromString(const std::string& json, |
| 49 | const std::vector<std::string>& paths, |
| 50 | const ConfigLoadOptions& options); |
| 51 | |
| 52 | ConverterPtr NewFromString(const std::string& json, |
| 53 | std::shared_ptr<ResourceProvider> provider); |
| 54 | |
| 55 | ConverterPtr NewFromString(const std::string& json, |
| 56 | std::shared_ptr<ResourceProvider> provider, |
| 57 | const ConfigLoadOptions& options); |
| 58 | |
| 59 | ConverterPtr NewFromFile(const std::string& fileName); |
| 60 | |
| 61 | ConverterPtr NewFromFile(const std::string& fileName, |
| 62 | std::shared_ptr<ResourceProvider> provider); |
| 63 | |
| 64 | ConverterPtr NewFromFile(const std::string& fileName, |
| 65 | std::shared_ptr<ResourceProvider> provider, |
| 66 | const ConfigLoadOptions& options); |
| 67 | |
| 68 | ConverterPtr NewFromFile(const std::string& fileName, |
| 69 | const std::vector<std::string>& paths, |
| 70 | const char* argv0); |
| 71 | |
| 72 | ConverterPtr NewFromFile(const std::string& fileName, |
| 73 | const std::vector<std::string>& paths, |
| 74 | const char* argv0, |
| 75 | const ConfigLoadOptions& options); |
| 76 | |
| 77 | private: |
| 78 | void* internal; |
| 79 | }; |
| 80 | } // namespace opencc |