1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * 4 * HDF is dual licensed: you can use it either under the terms of 5 * the GPL, or the BSD license, at your option. 6 * See the LICENSE file in the root of this repository for complete details. 7 */ 8 9 #ifndef OHOS_HDI_FILE_DETAIL_H 10 #define OHOS_HDI_FILE_DETAIL_H 11 12 #include <unordered_set> 13 #include "util/options.h" 14 #include "util/string.h" 15 16 namespace OHOS { 17 namespace HDI { 18 class FileDetail { 19 public: 20 using StringSet = std::unordered_set<String, StringHashFunc, StringEqualFunc>; 21 22 void SetFilePath(const String& filePath); 23 GetFilePath()24 inline String GetFilePath() const 25 { 26 return idlFilePath_; 27 } 28 SetPackageName(const String & packageName)29 void SetPackageName(const String& packageName) 30 { 31 packageName_ = packageName; 32 } 33 GetPackageName()34 inline String GetPackageName() const 35 { 36 return packageName_; 37 } 38 GetName()39 inline String GetName() const 40 { 41 return idlName_; 42 } 43 GetFullName()44 inline String GetFullName() const 45 { 46 return packageName_ + "." + idlName_; 47 } 48 49 bool AddImport(const String& packageName); 50 DelImport(const String & packageName)51 void DelImport(const String& packageName) 52 { 53 imports_.erase(packageName); 54 } 55 GetImportSize()56 inline size_t GetImportSize() const 57 { 58 return imports_.size(); 59 } 60 GetImports()61 inline const StringSet& GetImports() const 62 { 63 return imports_; 64 } 65 ImportsToPath(const String & importPkgName)66 inline static String ImportsToPath(const String& importPkgName) 67 { 68 return Options::GetInstance().GetPackagePath(importPkgName) + ".idl"; 69 } 70 71 String Dump(); 72 private: 73 String idlFilePath_; 74 String rootPackageName_; 75 String packageName_; 76 String idlName_; 77 StringSet imports_; 78 }; 79 } // namespace HDI 80 } // namespace OHOS 81 82 #endif // OHOS_HDI_FILE_DETAIL_H