1 /* 2 * Copyright (c) 2024 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 16 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_INSPECTOR_INSPECTOR_FILTER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_INSPECTOR_INSPECTOR_FILTER_H 18 19 #include <algorithm> 20 #include <map> 21 #include <string> 22 #include <vector> 23 24 #include "base/utils/macros.h" 25 26 namespace OHOS::Ace::NG { 27 28 enum FixedAttrBit : uint64_t { 29 FIXED_ATTR_ID = 0, /* "id" */ 30 FIXED_ATTR_CONTENT = 1, /* "content" */ 31 FIXED_ATTR_SRC = 2, /* "src" */ 32 FIXED_ATTR_EDITABLE = 3, /* "editable" */ 33 FIXED_ATTR_SCROLLABLE = 4, /* "scrollable" */ 34 FIXED_ATTR_SELECTABLE = 5, /* "selectable" */ 35 FIXED_ATTR_FOCUSABLE = 6, /* "focusable" */ 36 FIXED_ATTR_FOCUSED = 7, /* "focused" */ 37 }; 38 39 class ACE_FORCE_EXPORT InspectorFilter { 40 public: InspectorFilter()41 InspectorFilter() {} 42 bool CheckFixedAttr(const FixedAttrBit attrBit) const; 43 bool CheckExtAttr(const std::string& attr) const; 44 bool CheckFilterAttr(const FixedAttrBit fixedAttrBit, const char* extAttr) const; 45 bool IsFastFilter() const; 46 void AddFilterAttr(const std::string& attr); 47 void SetFilterID(std::string& id); 48 std::string GetFilterID(void) const; 49 void SetFilterDepth(size_t depth); 50 size_t GetFilterDepth() const; 51 private: 52 bool FilterEmpty() const; 53 std::string filterId; 54 uint32_t filterDepth = 0; 55 uint64_t filterFixed = 0; 56 std::vector<std::string> filterExt; 57 }; 58 59 } // namespace OHOS::Ace::NG 60 61 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_INSPECTOR_INSPECTOR_FILTER_H 62