1 /* 2 * Copyright 2011, Haiku, Inc. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _PACKAGE__PACKAGE_INFO_H_ 6 #define _PACKAGE__PACKAGE_INFO_H_ 7 8 9 #include <ObjectList.h> 10 #include <String.h> 11 12 #include <package/PackageArchitecture.h> 13 #include <package/PackageFlags.h> 14 #include <package/PackageInfoAttributes.h> 15 #include <package/PackageResolvable.h> 16 #include <package/PackageResolvableExpression.h> 17 #include <package/PackageVersion.h> 18 19 20 class BEntry; 21 22 23 namespace BPackageKit { 24 25 26 /* 27 * Keeps a list of package info elements (e.g. name, version, vendor, ...) which 28 * will be converted to package attributes when creating a package. Usually, 29 * these elements have been parsed from a ".PackageInfo"-file. 30 * Alternatively, the package reader populates a BPackageInfo object by 31 * collecting package attributes from an existing package. 32 */ 33 class BPackageInfo { 34 public: 35 struct ParseErrorListener { 36 virtual ~ParseErrorListener(); 37 virtual void OnError(const BString& msg, int line, int col) = 0; 38 }; 39 40 public: 41 BPackageInfo(); 42 ~BPackageInfo(); 43 44 status_t ReadFromConfigFile( 45 const BEntry& packageInfoEntry, 46 ParseErrorListener* listener = NULL); 47 status_t ReadFromConfigString( 48 const BString& packageInfoString, 49 ParseErrorListener* listener = NULL); 50 51 status_t InitCheck() const; 52 53 const BString& Name() const; 54 const BString& Summary() const; 55 const BString& Description() const; 56 const BString& Vendor() const; 57 const BString& Packager() const; 58 const BString& Checksum() const; 59 60 uint32 Flags() const; 61 62 BPackageArchitecture Architecture() const; 63 64 const BPackageVersion& Version() const; 65 66 const BObjectList<BString>& CopyrightList() const; 67 const BObjectList<BString>& LicenseList() const; 68 const BObjectList<BString>& URLList() const; 69 const BObjectList<BString>& SourceURLList() const; 70 71 const BObjectList<BPackageResolvable>& ProvidesList() const; 72 const BObjectList<BPackageResolvableExpression>& 73 RequiresList() const; 74 const BObjectList<BPackageResolvableExpression>& 75 SupplementsList() const; 76 const BObjectList<BPackageResolvableExpression>& 77 ConflictsList() const; 78 const BObjectList<BPackageResolvableExpression>& 79 FreshensList() const; 80 const BObjectList<BString>& ReplacesList() const; 81 82 void SetName(const BString& name); 83 void SetSummary(const BString& summary); 84 void SetDescription(const BString& description); 85 void SetVendor(const BString& vendor); 86 void SetPackager(const BString& packager); 87 void SetChecksum(const BString& checksum); 88 89 void SetFlags(uint32 flags); 90 91 void SetArchitecture( 92 BPackageArchitecture architecture); 93 94 void SetVersion(const BPackageVersion& version); 95 96 void ClearCopyrightList(); 97 status_t AddCopyright(const BString& copyright); 98 99 void ClearLicenseList(); 100 status_t AddLicense(const BString& license); 101 102 void ClearURLList(); 103 status_t AddURL(const BString& url); 104 105 void ClearSourceURLList(); 106 status_t AddSourceURL(const BString& url); 107 108 void ClearProvidesList(); 109 status_t AddProvides(const BPackageResolvable& provides); 110 111 void ClearRequiresList(); 112 status_t AddRequires( 113 const BPackageResolvableExpression& expr); 114 115 void ClearSupplementsList(); 116 status_t AddSupplements( 117 const BPackageResolvableExpression& expr); 118 119 void ClearConflictsList(); 120 status_t AddConflicts( 121 const BPackageResolvableExpression& expr); 122 123 void ClearFreshensList(); 124 status_t AddFreshens( 125 const BPackageResolvableExpression& expr); 126 127 void ClearReplacesList(); 128 status_t AddReplaces(const BString& replaces); 129 130 void Clear(); 131 132 public: 133 static status_t GetArchitectureByName(const BString& name, 134 BPackageArchitecture& _architecture); 135 136 static const char* kElementNames[]; 137 static const char* kArchitectureNames[]; 138 139 private: 140 class Parser; 141 friend class Parser; 142 143 private: 144 BString fName; 145 BString fSummary; 146 BString fDescription; 147 BString fVendor; 148 BString fPackager; 149 150 uint32 fFlags; 151 152 BPackageArchitecture fArchitecture; 153 154 BPackageVersion fVersion; 155 156 BObjectList<BString> fCopyrightList; 157 BObjectList<BString> fLicenseList; 158 BObjectList<BString> fURLList; 159 BObjectList<BString> fSourceURLList; 160 161 BObjectList<BPackageResolvable> fProvidesList; 162 163 BObjectList<BPackageResolvableExpression> fRequiresList; 164 BObjectList<BPackageResolvableExpression> fSupplementsList; 165 166 BObjectList<BPackageResolvableExpression> fConflictsList; 167 168 BObjectList<BPackageResolvableExpression> fFreshensList; 169 170 BObjectList<BString> fReplacesList; 171 172 BString fChecksum; 173 }; 174 175 176 } // namespace BPackageKit 177 178 179 #endif // _PACKAGE__PACKAGE_INFO_H_ 180