|
|
Donner
C++20 SVG rendering library
|
Parser for CSS <length-percentage> strings, such as "10px", "30%", "10em", etc. More...
#include "donner/base/parser/LengthParser.h"
Classes | |
| struct | Result |
| Container for parse result, containing the parsed result and the number of characters that were consumed to parse it. More... | |
| struct | Options |
| Options to modify the parsing behavior. More... | |
Static Public Member Functions | |
| static ParseResult< Result > | Parse (std::string_view str, Options options=Options()) |
| Parse a CSS <length-percentage>, see https://www.w3.org/TR/css-values/#typedef-length-percentage. | |
| static std::optional< Lengthd::Unit > | ParseUnit (std::string_view str) |
| Parse a unit suffix from a string, such as "px" or "em". | |
Parser for CSS <length-percentage> strings, such as "10px", "30%", "10em", etc.
For example:
|
static |
Parse a CSS <length-percentage>, see https://www.w3.org/TR/css-values/#typedef-length-percentage.
Equivalent to [ <length> | <percentage> ], where <percentage> will resolve to <length>.
With the following token definitions:
If the number is 0, the <ident-token> may be omitted since 0 is unitless. This can be extended to all numbers by setting Options::unitOptional to true.
Note that this may not consume all input, the caller should handle the result of Result::consumedChars.
| str | String to parse, not all characters may be consumed. |
| options | Parser options. |
|
static |
Parse a unit suffix from a string, such as "px" or "em".
| str | String containing the unit suffix, which must be a complete case-insensitive match for a supported <dimension-token> suffix, or '%' for <percentage-token>. |