Vector<char> IndexFreeListKey::encode(int64_t databaseId, int64_t objectStoreId, int64_t indexId) { KeyPrefix prefix(databaseId, 0, 0); Vector<char> ret = prefix.encode(); ret.append(encodeByte(IndexFreeListTypeByte)); ret.append(encodeVarInt(objectStoreId)); ret.append(encodeVarInt(indexId)); return ret; }
void ProtoSerializerVisitor::write(const uint32_t &fourByteID, const uint8_t &oneByteID, const string &/*longName*/, const string &/*shortName*/, const void *data, const uint32_t &size) { uint32_t key = getKey( (oneByteID > 0 ? oneByteID : fourByteID) , ProtoSerializerVisitor::LENGTH_DELIMITED); m_size += encodeVarInt(m_buffer, key); m_size += encodeVarInt(m_buffer, size); m_buffer.write(reinterpret_cast<const char*>(data), size); m_size += size; }
void ProtoSerializerVisitor::write(const uint32_t &id, const void *data, const uint32_t &size) { uint32_t key = getKey(id, ProtoSerializerVisitor::LENGTH_DELIMITED); m_size += encodeVarInt(m_buffer, key); m_size += encodeVarInt(m_buffer, size); m_buffer.write(reinterpret_cast<const char*>(data), size); m_size += size; }
Vector<char> ObjectStoreMetaDataKey::encode(int64_t databaseId, int64_t objectStoreId, int64_t metaDataType) { KeyPrefix prefix(databaseId, 0, 0); Vector<char> ret = prefix.encode(); ret.append(encodeByte(kObjectStoreMetaDataTypeByte)); ret.append(encodeVarInt(objectStoreId)); ret.append(encodeVarInt(metaDataType)); return ret; }
Vector<char> IndexMetaDataKey::encode(int64_t databaseId, int64_t objectStoreId, int64_t indexId, unsigned char metaDataType) { KeyPrefix prefix(databaseId, 0, 0); Vector<char> ret = prefix.encode(); ret.append(encodeByte(IndexMetaDataTypeByte)); ret.append(encodeVarInt(objectStoreId)); ret.append(encodeVarInt(indexId)); ret.append(encodeByte(metaDataType)); return ret; }
void ProtoSerializerVisitor::write(const uint32_t &fourByteID, const uint8_t &oneByteID, const string &/*longName*/, const string &/*shortName*/, const string &v) { uint32_t key = getKey( (oneByteID > 0 ? oneByteID : fourByteID) , ProtoSerializerVisitor::LENGTH_DELIMITED); m_size += encodeVarInt(m_buffer, key); const uint32_t size = v.length(); m_size += encodeVarInt(m_buffer, size); m_buffer.write(v.c_str(), size); m_size += size; }
void ProtoSerializerVisitor::write(const uint32_t &id, const string &v) { uint32_t key = getKey(id, ProtoSerializerVisitor::LENGTH_DELIMITED); m_size += encodeVarInt(m_buffer, key); const uint32_t size = v.length(); m_size += encodeVarInt(m_buffer, size); m_buffer.write(v.c_str(), size); m_size += size; }
Vector<char> encodeIDBKeyPath(const IDBKeyPath& keyPath) { // May be typed, or may be a raw string. An invalid leading // byte is used to identify typed coding. New records are // always written as typed. Vector<char> ret; ret.append(IDBKeyPathTypeCodedByte1); ret.append(IDBKeyPathTypeCodedByte2); ret.append(static_cast<char>(keyPath.type())); switch (keyPath.type()) { case IDBKeyPath::NullType: break; case IDBKeyPath::StringType: ret.append(encodeStringWithLength(keyPath.string())); break; case IDBKeyPath::ArrayType: { const Vector<String>& array = keyPath.array(); size_t count = array.size(); ret.append(encodeVarInt(count)); for (size_t i = 0; i < count; ++i) ret.append(encodeStringWithLength(array[i])); break; } } return ret; }
Vector<char> DatabaseFreeListKey::encode(int64_t databaseId) { KeyPrefix prefix(0, 0, 0); Vector<char> ret = prefix.encode(); ret.append(encodeByte(DatabaseFreeListTypeByte)); ret.append(encodeVarInt(databaseId)); return ret; }
void ProtoSerializerVisitor::write(const uint32_t &fourByteID, const uint8_t &oneByteID, const string &/*longName*/, const string &/*shortName*/, const double &v) { uint32_t key = getKey( (oneByteID > 0 ? oneByteID : fourByteID) , ProtoSerializerVisitor::EIGHT_BYTES); m_size += encodeVarInt(m_buffer, key); double _v = htond(v); m_buffer.write(reinterpret_cast<const char*>(&_v), sizeof(const double)); m_size += sizeof(const double); }
void ProtoSerializerVisitor::write(const uint32_t &id, const double &v) { uint32_t key = getKey(id, ProtoSerializerVisitor::EIGHT_BYTES); m_size += encodeVarInt(m_buffer, key); double _v = htond(v); m_buffer.write(reinterpret_cast<const char*>(&_v), sizeof(const double)); m_size += sizeof(const double); }
void ProtoSerializerVisitor::write(const uint32_t &id, const float &v) { uint32_t key = getKey(id, ProtoSerializerVisitor::FOUR_BYTES); m_size += encodeVarInt(m_buffer, key); float _v = htonf(v); m_buffer.write(reinterpret_cast<const char*>(&_v), sizeof(const float)); m_size += sizeof(const float); }
Vector<char> IndexDataKey::encode(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const Vector<char>& encodedUserKey, const Vector<char>& encodedPrimaryKey, int64_t sequenceNumber) { KeyPrefix prefix(databaseId, objectStoreId, indexId); Vector<char> ret = prefix.encode(); ret.append(encodedUserKey); ret.append(encodeVarInt(sequenceNumber)); ret.append(encodedPrimaryKey); return ret; }
Vector<char> IndexNamesKey::encode(int64_t databaseId, int64_t objectStoreId, const String& indexName) { KeyPrefix prefix(databaseId, 0, 0); Vector<char> ret = prefix.encode(); ret.append(encodeByte(IndexNamesKeyTypeByte)); ret.append(encodeVarInt(objectStoreId)); ret.append(encodeStringWithLength(indexName)); return ret; }
void encodeIDBKey(const IDBKey& key, Vector<char>& into) { size_t previousSize = into.size(); ASSERT(key.isValid()); switch (key.type()) { case IDBKey::InvalidType: case IDBKey::MinType: ASSERT_NOT_REACHED(); into.append(encodeByte(IDBKeyNullTypeByte)); return; case IDBKey::ArrayType: { into.append(encodeByte(IDBKeyArrayTypeByte)); size_t length = key.array().size(); into.append(encodeVarInt(length)); for (size_t i = 0; i < length; ++i) encodeIDBKey(*key.array()[i], into); ASSERT_UNUSED(previousSize, into.size() > previousSize); return; } case IDBKey::StringType: into.append(encodeByte(IDBKeyStringTypeByte)); into.append(encodeStringWithLength(key.string())); ASSERT_UNUSED(previousSize, into.size() > previousSize); return; case IDBKey::DateType: into.append(encodeByte(IDBKeyDateTypeByte)); into.append(encodeDouble(key.date())); ASSERT_UNUSED(previousSize, into.size() - previousSize == 9); return; case IDBKey::NumberType: into.append(encodeByte(IDBKeyNumberTypeByte)); into.append(encodeDouble(key.number())); ASSERT_UNUSED(previousSize, into.size() - previousSize == 9); return; } ASSERT_NOT_REACHED(); }
Vector<char> encodeStringWithLength(const String& s) { Vector<char> ret = encodeVarInt(s.length()); ret.append(encodeString(s)); return ret; }