1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef UDMF_UTD_FLEXIBLE_TYPE 16 #define UDMF_UTD_FLEXIBLE_TYPE 17 #include <string> 18 #include <set> 19 #include <vector> 20 #include "error_code.h" 21 #include "utd_common.h" 22 #include "visibility.h" 23 namespace OHOS { 24 namespace UDMF { 25 constexpr const char* FLEXIBLE_TYPE_FLAG = "flex.z"; 26 enum FlexibleTypeAttr : int32_t { 27 BELONGINGTO_TYPE = 0, 28 MIMETYPE, 29 FILE_EXTENTSION, 30 INVALID_BUT 31 }; 32 class API_EXPORT FlexibleType { 33 public: 34 static std::string EscapeStr(const std::string &chs); 35 static bool ParseFlexibleUtd(const std::string &typeId, TypeDescriptorCfg &flexibleTypeDescriptorCfg); 36 static std::string GenFlexibleUtd(const std::string &mimeType, const std::string &fileExtension, 37 const std::string &belongsTo); 38 static constexpr size_t MAX_TYPE_SIZE = 128; 39 static constexpr size_t ATTRIBUTE_PAIR_SIZE = 2; 40 }; 41 } // namespace UDMF 42 } // namespace OHOS 43 #endif // UDMF_UTD_FLEXIBLE_TYPE 44