• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 namespace OHOS {
23 namespace UDMF {
24 constexpr const char* FLEXIBLE_TYPE_FLAG = "flex.z";
25 enum FlexibleTypeAttr : int32_t {
26     BELONGINGTO_TYPE = 0,
27     MIMETYPE,
28     FILE_EXTENTSION,
29     INVALID_BUT
30 };
31 class FlexibleType {
32 public:
33     static std::string EscapeStr(const std::string &chs);
34     static bool ParseFlexibleUtd(const std::string &typeId, TypeDescriptorCfg &flexibleTypeDescriptorCfg);
35     static std::string GenFlexibleUtd(const std::string &mimeType, const std::string &fileExtension,
36                                      const std::string &belongsTo);
37     static constexpr size_t MAX_TYPE_SIZE = 128;
38     static constexpr size_t ATTRIBUTE_PAIR_SIZE = 2;
39 private:
40     static std::vector<std::string> StrSplit(const std::string &str, const std::string &delimiter);
41 };
42 } // namespace UDMF
43 } // namespace OHOS
44 #endif // UDMF_UTD_FLEXIBLE_TYPE
45