1 /* 2 * Copyright 2011, Haiku, Inc. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _PACKAGE__PACKAGE_RESOLVABLE_EXPRESSION_H_ 6 #define _PACKAGE__PACKAGE_RESOLVABLE_EXPRESSION_H_ 7 8 9 #include <String.h> 10 11 #include <package/PackageResolvableOperator.h> 12 #include <package/PackageVersion.h> 13 14 15 namespace BPackageKit { 16 17 18 namespace BHPKG { 19 class BPackageResolvableExpressionData; 20 } 21 using BHPKG::BPackageResolvableExpressionData; 22 23 24 /* 25 * Expresses a constraint on a specific resolvable, either just a name 26 * or a name plus a relational operator and a version. 27 * Instances of these will be matched against all the BPackageResolvable(s) 28 * of individual packages in order to solve a package management request. 29 * 30 * resolvable-expression ::= <name>[<op><version>] 31 * op ::= '<' | '<=' | '==' | '>=' | '>' 32 * 33 * String examples: 34 * haiku==r1 35 * lib:libssl==0.9.8 36 * subversion>=1.5 37 * cmd:svn 38 */ 39 class BPackageResolvableExpression { 40 public: 41 BPackageResolvableExpression(); 42 BPackageResolvableExpression( 43 const BPackageResolvableExpressionData& data 44 ); 45 BPackageResolvableExpression( 46 const BString& name, 47 BPackageResolvableOperator _op 48 = B_PACKAGE_RESOLVABLE_OP_ENUM_COUNT, 49 const BPackageVersion& version 50 = BPackageVersion()); 51 52 status_t InitCheck() const; 53 54 const BString& Name() const; 55 BPackageResolvableOperator Operator() const; 56 const BPackageVersion& Version() const; 57 58 BString ToString() const; 59 60 void SetTo(const BString& name, 61 BPackageResolvableOperator _op 62 = B_PACKAGE_RESOLVABLE_OP_ENUM_COUNT, 63 const BPackageVersion& version 64 = BPackageVersion()); 65 void Clear(); 66 67 public: 68 static const char* kOperatorNames[]; 69 70 private: 71 BString fName; 72 BPackageResolvableOperator fOperator; 73 BPackageVersion fVersion; 74 }; 75 76 77 } // namespace BPackageKit 78 79 80 #endif // _PACKAGE__PACKAGE_RESOLVABLE_EXPRESSION_H_ 81