Stores the current state of SVGParser during parsing.
More...
#include "donner/svg/parser/details/SVGParserContext.h"
|
| | SVGParserContext (std::string_view input, std::vector< ParseError > *warningsStorage, 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".
|
| ParseError | fromSubparser (ParseError &&error, ParserOrigin origin) |
| | Remap a parse error from a subparser back to the original input string, translating the line numbers.
|
| void | addWarning (ParseError &&warning) |
| | Add a warning to the list of warnings.
|
| void | addSubparserWarning (ParseError &&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< FileOffsetRange > | 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< FileOffsetRange > | 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, input_.
|
| 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.
◆ SVGParserContext()
| donner::svg::parser::SVGParserContext::SVGParserContext |
( |
std::string_view | input, |
|
|
std::vector< ParseError > * | warningsStorage, |
|
|
const SVGParser::Options & | options ) |
|
inline |
Construct a new context for the given input string.
- Parameters
-
| input | Input string. |
| warningsStorage | Storage for warnings, may be nullptr to disable warnings. |
| options | Options for parsing. |
◆ addSubparserWarning()
| void donner::svg::parser::SVGParserContext::addSubparserWarning |
( |
ParseError && | warning, |
|
|
ParserOrigin | origin ) |
|
inline |
Add a warning from a subparser to the list of warnings, remapping the error back to the original input string.
- Parameters
-
| warning | Warning to add. |
| origin | Origin of the subparser. |
◆ addWarning()
| void donner::svg::parser::SVGParserContext::addWarning |
( |
ParseError && | warning | ) |
|
|
inline |
Add a warning to the list of warnings.
- Parameters
-
◆ fromSubparser()
Remap a parse error from a subparser back to the original input string, translating the line numbers.
- Parameters
-
| error | Error to remap. |
| origin | Origin of the subparser. |
- Returns
- ParseError Remapped error.
◆ getAttributeLocation() [1/2]
Get the location of an element's attribute in the input string, from an SVGElement.
- Parameters
-
| element | Element containing the attribute. |
| attributeName | Name of the attribute. |
- Returns
- std::optional<size_t> Offset of the element's attribute in the input string.
◆ getAttributeLocation() [2/2]
Get the location of an element's attribute in the input string, from an XMLNode.
- Parameters
-
| node | Node containing the attribute. |
| attributeName | Name of the attribute. |
- Returns
- std::optional<size_t> Offset of the element's attribute in the input string.
◆ lineOffset()
| size_t donner::svg::parser::SVGParserContext::lineOffset |
( |
size_t | line | ) |
const |
|
inline |
Returns the offset of a given 1-indexed line number.
- Parameters
-
| line | Line number, 1-indexed. |
◆ offsetToLine()
| 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.
◆ parserOriginFrom()
| ParserOrigin donner::svg::parser::SVGParserContext::parserOriginFrom |
( |
std::string_view | substring | ) |
const |
|
inline |
Create a ParserOrigin for the given substring, where substring is within the XML parser's original string, input_.
- Parameters
-
| substring | Substring within the XML parser's original string. |
◆ setNamespacePrefix()
| void donner::svg::parser::SVGParserContext::setNamespacePrefix |
( |
const RcString & | namespacePrefix | ) |
|
|
inline |
Set the XML document's default namespace prefix, such as "http://www.w3.org/2000/svg".
- Parameters
-
| namespacePrefix | The default namespace prefix, such as "http://www.w3.org/2000/svg". |
The documentation for this class was generated from the following file:
- donner/svg/parser/details/SVGParserContext.h