2017-01-27 17:37:51 +02:00
|
|
|
// ************************************************************************
|
|
|
|
// ***************************** CEF4Delphi *******************************
|
|
|
|
// ************************************************************************
|
|
|
|
//
|
|
|
|
// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based
|
|
|
|
// browser in Delphi applications.
|
|
|
|
//
|
|
|
|
// The original license of DCEF3 still applies to CEF4Delphi.
|
|
|
|
//
|
|
|
|
// For more information about CEF4Delphi visit :
|
|
|
|
// https://www.briskbard.com/index.php?lang=en&pageid=cef
|
|
|
|
//
|
2018-01-06 16:25:32 +02:00
|
|
|
// Copyright � 2018 Salvador D�az Fau. All rights reserved.
|
2017-01-27 17:37:51 +02:00
|
|
|
//
|
|
|
|
// ************************************************************************
|
|
|
|
// ************ vvvv Original license and comments below vvvv *************
|
|
|
|
// ************************************************************************
|
|
|
|
(*
|
|
|
|
* Delphi Chromium Embedded 3
|
|
|
|
*
|
|
|
|
* Usage allowed under the restrictions of the Lesser GNU General Public License
|
|
|
|
* or alternatively the restrictions of the Mozilla Public License 1.1
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
|
|
|
* the specific language governing rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
|
|
|
|
* Web site : http://www.progdigy.com
|
|
|
|
* Repository : http://code.google.com/p/delphichromiumembedded/
|
|
|
|
* Group : http://groups.google.com/group/delphichromiumembedded
|
|
|
|
*
|
|
|
|
* Embarcadero Technologies, Inc is not permitted to use or redistribute
|
|
|
|
* this source code without explicit permission.
|
|
|
|
*
|
|
|
|
*)
|
|
|
|
|
|
|
|
unit uCEFValue;
|
|
|
|
|
|
|
|
{$IFNDEF CPUX64}
|
|
|
|
{$ALIGN ON}
|
|
|
|
{$MINENUMSIZE 4}
|
|
|
|
{$ENDIF}
|
|
|
|
|
2017-02-05 21:56:46 +02:00
|
|
|
{$I cef.inc}
|
|
|
|
|
2017-01-27 17:37:51 +02:00
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2017-03-16 20:09:42 +02:00
|
|
|
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
|
2017-01-27 17:37:51 +02:00
|
|
|
|
|
|
|
type
|
2017-03-16 20:09:42 +02:00
|
|
|
TCefValueRef = class(TCefBaseRefCountedRef, ICefValue)
|
2017-01-27 17:37:51 +02:00
|
|
|
protected
|
|
|
|
function IsValid: Boolean;
|
|
|
|
function IsOwned: Boolean;
|
|
|
|
function IsReadOnly: Boolean;
|
|
|
|
function IsSame(const that: ICefValue): Boolean;
|
|
|
|
function IsEqual(const that: ICefValue): Boolean;
|
|
|
|
function Copy: ICefValue;
|
|
|
|
function GetType: TCefValueType;
|
|
|
|
function GetBool: Boolean;
|
|
|
|
function GetInt: Integer;
|
|
|
|
function GetDouble: Double;
|
|
|
|
function GetString: ustring;
|
|
|
|
function GetBinary: ICefBinaryValue;
|
|
|
|
function GetDictionary: ICefDictionaryValue;
|
|
|
|
function GetList: ICefListValue;
|
|
|
|
function SetNull: Boolean;
|
|
|
|
function SetBool(value: Integer): Boolean;
|
|
|
|
function SetInt(value: Integer): Boolean;
|
|
|
|
function SetDouble(value: Double): Boolean;
|
|
|
|
function SetString(const value: ustring): Boolean;
|
|
|
|
function SetBinary(const value: ICefBinaryValue): Boolean;
|
|
|
|
function SetDictionary(const value: ICefDictionaryValue): Boolean;
|
|
|
|
function SetList(const value: ICefListValue): Boolean;
|
|
|
|
|
|
|
|
public
|
|
|
|
class function UnWrap(data: Pointer): ICefValue;
|
|
|
|
class function New: ICefValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
|
|
|
uCEFMiscFunctions, uCEFLibFunctions, uCEFBinaryValue, uCEFListValue, uCEFDictionaryValue;
|
|
|
|
|
|
|
|
function TCefValueRef.Copy: ICefValue;
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := UnWrap(PCefValue(FData).copy(PCefValue(FData)));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefValueRef.GetBinary: ICefBinaryValue;
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := TCefBinaryValueRef.UnWrap(PCefValue(FData).get_binary(PCefValue(FData)));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefValueRef.GetBool: Boolean;
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := PCefValue(FData).get_bool(PCefValue(FData)) <> 0;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefValueRef.GetDictionary: ICefDictionaryValue;
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := TCefDictionaryValueRef.UnWrap(PCefValue(FData).get_dictionary(PCefValue(FData)));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefValueRef.GetDouble: Double;
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := PCefValue(FData).get_double(PCefValue(FData));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefValueRef.GetInt: Integer;
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := PCefValue(FData).get_int(PCefValue(FData));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefValueRef.GetList: ICefListValue;
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := TCefListValueRef.UnWrap(PCefValue(FData).get_list(PCefValue(FData)));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefValueRef.GetString: ustring;
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := CefStringFreeAndGet(PCefValue(FData).get_string(PCefValue(FData)));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefValueRef.GetType: TCefValueType;
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := PCefValue(FData).get_type(PCefValue(FData));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefValueRef.IsEqual(const that: ICefValue): Boolean;
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := PCefValue(FData).is_equal(PCefValue(FData), CefGetData(that)) <> 0;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefValueRef.IsOwned: Boolean;
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := PCefValue(FData).is_owned(PCefValue(FData)) <> 0;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefValueRef.IsReadOnly: Boolean;
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := PCefValue(FData).is_read_only(PCefValue(FData)) <> 0;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefValueRef.IsSame(const that: ICefValue): Boolean;
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := PCefValue(FData).is_same(PCefValue(FData), CefGetData(that)) <> 0;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefValueRef.IsValid: Boolean;
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := PCefValue(FData).is_valid(PCefValue(FData)) <> 0;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
class function TCefValueRef.New: ICefValue;
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := UnWrap(cef_value_create);
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefValueRef.SetBinary(const value: ICefBinaryValue): Boolean;
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := PCefValue(FData).set_binary(PCefValue(FData), CefGetData(value)) <> 0;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefValueRef.SetBool(value: Integer): Boolean;
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := PCefValue(FData).set_bool(PCefValue(FData), value) <> 0;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefValueRef.SetDictionary(const value: ICefDictionaryValue): Boolean;
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := PCefValue(FData).set_dictionary(PCefValue(FData), CefGetData(value)) <> 0;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefValueRef.SetDouble(value: Double): Boolean;
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := PCefValue(FData).set_double(PCefValue(FData), value) <> 0;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefValueRef.SetInt(value: Integer): Boolean;
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := PCefValue(FData).set_int(PCefValue(FData), value) <> 0;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefValueRef.SetList(const value: ICefListValue): Boolean;
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := PCefValue(FData).set_list(PCefValue(FData), CefGetData(value)) <> 0;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefValueRef.SetNull: Boolean;
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := PCefValue(FData).set_null(PCefValue(FData)) <> 0;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefValueRef.SetString(const value: ustring): Boolean;
|
|
|
|
var
|
2018-03-29 20:02:04 +02:00
|
|
|
TempValue : TCefString;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
TempValue := CefString(value);
|
|
|
|
Result := PCefValue(FData).set_string(PCefValue(FData), @TempValue) <> 0;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
class function TCefValueRef.UnWrap(data: Pointer): ICefValue;
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
if (data <> nil) then
|
|
|
|
Result := Create(data) as ICefValue
|
|
|
|
else
|
2017-01-27 17:37:51 +02:00
|
|
|
Result := nil;
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|