mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
- Add CefValue for wrapping various value types in a single object (issue #1607).
- Add IsSame() and IsEqual() methods for comparing CefValue* types. - Improve CefValue* documentation.
This commit is contained in:
@@ -41,11 +41,195 @@
|
||||
#include <vector>
|
||||
#include "include/cef_base.h"
|
||||
|
||||
class CefBinaryValue;
|
||||
class CefDictionaryValue;
|
||||
class CefListValue;
|
||||
|
||||
typedef cef_value_type_t CefValueType;
|
||||
|
||||
///
|
||||
// Class that wraps other data value types. Complex types (binary, dictionary
|
||||
// and list) will be referenced but not owned by this object. Can be used on any
|
||||
// process and thread.
|
||||
///
|
||||
/*--cef(source=library)--*/
|
||||
class CefValue : public virtual CefBase {
|
||||
public:
|
||||
///
|
||||
// Creates a new object.
|
||||
///
|
||||
/*--cef()--*/
|
||||
static CefRefPtr<CefValue> Create();
|
||||
|
||||
///
|
||||
// Returns true if the underlying data is valid. This will always be true for
|
||||
// simple types. For complex types (binary, dictionary and list) the
|
||||
// underlying data may become invalid if owned by another object (e.g. list or
|
||||
// dictionary) and that other object is then modified or destroyed. This value
|
||||
// object can be re-used by calling Set*() even if the underlying data is
|
||||
// invalid.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsValid() =0;
|
||||
|
||||
///
|
||||
// Returns true if the underlying data is owned by another object.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsOwned() =0;
|
||||
|
||||
///
|
||||
// Returns true if the underlying data is read-only. Some APIs may expose
|
||||
// read-only objects.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsReadOnly() =0;
|
||||
|
||||
///
|
||||
// Returns true if this object and |that| object have the same underlying
|
||||
// data. If true modifications to this object will also affect |that| object
|
||||
// and vice-versa.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsSame(CefRefPtr<CefValue> that) =0;
|
||||
|
||||
///
|
||||
// Returns true if this object and |that| object have an equivalent underlying
|
||||
// value but are not necessarily the same object.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsEqual(CefRefPtr<CefValue> that) =0;
|
||||
|
||||
///
|
||||
// Returns a copy of this object. The underlying data will also be copied.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefValue> Copy() =0;
|
||||
|
||||
///
|
||||
// Returns the underlying value type.
|
||||
///
|
||||
/*--cef(default_retval=VTYPE_INVALID)--*/
|
||||
virtual CefValueType GetType() =0;
|
||||
|
||||
///
|
||||
// Returns the underlying value as type bool.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool GetBool() =0;
|
||||
|
||||
///
|
||||
// Returns the underlying value as type int.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual int GetInt() =0;
|
||||
|
||||
///
|
||||
// Returns the underlying value as type double.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual double GetDouble() =0;
|
||||
|
||||
///
|
||||
// Returns the underlying value as type string.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefString GetString() =0;
|
||||
|
||||
///
|
||||
// Returns the underlying value as type binary. The returned reference may
|
||||
// become invalid if the value is owned by another object or if ownership is
|
||||
// transferred to another object in the future. To maintain a reference to
|
||||
// the value after assigning ownership to a dictionary or list pass this
|
||||
// object to the SetValue() method instead of passing the returned reference
|
||||
// to SetBinary().
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefBinaryValue> GetBinary() =0;
|
||||
|
||||
///
|
||||
// Returns the underlying value as type dictionary. The returned reference may
|
||||
// become invalid if the value is owned by another object or if ownership is
|
||||
// transferred to another object in the future. To maintain a reference to
|
||||
// the value after assigning ownership to a dictionary or list pass this
|
||||
// object to the SetValue() method instead of passing the returned reference
|
||||
// to SetDictionary().
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefDictionaryValue> GetDictionary() =0;
|
||||
|
||||
///
|
||||
// Returns the underlying value as type list. The returned reference may
|
||||
// become invalid if the value is owned by another object or if ownership is
|
||||
// transferred to another object in the future. To maintain a reference to
|
||||
// the value after assigning ownership to a dictionary or list pass this
|
||||
// object to the SetValue() method instead of passing the returned reference
|
||||
// to SetList().
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefListValue> GetList() =0;
|
||||
|
||||
///
|
||||
// Sets the underlying value as type null. Returns true if the value was set
|
||||
// successfully.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool SetNull() =0;
|
||||
|
||||
///
|
||||
// Sets the underlying value as type bool. Returns true if the value was set
|
||||
// successfully.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool SetBool(bool value) =0;
|
||||
|
||||
///
|
||||
// Sets the underlying value as type int. Returns true if the value was set
|
||||
// successfully.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool SetInt(int value) =0;
|
||||
|
||||
///
|
||||
// Sets the underlying value as type double. Returns true if the value was set
|
||||
// successfully.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool SetDouble(double value) =0;
|
||||
|
||||
///
|
||||
// Sets the underlying value as type string. Returns true if the value was set
|
||||
// successfully.
|
||||
///
|
||||
/*--cef(optional_param=value)--*/
|
||||
virtual bool SetString(const CefString& value) =0;
|
||||
|
||||
///
|
||||
// Sets the underlying value as type binary. Returns true if the value was set
|
||||
// successfully. This object keeps a reference to |value| and ownership of the
|
||||
// underlying data remains unchanged.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool SetBinary(CefRefPtr<CefBinaryValue> value) =0;
|
||||
|
||||
///
|
||||
// Sets the underlying value as type dict. Returns true if the value was set
|
||||
// successfully. This object keeps a reference to |value| and ownership of the
|
||||
// underlying data remains unchanged.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool SetDictionary(CefRefPtr<CefDictionaryValue> value) =0;
|
||||
|
||||
///
|
||||
// Sets the underlying value as type list. Returns true if the value was set
|
||||
// successfully. This object keeps a reference to |value| and ownership of the
|
||||
// underlying data remains unchanged.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool SetList(CefRefPtr<CefListValue> value) =0;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
// Class representing a binary value. Can be used on any process and thread.
|
||||
///
|
||||
@@ -61,8 +245,10 @@ class CefBinaryValue : public virtual CefBase {
|
||||
size_t data_size);
|
||||
|
||||
///
|
||||
// Returns true if this object is valid. Do not call any other methods if this
|
||||
// method returns false.
|
||||
// Returns true if this object is valid. This object may become invalid if
|
||||
// the underlying data is owned by another object (e.g. list or dictionary)
|
||||
// and that other object is then modified or destroyed. Do not call any other
|
||||
// methods if this method returns false.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsValid() =0;
|
||||
@@ -73,6 +259,20 @@ class CefBinaryValue : public virtual CefBase {
|
||||
/*--cef()--*/
|
||||
virtual bool IsOwned() =0;
|
||||
|
||||
///
|
||||
// Returns true if this object and |that| object have the same underlying
|
||||
// data.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsSame(CefRefPtr<CefBinaryValue> that) =0;
|
||||
|
||||
///
|
||||
// Returns true if this object and |that| object have an equivalent underlying
|
||||
// value but are not necessarily the same object.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsEqual(CefRefPtr<CefBinaryValue> that) =0;
|
||||
|
||||
///
|
||||
// Returns a copy of this object. The data in this object will also be copied.
|
||||
///
|
||||
@@ -111,8 +311,10 @@ class CefDictionaryValue : public virtual CefBase {
|
||||
static CefRefPtr<CefDictionaryValue> Create();
|
||||
|
||||
///
|
||||
// Returns true if this object is valid. Do not call any other methods if this
|
||||
// method returns false.
|
||||
// Returns true if this object is valid. This object may become invalid if
|
||||
// the underlying data is owned by another object (e.g. list or dictionary)
|
||||
// and that other object is then modified or destroyed. Do not call any other
|
||||
// methods if this method returns false.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsValid() =0;
|
||||
@@ -130,6 +332,21 @@ class CefDictionaryValue : public virtual CefBase {
|
||||
/*--cef()--*/
|
||||
virtual bool IsReadOnly() =0;
|
||||
|
||||
///
|
||||
// Returns true if this object and |that| object have the same underlying
|
||||
// data. If true modifications to this object will also affect |that| object
|
||||
// and vice-versa.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsSame(CefRefPtr<CefDictionaryValue> that) =0;
|
||||
|
||||
///
|
||||
// Returns true if this object and |that| object have an equivalent underlying
|
||||
// value but are not necessarily the same object.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsEqual(CefRefPtr<CefDictionaryValue> that) =0;
|
||||
|
||||
///
|
||||
// Returns a writable copy of this object. If |exclude_empty_children| is true
|
||||
// any empty dictionaries or lists will be excluded from the copy.
|
||||
@@ -174,6 +391,16 @@ class CefDictionaryValue : public virtual CefBase {
|
||||
/*--cef(default_retval=VTYPE_INVALID)--*/
|
||||
virtual CefValueType GetType(const CefString& key) =0;
|
||||
|
||||
///
|
||||
// Returns the value at the specified key. For simple types the returned
|
||||
// value will copy existing data and modifications to the value will not
|
||||
// modify this object. For complex types (binary, dictionary and list) the
|
||||
// returned value will reference existing data and modifications to the value
|
||||
// will modify this object.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefValue> GetValue(const CefString& key) =0;
|
||||
|
||||
///
|
||||
// Returns the value at the specified key as type bool.
|
||||
///
|
||||
@@ -199,23 +426,39 @@ class CefDictionaryValue : public virtual CefBase {
|
||||
virtual CefString GetString(const CefString& key) =0;
|
||||
|
||||
///
|
||||
// Returns the value at the specified key as type binary.
|
||||
// Returns the value at the specified key as type binary. The returned
|
||||
// value will reference existing data.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefBinaryValue> GetBinary(const CefString& key) =0;
|
||||
|
||||
///
|
||||
// Returns the value at the specified key as type dictionary.
|
||||
// Returns the value at the specified key as type dictionary. The returned
|
||||
// value will reference existing data and modifications to the value will
|
||||
// modify this object.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefDictionaryValue> GetDictionary(const CefString& key) =0;
|
||||
|
||||
///
|
||||
// Returns the value at the specified key as type list.
|
||||
// Returns the value at the specified key as type list. The returned value
|
||||
// will reference existing data and modifications to the value will modify
|
||||
// this object.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefListValue> GetList(const CefString& key) =0;
|
||||
|
||||
///
|
||||
// Sets the value at the specified key. Returns true if the value was set
|
||||
// successfully. If |value| represents simple data then the underlying data
|
||||
// will be copied and modifications to |value| will not modify this object. If
|
||||
// |value| represents complex data (binary, dictionary or list) then the
|
||||
// underlying data will be referenced and modifications to |value| will modify
|
||||
// this object.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool SetValue(const CefString& key, CefRefPtr<CefValue> value) =0;
|
||||
|
||||
///
|
||||
// Sets the value at the specified key as type null. Returns true if the
|
||||
// value was set successfully.
|
||||
@@ -264,8 +507,7 @@ class CefDictionaryValue : public virtual CefBase {
|
||||
|
||||
///
|
||||
// Sets the value at the specified key as type dict. Returns true if the
|
||||
// value was set successfully. After calling this method the |value| object
|
||||
// will no longer be valid. If |value| is currently owned by another object
|
||||
// value was set successfully. If |value| is currently owned by another object
|
||||
// then the value will be copied and the |value| reference will not change.
|
||||
// Otherwise, ownership will be transferred to this object and the |value|
|
||||
// reference will be invalidated.
|
||||
@@ -276,8 +518,7 @@ class CefDictionaryValue : public virtual CefBase {
|
||||
|
||||
///
|
||||
// Sets the value at the specified key as type list. Returns true if the
|
||||
// value was set successfully. After calling this method the |value| object
|
||||
// will no longer be valid. If |value| is currently owned by another object
|
||||
// value was set successfully. If |value| is currently owned by another object
|
||||
// then the value will be copied and the |value| reference will not change.
|
||||
// Otherwise, ownership will be transferred to this object and the |value|
|
||||
// reference will be invalidated.
|
||||
@@ -301,8 +542,10 @@ class CefListValue : public virtual CefBase {
|
||||
static CefRefPtr<CefListValue> Create();
|
||||
|
||||
///
|
||||
// Returns true if this object is valid. Do not call any other methods if this
|
||||
// method returns false.
|
||||
// Returns true if this object is valid. This object may become invalid if
|
||||
// the underlying data is owned by another object (e.g. list or dictionary)
|
||||
// and that other object is then modified or destroyed. Do not call any other
|
||||
// methods if this method returns false.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsValid() =0;
|
||||
@@ -320,6 +563,21 @@ class CefListValue : public virtual CefBase {
|
||||
/*--cef()--*/
|
||||
virtual bool IsReadOnly() =0;
|
||||
|
||||
///
|
||||
// Returns true if this object and |that| object have the same underlying
|
||||
// data. If true modifications to this object will also affect |that| object
|
||||
// and vice-versa.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsSame(CefRefPtr<CefListValue> that) =0;
|
||||
|
||||
///
|
||||
// Returns true if this object and |that| object have an equivalent underlying
|
||||
// value but are not necessarily the same object.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsEqual(CefRefPtr<CefListValue> that) =0;
|
||||
|
||||
///
|
||||
// Returns a writable copy of this object.
|
||||
///
|
||||
@@ -357,6 +615,16 @@ class CefListValue : public virtual CefBase {
|
||||
/*--cef(default_retval=VTYPE_INVALID,index_param=index)--*/
|
||||
virtual CefValueType GetType(int index) =0;
|
||||
|
||||
///
|
||||
// Returns the value at the specified index. For simple types the returned
|
||||
// value will copy existing data and modifications to the value will not
|
||||
// modify this object. For complex types (binary, dictionary and list) the
|
||||
// returned value will reference existing data and modifications to the value
|
||||
// will modify this object.
|
||||
///
|
||||
/*--cef(index_param=index)--*/
|
||||
virtual CefRefPtr<CefValue> GetValue(int index) =0;
|
||||
|
||||
///
|
||||
// Returns the value at the specified index as type bool.
|
||||
///
|
||||
@@ -382,23 +650,39 @@ class CefListValue : public virtual CefBase {
|
||||
virtual CefString GetString(int index) =0;
|
||||
|
||||
///
|
||||
// Returns the value at the specified index as type binary.
|
||||
// Returns the value at the specified index as type binary. The returned
|
||||
// value will reference existing data.
|
||||
///
|
||||
/*--cef(index_param=index)--*/
|
||||
virtual CefRefPtr<CefBinaryValue> GetBinary(int index) =0;
|
||||
|
||||
///
|
||||
// Returns the value at the specified index as type dictionary.
|
||||
// Returns the value at the specified index as type dictionary. The returned
|
||||
// value will reference existing data and modifications to the value will
|
||||
// modify this object.
|
||||
///
|
||||
/*--cef(index_param=index)--*/
|
||||
virtual CefRefPtr<CefDictionaryValue> GetDictionary(int index) =0;
|
||||
|
||||
///
|
||||
// Returns the value at the specified index as type list.
|
||||
// Returns the value at the specified index as type list. The returned
|
||||
// value will reference existing data and modifications to the value will
|
||||
// modify this object.
|
||||
///
|
||||
/*--cef(index_param=index)--*/
|
||||
virtual CefRefPtr<CefListValue> GetList(int index) =0;
|
||||
|
||||
///
|
||||
// Sets the value at the specified index. Returns true if the value was set
|
||||
// successfully. If |value| represents simple data then the underlying data
|
||||
// will be copied and modifications to |value| will not modify this object. If
|
||||
// |value| represents complex data (binary, dictionary or list) then the
|
||||
// underlying data will be referenced and modifications to |value| will modify
|
||||
// this object.
|
||||
///
|
||||
/*--cef(index_param=index)--*/
|
||||
virtual bool SetValue(int index, CefRefPtr<CefValue> value) =0;
|
||||
|
||||
///
|
||||
// Sets the value at the specified index as type null. Returns true if the
|
||||
// value was set successfully.
|
||||
@@ -436,8 +720,7 @@ class CefListValue : public virtual CefBase {
|
||||
|
||||
///
|
||||
// Sets the value at the specified index as type binary. Returns true if the
|
||||
// value was set successfully. After calling this method the |value| object
|
||||
// will no longer be valid. If |value| is currently owned by another object
|
||||
// value was set successfully. If |value| is currently owned by another object
|
||||
// then the value will be copied and the |value| reference will not change.
|
||||
// Otherwise, ownership will be transferred to this object and the |value|
|
||||
// reference will be invalidated.
|
||||
@@ -447,8 +730,7 @@ class CefListValue : public virtual CefBase {
|
||||
|
||||
///
|
||||
// Sets the value at the specified index as type dict. Returns true if the
|
||||
// value was set successfully. After calling this method the |value| object
|
||||
// will no longer be valid. If |value| is currently owned by another object
|
||||
// value was set successfully. If |value| is currently owned by another object
|
||||
// then the value will be copied and the |value| reference will not change.
|
||||
// Otherwise, ownership will be transferred to this object and the |value|
|
||||
// reference will be invalidated.
|
||||
@@ -458,8 +740,7 @@ class CefListValue : public virtual CefBase {
|
||||
|
||||
///
|
||||
// Sets the value at the specified index as type list. Returns true if the
|
||||
// value was set successfully. After calling this method the |value| object
|
||||
// will no longer be valid. If |value| is currently owned by another object
|
||||
// value was set successfully. If |value| is currently owned by another object
|
||||
// then the value will be copied and the |value| reference will not change.
|
||||
// Otherwise, ownership will be transferred to this object and the |value|
|
||||
// reference will be invalidated.
|
||||
|
Reference in New Issue
Block a user