michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef IndexedDatabaseInlines_h michael@0: #define IndexedDatabaseInlines_h michael@0: michael@0: #ifndef mozilla_dom_indexeddb_indexeddatabase_h__ michael@0: #error Must include IndexedDatabase.h first michael@0: #endif michael@0: michael@0: BEGIN_INDEXEDDB_NAMESPACE michael@0: michael@0: inline michael@0: StructuredCloneWriteInfo::StructuredCloneWriteInfo() michael@0: : mTransaction(nullptr), michael@0: mOffsetToKeyProp(0) michael@0: { michael@0: } michael@0: michael@0: inline michael@0: StructuredCloneWriteInfo::StructuredCloneWriteInfo( michael@0: StructuredCloneWriteInfo&& aCloneWriteInfo) michael@0: : mCloneBuffer(Move(aCloneWriteInfo.mCloneBuffer)) michael@0: , mTransaction(aCloneWriteInfo.mTransaction) michael@0: , mOffsetToKeyProp(aCloneWriteInfo.mOffsetToKeyProp) michael@0: { michael@0: mFiles.SwapElements(aCloneWriteInfo.mFiles); michael@0: aCloneWriteInfo.mTransaction = nullptr; michael@0: aCloneWriteInfo.mOffsetToKeyProp = 0; michael@0: } michael@0: michael@0: inline michael@0: bool michael@0: StructuredCloneWriteInfo::SetFromSerialized( michael@0: const SerializedStructuredCloneWriteInfo& aOther) michael@0: { michael@0: if (!aOther.dataLength) { michael@0: mCloneBuffer.clear(); michael@0: } michael@0: else if (!mCloneBuffer.copy(aOther.data, aOther.dataLength)) { michael@0: return false; michael@0: } michael@0: michael@0: mFiles.Clear(); michael@0: mOffsetToKeyProp = aOther.offsetToKeyProp; michael@0: return true; michael@0: } michael@0: michael@0: inline michael@0: StructuredCloneReadInfo::StructuredCloneReadInfo() michael@0: : mDatabase(nullptr) michael@0: { michael@0: } michael@0: michael@0: inline StructuredCloneReadInfo& michael@0: StructuredCloneReadInfo::operator=(StructuredCloneReadInfo&& aCloneReadInfo) michael@0: { michael@0: MOZ_ASSERT(&aCloneReadInfo != this); michael@0: michael@0: mCloneBuffer = Move(aCloneReadInfo.mCloneBuffer); michael@0: mFiles.Clear(); michael@0: mFiles.SwapElements(aCloneReadInfo.mFiles); michael@0: mDatabase = aCloneReadInfo.mDatabase; michael@0: aCloneReadInfo.mDatabase = nullptr; michael@0: return *this; michael@0: } michael@0: michael@0: inline michael@0: bool michael@0: StructuredCloneReadInfo::SetFromSerialized( michael@0: const SerializedStructuredCloneReadInfo& aOther) michael@0: { michael@0: if (aOther.dataLength && michael@0: !mCloneBuffer.copy(aOther.data, aOther.dataLength)) { michael@0: return false; michael@0: } michael@0: michael@0: mFiles.Clear(); michael@0: return true; michael@0: } michael@0: michael@0: inline michael@0: void michael@0: AppendConditionClause(const nsACString& aColumnName, michael@0: const nsACString& aArgName, michael@0: bool aLessThan, michael@0: bool aEquals, michael@0: nsACString& aResult) michael@0: { michael@0: aResult += NS_LITERAL_CSTRING(" AND ") + aColumnName + michael@0: NS_LITERAL_CSTRING(" "); michael@0: michael@0: if (aLessThan) { michael@0: aResult.AppendLiteral("<"); michael@0: } michael@0: else { michael@0: aResult.AppendLiteral(">"); michael@0: } michael@0: michael@0: if (aEquals) { michael@0: aResult.AppendLiteral("="); michael@0: } michael@0: michael@0: aResult += NS_LITERAL_CSTRING(" :") + aArgName; michael@0: } michael@0: michael@0: END_INDEXEDDB_NAMESPACE michael@0: michael@0: #endif