#pragma once #include #include #include #include namespace vcpkg::PlatformExpression { // map of cmake variables and their values. using Context = std::unordered_map; namespace detail { struct ExprImpl; } struct Expr { static Expr Identifier(StringView id); static Expr Not(Expr&& e); static Expr And(std::vector&& exprs); static Expr Or(std::vector&& exprs); // The empty expression is always true static Expr Empty() { return Expr(); } // since ExprImpl is not yet defined, we need to define the ctor and dtor in the C++ file Expr(); Expr(const Expr&); Expr(Expr&&); Expr& operator=(const Expr& e); Expr& operator=(Expr&&); explicit Expr(std::unique_ptr&& e); ~Expr(); bool evaluate(const Context& context) const; bool is_empty() const { return !static_cast(underlying_); } private: std::unique_ptr underlying_; }; // Note: for backwards compatibility, in CONTROL files, // multiple binary operators are allowed to be next to one another; i.e. // (windows & arm) = (windows && arm) = (windows &&& arm), etc. enum class MultipleBinaryOperators { Deny, Allow, }; // platform expression parses the following : // : // // // // : // ( ) // // : // A lowercase alpha-numeric string // : // // ! // // // & // // // | ExpectedS parse_platform_expression(StringView expression, MultipleBinaryOperators multiple_binary_operators); }