Class TDataURI

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TDataURI = class(TObject)

Description

Reading data URI scheme, see http://en.wikipedia.org/wiki/Data_URI_scheme. Such URI specifies the MIME type and contains the data, encoded in plain text or base64. That is, the data is not merely referenced / linked (like with a usual URL), it's simply fully encoded inside the URI. Since such URI can be used anywhere a normal URI is expected, it allows you to inline any kind of data inside any container file. For example, you can place images (textures) and such directly inside a VRML/X3D file.

Hierarchy

  • TObject
  • TDataURI

Overview

Methods

Public destructor Destroy; override;
Public class function IsDataURI(const URI: string; out Colon: Integer): boolean;
Public class function IsDataURI(const URI: string): boolean;
Public function Stream: TStream;

Properties

Public property URI: string read FURI write SetURI;
Public property Valid: boolean read FValid;
Public property Mime: string read FMime;
Public property Base64: boolean read FBase64;
Public property Charset: string read FCharset;
Public property URIPrefix: string read FURIPrefix;

Description

Methods

Public destructor Destroy; override;
 
Public class function IsDataURI(const URI: string; out Colon: Integer): boolean;
 
Public class function IsDataURI(const URI: string): boolean;
 
Public function Stream: TStream;

Read the actual data contents. If the URI is not valid (includes the initial state when it's not set) then returns Nil.

The important property of this reader is that the no expensive encoding is done until you call this method. In particular, you can set URI, check Mime, and if you see that Mime is something not interesting for you (for example, maybe you require some image mime-type) just don't call this method. Then nothing expensive will happen, e.g. data will not be base64-decoded without a need.

Properties

Public property URI: string read FURI write SetURI;

The data URI that this class reads.

When you set this, we read the beginning of URI. If this is a valid data URI, then we set Valid to True, update Mime, Base64, Charset, URIPrefix accordingly, and you can call Stream if you want to read actual contents.

If this is not a valid data URI, then we set Valid to False, make appropriate warning through OnWarning, and reset Mime, Base64, Charset, URIPrefix to some default values.

Public property Valid: boolean read FValid;
 
Public property Mime: string read FMime;
 
Public property Base64: boolean read FBase64;
 
Public property Charset: string read FCharset;
 
Public property URIPrefix: string read FURIPrefix;
 

Generated by PasDoc 0.12.1 on 2013-02-04 20:26:50