2017-01-27 16:37:51 +01:00
|
|
|
unit uCEFListValue;
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
{$IFDEF FPC}
|
|
|
|
{$MODE OBJFPC}{$H+}
|
|
|
|
{$ENDIF}
|
|
|
|
|
2017-02-05 20:56:46 +01:00
|
|
|
{$I cef.inc}
|
|
|
|
|
2022-02-19 18:56:41 +01:00
|
|
|
{$IFNDEF TARGET_64BITS}{$ALIGN ON}{$ENDIF}
|
|
|
|
{$MINENUMSIZE 4}
|
|
|
|
|
2017-01-27 16:37:51 +01:00
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2017-03-16 19:09:42 +01:00
|
|
|
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
|
2017-01-27 16:37:51 +01:00
|
|
|
|
|
|
|
type
|
2017-03-16 19:09:42 +01:00
|
|
|
TCefListValueRef = class(TCefBaseRefCountedRef, ICefListValue)
|
2017-01-27 16:37:51 +01:00
|
|
|
protected
|
|
|
|
function IsValid: Boolean;
|
|
|
|
function IsOwned: Boolean;
|
|
|
|
function IsReadOnly: Boolean;
|
|
|
|
function IsSame(const that: ICefListValue): Boolean;
|
|
|
|
function IsEqual(const that: ICefListValue): Boolean;
|
|
|
|
function Copy: ICefListValue;
|
|
|
|
function SetSize(size: NativeUInt): Boolean;
|
|
|
|
function GetSize: NativeUInt;
|
|
|
|
function Clear: Boolean;
|
|
|
|
function Remove(index: NativeUInt): Boolean;
|
|
|
|
function GetType(index: NativeUInt): TCefValueType;
|
|
|
|
function GetValue(index: NativeUInt): ICefValue;
|
|
|
|
function GetBool(index: NativeUInt): Boolean;
|
|
|
|
function GetInt(index: NativeUInt): Integer;
|
|
|
|
function GetDouble(index: NativeUInt): Double;
|
|
|
|
function GetString(index: NativeUInt): ustring;
|
|
|
|
function GetBinary(index: NativeUInt): ICefBinaryValue;
|
|
|
|
function GetDictionary(index: NativeUInt): ICefDictionaryValue;
|
|
|
|
function GetList(index: NativeUInt): ICefListValue;
|
|
|
|
function SetValue(index: NativeUInt; const value: ICefValue): Boolean;
|
|
|
|
function SetNull(index: NativeUInt): Boolean;
|
|
|
|
function SetBool(index: NativeUInt; value: Boolean): Boolean;
|
|
|
|
function SetInt(index: NativeUInt; value: Integer): Boolean;
|
|
|
|
function SetDouble(index: NativeUInt; value: Double): Boolean;
|
|
|
|
function SetString(index: NativeUInt; const value: ustring): Boolean;
|
|
|
|
function SetBinary(index: NativeUInt; const value: ICefBinaryValue): Boolean;
|
|
|
|
function SetDictionary(index: NativeUInt; const value: ICefDictionaryValue): Boolean;
|
|
|
|
function SetList(index: NativeUInt; const value: ICefListValue): Boolean;
|
|
|
|
|
|
|
|
public
|
|
|
|
class function UnWrap(data: Pointer): ICefListValue;
|
|
|
|
class function New: ICefListValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
|
|
|
uCEFMiscFunctions, uCEFLibFunctions, uCEFBinaryValue, uCEFValue, uCEFDictionaryValue;
|
|
|
|
|
|
|
|
function TCefListValueRef.Clear: Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefListValue(FData)^.clear(PCefListValue(FData)) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefListValueRef.Copy: ICefListValue;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := UnWrap(PCefListValue(FData)^.copy(PCefListValue(FData)));
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
class function TCefListValueRef.New: ICefListValue;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := UnWrap(cef_list_value_create());
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefListValueRef.GetBinary(index: NativeUInt): ICefBinaryValue;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := TCefBinaryValueRef.UnWrap(PCefListValue(FData)^.get_binary(PCefListValue(FData), index));
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefListValueRef.GetBool(index: NativeUInt): Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefListValue(FData)^.get_bool(PCefListValue(FData), index) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefListValueRef.GetDictionary(index: NativeUInt): ICefDictionaryValue;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := TCefDictionaryValueRef.UnWrap(PCefListValue(FData)^.get_dictionary(PCefListValue(FData), index));
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefListValueRef.GetDouble(index: NativeUInt): Double;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefListValue(FData)^.get_double(PCefListValue(FData), index);
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefListValueRef.GetInt(index: NativeUInt): Integer;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefListValue(FData)^.get_int(PCefListValue(FData), index);
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefListValueRef.GetList(index: NativeUInt): ICefListValue;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := UnWrap(PCefListValue(FData)^.get_list(PCefListValue(FData), index));
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefListValueRef.GetSize: NativeUInt;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefListValue(FData)^.get_size(PCefListValue(FData));
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefListValueRef.GetString(index: NativeUInt): ustring;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := CefStringFreeAndGet(PCefListValue(FData)^.get_string(PCefListValue(FData), index));
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefListValueRef.GetType(index: NativeUInt): TCefValueType;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefListValue(FData)^.get_type(PCefListValue(FData), index);
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefListValueRef.GetValue(index: NativeUInt): ICefValue;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := TCefValueRef.UnWrap(PCefListValue(FData)^.get_value(PCefListValue(FData), index));
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefListValueRef.IsEqual(const that: ICefListValue): Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefListValue(FData)^.is_equal(PCefListValue(FData), CefGetData(that)) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefListValueRef.IsOwned: Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefListValue(FData)^.is_owned(PCefListValue(FData)) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefListValueRef.IsReadOnly: Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefListValue(FData)^.is_read_only(PCefListValue(FData)) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefListValueRef.IsSame(const that: ICefListValue): Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefListValue(FData)^.is_same(PCefListValue(FData), CefGetData(that)) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefListValueRef.IsValid: Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefListValue(FData)^.is_valid(PCefListValue(FData)) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefListValueRef.Remove(index: NativeUInt): Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefListValue(FData)^.remove(PCefListValue(FData), index) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefListValueRef.SetBinary(index: NativeUInt; const value: ICefBinaryValue): Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefListValue(FData)^.set_binary(PCefListValue(FData), index, CefGetData(value)) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefListValueRef.SetBool(index: NativeUInt; value: Boolean): Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefListValue(FData)^.set_bool(PCefListValue(FData), index, Ord(value)) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefListValueRef.SetDictionary(index: NativeUInt; const value: ICefDictionaryValue): Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefListValue(FData)^.set_dictionary(PCefListValue(FData), index, CefGetData(value)) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefListValueRef.SetDouble(index: NativeUInt; value: Double): Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefListValue(FData)^.set_double(PCefListValue(FData), index, value) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefListValueRef.SetInt(index: NativeUInt; value: Integer): Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefListValue(FData)^.set_int(PCefListValue(FData), index, value) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefListValueRef.SetList(index: NativeUInt; const value: ICefListValue): Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefListValue(FData)^.set_list(PCefListValue(FData), index, CefGetData(value)) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefListValueRef.SetNull(index: NativeUInt): Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefListValue(FData)^.set_null(PCefListValue(FData), index) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefListValueRef.SetSize(size: NativeUInt): Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefListValue(FData)^.set_size(PCefListValue(FData), size) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefListValueRef.SetString(index: NativeUInt; const value: ustring): Boolean;
|
|
|
|
var
|
2018-05-12 14:50:54 +02:00
|
|
|
TempValue : TCefString;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
TempValue := CefString(value);
|
|
|
|
Result := PCefListValue(FData)^.set_string(PCefListValue(FData), index, @TempValue) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefListValueRef.SetValue(index: NativeUInt; const value: ICefValue): Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefListValue(FData)^.set_value(PCefListValue(FData), index, CefGetData(value)) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
class function TCefListValueRef.UnWrap(data: Pointer): ICefListValue;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
if (data <> nil) then
|
|
|
|
Result := Create(data) as ICefListValue
|
|
|
|
else
|
2017-01-27 16:37:51 +01:00
|
|
|
Result := nil;
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|