本文整理汇总了C++中idbkey::KeyArray类的典型用法代码示例。如果您正苦于以下问题:C++ KeyArray类的具体用法?C++ KeyArray怎么用?C++ KeyArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KeyArray类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: decodeIDBKey
const char* decodeIDBKey(const char* p, const char* limit, RefPtr<IDBKey>& foundKey)
{
ASSERT(limit >= p);
if (p >= limit)
return 0;
unsigned char type = *p++;
switch (type) {
case IDBKeyNullTypeByte:
foundKey = IDBKey::createInvalid();
return p;
case IDBKeyArrayTypeByte: {
int64_t length;
p = decodeVarInt(p, limit, length);
if (!p)
return 0;
if (length < 0)
return 0;
IDBKey::KeyArray array;
while (length--) {
RefPtr<IDBKey> key;
p = decodeIDBKey(p, limit, key);
if (!p)
return 0;
array.append(key);
}
foundKey = IDBKey::createArray(array);
return p;
}
case IDBKeyStringTypeByte: {
String s;
p = decodeStringWithLength(p, limit, s);
if (!p)
return 0;
foundKey = IDBKey::createString(s);
return p;
}
case IDBKeyDateTypeByte: {
double d;
p = decodeDouble(p, limit, &d);
if (!p)
return 0;
foundKey = IDBKey::createDate(d);
return p;
}
case IDBKeyNumberTypeByte: {
double d;
p = decodeDouble(p, limit, &d);
if (!p)
return 0;
foundKey = IDBKey::createNumber(d);
return p;
}
}
ASSERT_NOT_REACHED();
return 0;
}
示例2: convertToWebIDBKeyArray
static void convertToWebIDBKeyArray(const IDBKey::KeyArray& array, WebVector<WebIDBKey>& result)
{
WebVector<WebIDBKey> keys(array.size());
WebVector<WebIDBKey> subkeys;
for (size_t i = 0; i < array.size(); ++i) {
IDBKey* key = array[i];
switch (key->getType()) {
case IDBKey::ArrayType:
convertToWebIDBKeyArray(key->array(), subkeys);
keys[i] = WebIDBKey::createArray(subkeys);
break;
case IDBKey::BinaryType:
keys[i] = WebIDBKey::createBinary(key->binary());
break;
case IDBKey::StringType:
keys[i] = WebIDBKey::createString(key->string());
break;
case IDBKey::DateType:
keys[i] = WebIDBKey::createDate(key->date());
break;
case IDBKey::NumberType:
keys[i] = WebIDBKey::createNumber(key->number());
break;
case IDBKey::InvalidType:
keys[i] = WebIDBKey::createInvalid();
break;
case IDBKey::MinType:
ASSERT_NOT_REACHED();
break;
}
}
result.swap(keys);
}
示例3: createNumber
static PassRefPtr<IDBKey> createIDBKeyFromValue(v8::Handle<v8::Value> value, Vector<v8::Handle<v8::Array> >& stack, v8::Isolate* isolate)
{
if (value->IsNumber() && !std::isnan(value->NumberValue()))
return IDBKey::createNumber(value->NumberValue());
if (value->IsString())
return IDBKey::createString(toCoreString(value.As<v8::String>()));
if (value->IsDate() && !std::isnan(value->NumberValue()))
return IDBKey::createDate(value->NumberValue());
if (value->IsArray()) {
v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(value);
if (stack.contains(array))
return 0;
if (stack.size() >= maximumDepth)
return 0;
stack.append(array);
IDBKey::KeyArray subkeys;
uint32_t length = array->Length();
for (uint32_t i = 0; i < length; ++i) {
v8::Local<v8::Value> item = array->Get(v8::Int32::New(i, isolate));
RefPtr<IDBKey> subkey = createIDBKeyFromValue(item, stack, isolate);
if (!subkey)
subkeys.append(IDBKey::createInvalid());
else
subkeys.append(subkey);
}
stack.removeLast();
return IDBKey::createArray(subkeys);
}
return 0;
}
示例4: convertFromWebIDBKeyArray
static IDBKey* convertFromWebIDBKeyArray(const WebVector<WebIDBKey>& array)
{
IDBKey::KeyArray keys;
keys.reserveCapacity(array.size());
for (size_t i = 0; i < array.size(); ++i) {
switch (array[i].keyType()) {
case WebIDBKeyTypeArray:
keys.append(convertFromWebIDBKeyArray(array[i].array()));
break;
case WebIDBKeyTypeBinary:
keys.append(IDBKey::createBinary(array[i].binary()));
break;
case WebIDBKeyTypeString:
keys.append(IDBKey::createString(array[i].string()));
break;
case WebIDBKeyTypeDate:
keys.append(IDBKey::createDate(array[i].date()));
break;
case WebIDBKeyTypeNumber:
keys.append(IDBKey::createNumber(array[i].number()));
break;
case WebIDBKeyTypeInvalid:
keys.append(IDBKey::createInvalid());
break;
case WebIDBKeyTypeNull:
case WebIDBKeyTypeMin:
ASSERT_NOT_REACHED();
break;
}
}
return IDBKey::createArray(keys);
}
示例5: createIDBKeyFromScriptValueAndKeyPathInternal
static IDBKey* createIDBKeyFromScriptValueAndKeyPathInternal(v8::Isolate* isolate, const ScriptValue& value, const IDBKeyPath& keyPath, bool allowExperimentalTypes = false)
{
ASSERT(!keyPath.isNull());
v8::HandleScope handleScope(isolate);
if (keyPath.type() == IDBKeyPath::ArrayType) {
IDBKey::KeyArray result;
const Vector<String>& array = keyPath.array();
for (size_t i = 0; i < array.size(); ++i) {
IDBKey* key = createIDBKeyFromScriptValueAndKeyPathInternal(isolate, value, array[i], allowExperimentalTypes);
if (!key)
return 0;
result.append(key);
}
return IDBKey::createArray(result);
}
ASSERT(keyPath.type() == IDBKeyPath::StringType);
return createIDBKeyFromScriptValueAndKeyPathInternal(isolate, value, keyPath.string(), allowExperimentalTypes);
}
示例6: createIDBKeyFromValue
static IDBKey* createIDBKeyFromValue(v8::Isolate* isolate, v8::Handle<v8::Value> value, Vector<v8::Handle<v8::Array> >& stack, bool allowExperimentalTypes = false)
{
if (value->IsNumber() && !std::isnan(value->NumberValue()))
return IDBKey::createNumber(value->NumberValue());
if (value->IsString())
return IDBKey::createString(toCoreString(value.As<v8::String>()));
if (value->IsDate() && !std::isnan(value->NumberValue()))
return IDBKey::createDate(value->NumberValue());
if (value->IsUint8Array() && (allowExperimentalTypes || RuntimeEnabledFeatures::indexedDBExperimentalEnabled())) {
// Per discussion in https://www.w3.org/Bugs/Public/show_bug.cgi?id=23332 the
// input type is constrained to Uint8Array to match the output type.
ArrayBufferView* view = blink::V8ArrayBufferView::toImpl(value->ToObject());
const char* start = static_cast<const char*>(view->baseAddress());
size_t length = view->byteLength();
return IDBKey::createBinary(SharedBuffer::create(start, length));
}
if (value->IsArray()) {
v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(value);
if (stack.contains(array))
return 0;
if (stack.size() >= maximumDepth)
return 0;
stack.append(array);
IDBKey::KeyArray subkeys;
uint32_t length = array->Length();
for (uint32_t i = 0; i < length; ++i) {
v8::Local<v8::Value> item = array->Get(v8::Int32::New(isolate, i));
IDBKey* subkey = createIDBKeyFromValue(isolate, item, stack, allowExperimentalTypes);
if (!subkey)
subkeys.append(IDBKey::createInvalid());
else
subkeys.append(subkey);
}
stack.removeLast();
return IDBKey::createArray(subkeys);
}
return 0;
}
示例7: handleScope
PassRefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(DOMRequestState* state, const ScriptValue& value, const IDBKeyPath& keyPath)
{
IDB_TRACE("createIDBKeyFromScriptValueAndKeyPath");
ASSERT(!keyPath.isNull());
v8::Isolate* isolate = state ? state->context()->GetIsolate() : v8::Isolate::GetCurrent();
ASSERT(isolate->InContext());
v8::HandleScope handleScope(isolate);
if (keyPath.type() == IDBKeyPath::ArrayType) {
IDBKey::KeyArray result;
const Vector<String>& array = keyPath.array();
for (size_t i = 0; i < array.size(); ++i) {
RefPtr<IDBKey> key = createIDBKeyFromScriptValueAndKeyPath(value, array[i], isolate);
if (!key)
return 0;
result.append(key);
}
return IDBKey::createArray(result);
}
ASSERT(keyPath.type() == IDBKeyPath::StringType);
return createIDBKeyFromScriptValueAndKeyPath(value, keyPath.string(), isolate);
}
示例8: createArray
PassRefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(DOMRequestState* requestState, const ScriptValue& value, const IDBKeyPath& keyPath)
{
IDB_TRACE("createIDBKeyFromScriptValueAndKeyPath");
ASSERT(!keyPath.isNull());
ExecState* exec = requestState->exec();
if (keyPath.type() == IDBKeyPath::ArrayType) {
IDBKey::KeyArray result;
const Vector<String>& array = keyPath.array();
for (size_t i = 0; i < array.size(); i++) {
RefPtr<IDBKey> key = createIDBKeyFromScriptValueAndKeyPath(exec, value, array[i]);
if (!key)
return 0;
result.append(key);
}
return IDBKey::createArray(result);
}
ASSERT(keyPath.type() == IDBKeyPath::StringType);
return createIDBKeyFromScriptValueAndKeyPath(exec, value, keyPath.string());
}
示例9: createNumber
static PassRefPtr<IDBKey> createIDBKeyFromValue(ExecState* exec, JSValue value, Vector<JSArray*>& stack)
{
if (value.isNumber() && !std::isnan(value.toNumber(exec)))
return IDBKey::createNumber(value.toNumber(exec));
if (value.isString())
return IDBKey::createString(value.toString(exec)->value(exec));
if (value.inherits(&DateInstance::s_info) && !std::isnan(valueToDate(exec, value)))
return IDBKey::createDate(valueToDate(exec, value));
if (value.isObject()) {
JSObject* object = asObject(value);
if (isJSArray(object) || object->inherits(&JSArray::s_info)) {
JSArray* array = asArray(object);
size_t length = array->length();
if (stack.contains(array))
return 0;
if (stack.size() >= maximumDepth)
return 0;
stack.append(array);
IDBKey::KeyArray subkeys;
for (size_t i = 0; i < length; i++) {
JSValue item = array->getIndex(exec, i);
RefPtr<IDBKey> subkey = createIDBKeyFromValue(exec, item, stack);
if (!subkey)
subkeys.append(IDBKey::createInvalid());
else
subkeys.append(subkey);
}
stack.removeLast();
return IDBKey::createArray(subkeys);
}
}
return 0;
}