|
| | SVGParserContext (std::string_view input, ParseWarningSink &warningSink, const SVGParser::Options &options) |
| | Construct a new context for the given input string.
|
|
const SVGParser::Options & | options () const |
| | Get the parser options.
|
| void | setNamespacePrefix (const RcString &namespacePrefix) |
| | Set the XML document's default namespace prefix, such as "http://www.w3.org/2000/svg".
|
|
std::string_view | namespacePrefix () const |
| | Get the XML document's default namespace prefix, such as "http://www.w3.org/2000/svg".
|
| ParseDiagnostic | fromSubparser (ParseDiagnostic &&error, ParserOrigin origin) |
| | Remap a parse error from a subparser back to the original input string, translating the line numbers.
|
| void | addWarning (ParseDiagnostic &&warning) |
| | Add a warning to the list of warnings.
|
|
bool | warningsEnabled () const |
| | Whether the document parser collects diagnostics.
|
|
const std::vector< ParseDiagnostic > & | warnings () const |
| | Warnings collected so far, in the order they were added.
|
| void | setTypedAttributesOnly (bool typedOnly) |
| | Restrict attribute parsing to type-specific attributes: an attribute that falls through to the common attribute path (presentation, conditional-processing and generic attributes) is left alone and only recorded, see fellThroughToCommonAttributes.
|
|
bool | typedAttributesOnly () const |
| | Whether attribute parsing skips common attributes, see setTypedAttributesOnly.
|
|
void | noteCommonAttributeFallThrough () |
| | Records that an attribute fell through to the common attribute path.
|
|
bool | takeCommonAttributeFallThrough () |
| | Returns whether an attribute fell through to the common attribute path since the last call, and clears the record.
|
| void | addRecoverableWarnings (ParseWarningSink &&warnings) |
| | Forward recovered parser diagnostics directly, preserving bounded sink refusal flags.
|
| SourceRange | documentSourceRange (SourceRange range) const |
| | Annotate a known document source range when original input is available.
|
| void | addSubparserWarning (ParseDiagnostic &&warning, ParserOrigin origin) |
| | Add a warning from a subparser to the list of warnings, remapping the error back to the original input string.
|
| std::optional< SourceRange > | getAttributeLocation (const xml::XMLNode &node, const xml::XMLQualifiedNameRef &attributeName) const |
| | Get the location of an element's attribute in the input string, from an XMLNode.
|
| std::optional< SourceRange > | getAttributeLocation (const SVGElement &element, const xml::XMLQualifiedNameRef &attributeName) const |
| | Get the location of an element's attribute in the input string, from an SVGElement.
|
| ParserOrigin | parserOriginFrom (std::string_view substring) const |
| | Create a ParserOrigin for the given substring, where substring is within the XML parser's original string.
|
| size_t | offsetToLine (size_t offset) const |
| | Return line numbers for the given offset.
|
| size_t | lineOffset (size_t line) const |
| | Returns the offset of a given 1-indexed line number.
|
Stores the current state of SVGParser during parsing.
Used to add parse warnings and store global state like the parsing options.
| size_t donner::svg::parser::SVGParserContext::offsetToLine |
( |
size_t | offset | ) |
const |
|
inline |
Return line numbers for the given offset.
For example, given a string: "abc\n123", offsets 0-3 would be considered line 1, and offsets after 4 (corresponding to the index of '1'), would be line 2. Values beyond the length of the string return the last line number.
- Parameters
-
- Returns
- size_t Line number, 1-indexed.