Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
uri.h File Reference

URI functions as per 4.3.4 of CSS 2.1 http://www.w3.org/TR/CSS21/syndata.html#uri. More...

Go to the source code of this file.

Enumerations

enum class  Base64Data { NONE , RASTER , SVG }
 

Functions

std::string extract_uri (char const *s, char const **endptr=nullptr)
 Parse functional URI notation, as per 4.3.4 of CSS 2.1.
 
std::optional< std::string > try_extract_uri (const char *url)
 Try extracting URI from "url(xyz)" string using extract_uri.
 
std::optional< std::string > try_extract_uri_id (const char *url)
 Try extracting the object id from "url(#obj_id)" string using extract_uri.
 
std::tuple< char const *, Base64Dataextract_uri_data (char const *uri_data)
 Attempt to extract the data in a data uri, but does not decode the base64.
 

Detailed Description

URI functions as per 4.3.4 of CSS 2.1 http://www.w3.org/TR/CSS21/syndata.html#uri.

Definition in file uri.h.

Enumeration Type Documentation

◆ Base64Data

enum class Base64Data
strong
Enumerator
NONE 
RASTER 
SVG 

Definition at line 18 of file uri.h.

Function Documentation

◆ extract_uri()

std::string extract_uri ( char const *  s,
char const **  endptr = nullptr 
)

Parse functional URI notation, as per 4.3.4 of CSS 2.1.

http://www.w3.org/TR/CSS21/syndata.html#uri

‍The format of a URI value is 'url(' followed by optional white space followed by an optional single quote (') or double quote (") character followed by the URI itself, followed by an optional single quote (') or double quote (") character followed by optional white space followed by ')'. The two quote characters must be the same.

Example:

url = extract_uri("url('foo')bar", &out);
-> url == "foo"
-> out == "bar"
Parameters
sString which starts with "url("
[out]endptrpoints to s + N, where N is the number of characters parsed or to a nullptr when an invalid URL is found
Returns
URL string, or empty string on failure

Definition at line 19 of file uri.cpp.

References result.

Referenced by Inkscape::LivePathEffect::LPEPowerMask::doBeforeEffect(), find_references(), SPIShapes::read(), SPIPaint::read(), SPIFilter::read(), SPItem::set(), sp_css_uri_reference_resolve(), and try_extract_uri().

◆ extract_uri_data()

std::tuple< char const *, Base64Data > extract_uri_data ( char const *  uri_data)

Attempt to extract the data in a data uri, but does not decode the base64.

Parameters
uri_datapointer to the uri data encoded in base64
base64_typethe detected base64 type based on the mime-type.
Returns
The same uri_data pointer advanced to just after the uri components.

Definition at line 117 of file uri.cpp.

References data, NONE, RASTER, and SVG.

Referenced by Inkscape::Pixbuf::create_from_data_uri(), and Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_raster().

◆ try_extract_uri()

std::optional< std::string > try_extract_uri ( const char *  url)

Try extracting URI from "url(xyz)" string using extract_uri.

Parameters
urlstring input that may or may not be a link
Returns
Extracted non-empty link or no value if provided input is not an URI

Definition at line 102 of file uri.cpp.

References extract_uri().

Referenced by copy_style_links(), and try_extract_uri_id().

◆ try_extract_uri_id()

std::optional< std::string > try_extract_uri_id ( const char *  url)

Try extracting the object id from "url(#obj_id)" string using extract_uri.

Parameters
urlstring input that may or may not be a link
Returns
Extracted non-empty objectid or no value if provided input is not an URI or not an id

Definition at line 107 of file uri.cpp.

References try_extract_uri().

Referenced by Inkscape::Extension::Internal::SvgBuilder::_getGradientNode(), and Inkscape::Extension::Internal::SvgBuilder::popGroup().