dom/indexedDB/IndexedDatabaseInlines.h
author Bas Schouten <bschouten@mozilla.com>
Mon, 11 Nov 2013 12:42:07 +1300
changeset 155112 f2e964f107992348465e513b95f604b7732a8345
parent 126244 8d558e07caf4c6f9ef6660f2000f54754894e814
child 159498 d9c1b5c40a55209ce369e5c0800279f1327b81d5
permissions -rw-r--r--
Bug 939049 - Part 2: Add generic ComputeLength code for backends with no such functionality. r=jrmuizel

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef mozilla_dom_indexeddb_indexeddatabase_h__
#error Must include IndexedDatabase.h first
#endif

BEGIN_INDEXEDDB_NAMESPACE

inline
StructuredCloneWriteInfo::StructuredCloneWriteInfo()
: mTransaction(nullptr),
  mOffsetToKeyProp(0)
{
}

inline
bool
StructuredCloneWriteInfo::SetFromSerialized(
                               const SerializedStructuredCloneWriteInfo& aOther)
{
  if (!aOther.dataLength) {
    mCloneBuffer.clear();
  }
  else if (!mCloneBuffer.copy(aOther.data, aOther.dataLength)) {
    return false;
  }

  mFiles.Clear();
  mOffsetToKeyProp = aOther.offsetToKeyProp;
  return true;
}

inline
StructuredCloneReadInfo::StructuredCloneReadInfo()
: mDatabase(nullptr)
{
}

inline
bool
StructuredCloneReadInfo::SetFromSerialized(
                                const SerializedStructuredCloneReadInfo& aOther)
{
  if (aOther.dataLength &&
      !mCloneBuffer.copy(aOther.data, aOther.dataLength)) {
    return false;
  }

  mFiles.Clear();
  return true;
}

inline
void
AppendConditionClause(const nsACString& aColumnName,
                      const nsACString& aArgName,
                      bool aLessThan,
                      bool aEquals,
                      nsACString& aResult)
{
  aResult += NS_LITERAL_CSTRING(" AND ") + aColumnName +
             NS_LITERAL_CSTRING(" ");

  if (aLessThan) {
    aResult.AppendLiteral("<");
  }
  else {
    aResult.AppendLiteral(">");
  }

  if (aEquals) {
    aResult.AppendLiteral("=");
  }

  aResult += NS_LITERAL_CSTRING(" :") + aArgName;
}

END_INDEXEDDB_NAMESPACE