QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
qgsabstractcontentcache.cpp
Go to the documentation of this file.
1/***************************************************************************
2 QgsAbstractContentCache.cpp
3 -----------------
4 begin : December 2018
5 copyright : (C) 2018 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
20#include <QRegularExpression>
21
22//
23// QgsAbstractContentCacheEntry
24//
25
27 : path( path )
28{
29}
30
31//
32// QgsAbstractContentCacheBase
33//
34
36 : QObject( parent )
37{}
38
39
41{
42
43}
44
45bool QgsAbstractContentCacheBase::parseBase64DataUrl( const QString &path, QString *mimeType, QString *data )
46{
47 const thread_local QRegularExpression sRx( QStringLiteral( "^data:(.*/.*?);?(?:base64)?,(.*)$" ) );
48 const QRegularExpressionMatch base64Match = sRx.match( path );
49 if ( !base64Match.hasMatch() )
50 return false;
51
52 if ( mimeType )
53 *mimeType = base64Match.captured( 1 );
54 if ( data )
55 *data = base64Match.captured( 2 );
56 return true;
57}
58
60{
61 return path.startsWith( QLatin1String( "base64:" ) )
62 || parseBase64DataUrl( path );
63}
virtual void onRemoteContentFetched(const QString &url, bool success)
Triggered after remote content (i.e.
static bool parseBase64DataUrl(const QString &path, QString *mimeType=nullptr, QString *data=nullptr)
Parses a path to determine if it represents a base 64 encoded HTML data URL, and if so,...
QgsAbstractContentCacheBase(QObject *parent)
Constructor for QgsAbstractContentCacheBase, with the specified parent object.
static bool isBase64Data(const QString &path)
Returns true if path represents base64 encoded data.
QgsAbstractContentCacheEntry(const QString &path)
Constructor for QgsAbstractContentCacheEntry for an entry relating to the specified path.