mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 483880 - Pull out implementation of mozStorageVariant_base so we can include it in more than one file
The current implementation means it can only be #included once, which makes it not terribly useful for other consumers. r=asuth
This commit is contained in:
parent
c1f550d335
commit
311505dbc1
@ -76,6 +76,7 @@ CPPSRCS = \
|
||||
mozStorageEvents.cpp \
|
||||
mozStorageStatementJSHelper.cpp \
|
||||
mozStoragePrivateHelpers.cpp \
|
||||
mozStorageVariant.cpp \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES = \
|
||||
|
208
storage/src/mozStorageVariant.cpp
Normal file
208
storage/src/mozStorageVariant.cpp
Normal file
@ -0,0 +1,208 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: sw=2 ts=2 sts=2 expandtab
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation
|
||||
* Portions created by the Initial Developer are Copyright (C) 2008
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Shawn Wilsher <me@shawnwilsher.com> (Original Author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "mozStorageVariant.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//// mozStorageVariant_base
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(
|
||||
mozStorageVariant_base,
|
||||
nsIVariant
|
||||
)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//// nsIVariant
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozStorageVariant_base::GetDataType(PRUint16 *_type)
|
||||
{
|
||||
*_type = nsIDataType::VTYPE_EMPTY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozStorageVariant_base::GetAsInt32(PRInt32 *)
|
||||
{
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozStorageVariant_base::GetAsInt64(PRInt64 *)
|
||||
{
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozStorageVariant_base::GetAsDouble(double *)
|
||||
{
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozStorageVariant_base::GetAsAUTF8String(nsACString &)
|
||||
{
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozStorageVariant_base::GetAsAString(nsAString &)
|
||||
{
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozStorageVariant_base::GetAsArray(PRUint16 *, nsIID *, PRUint32 *, void **)
|
||||
{
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozStorageVariant_base::GetAsInt8(PRUint8 *)
|
||||
{
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozStorageVariant_base::GetAsInt16(PRInt16 *)
|
||||
{
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozStorageVariant_base::GetAsUint8(PRUint8 *)
|
||||
{
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozStorageVariant_base::GetAsUint16(PRUint16 *)
|
||||
{
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozStorageVariant_base::GetAsUint32(PRUint32 *)
|
||||
{
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozStorageVariant_base::GetAsUint64(PRUint64 *)
|
||||
{
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozStorageVariant_base::GetAsFloat(float *)
|
||||
{
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozStorageVariant_base::GetAsBool(PRBool *)
|
||||
{
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozStorageVariant_base::GetAsChar(char *)
|
||||
{
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozStorageVariant_base::GetAsWChar(PRUnichar *)
|
||||
{
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozStorageVariant_base::GetAsID(nsID *)
|
||||
{
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozStorageVariant_base::GetAsDOMString(nsAString &)
|
||||
{
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozStorageVariant_base::GetAsString(char **)
|
||||
{
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozStorageVariant_base::GetAsWString(PRUnichar **)
|
||||
{
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozStorageVariant_base::GetAsISupports(nsISupports **)
|
||||
{
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozStorageVariant_base::GetAsInterface(nsIID **, void **)
|
||||
{
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozStorageVariant_base::GetAsACString(nsACString &)
|
||||
{
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozStorageVariant_base::GetAsStringWithSize(PRUint32 *, char **)
|
||||
{
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozStorageVariant_base::GetAsWStringWithSize(PRUint32 *, PRUnichar **)
|
||||
{
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
@ -40,10 +40,12 @@
|
||||
#ifndef __mozStorageVariant_h__
|
||||
#define __mozStorageVariant_h__
|
||||
|
||||
#include "nsIVariant.h"
|
||||
#include "nsTArray.h"
|
||||
#include <utility>
|
||||
|
||||
#include "nsIVariant.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
/**
|
||||
* This class is used by the storage module whenever an nsIVariant needs to be
|
||||
* returned. We provide traits for the basic sqlite types to make use easier.
|
||||
@ -56,8 +58,6 @@
|
||||
* nsnull -> NULL (use mozStorageNull)
|
||||
*/
|
||||
|
||||
#define NO_CONVERSION return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//// Base Class
|
||||
|
||||
@ -65,46 +65,11 @@ class mozStorageVariant_base : public nsIVariant
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetDataType(PRUint16 *_type)
|
||||
{
|
||||
*_type = nsIDataType::VTYPE_EMPTY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetAsInt32(PRInt32 *_integer) { NO_CONVERSION }
|
||||
NS_IMETHOD GetAsInt64(PRInt64 *) { NO_CONVERSION }
|
||||
NS_IMETHOD GetAsDouble(double *) { NO_CONVERSION }
|
||||
NS_IMETHOD GetAsAUTF8String(nsACString &) { NO_CONVERSION }
|
||||
NS_IMETHOD GetAsAString(nsAString &) { NO_CONVERSION }
|
||||
NS_IMETHOD GetAsArray(PRUint16 *, nsIID *, PRUint32 *, void **) { NO_CONVERSION }
|
||||
NS_IMETHOD GetAsInt8(PRUint8 *) { NO_CONVERSION }
|
||||
NS_IMETHOD GetAsInt16(PRInt16 *) { NO_CONVERSION }
|
||||
NS_IMETHOD GetAsUint8(PRUint8 *) { NO_CONVERSION }
|
||||
NS_IMETHOD GetAsUint16(PRUint16 *) { NO_CONVERSION }
|
||||
NS_IMETHOD GetAsUint32(PRUint32 *) { NO_CONVERSION }
|
||||
NS_IMETHOD GetAsUint64(PRUint64 *) { NO_CONVERSION }
|
||||
NS_IMETHOD GetAsFloat(float *) { NO_CONVERSION }
|
||||
NS_IMETHOD GetAsBool(PRBool *) { NO_CONVERSION }
|
||||
NS_IMETHOD GetAsChar(char *) { NO_CONVERSION }
|
||||
NS_IMETHOD GetAsWChar(PRUnichar *) { NO_CONVERSION }
|
||||
NS_IMETHOD GetAsID(nsID *) { NO_CONVERSION }
|
||||
NS_IMETHOD GetAsDOMString(nsAString &) { NO_CONVERSION }
|
||||
NS_IMETHOD GetAsString(char **) { NO_CONVERSION }
|
||||
NS_IMETHOD GetAsWString(PRUnichar **) { NO_CONVERSION }
|
||||
NS_IMETHOD GetAsISupports(nsISupports **) { NO_CONVERSION }
|
||||
NS_IMETHOD GetAsInterface(nsIID **, void **) { NO_CONVERSION }
|
||||
NS_IMETHOD GetAsACString(nsACString &) { NO_CONVERSION }
|
||||
NS_IMETHOD GetAsStringWithSize(PRUint32 *, char **) { NO_CONVERSION }
|
||||
NS_IMETHOD GetAsWStringWithSize(PRUint32 *, PRUnichar **) { NO_CONVERSION }
|
||||
NS_DECL_NSIVARIANT
|
||||
|
||||
protected:
|
||||
virtual ~mozStorageVariant_base() { }
|
||||
};
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(
|
||||
mozStorageVariant_base,
|
||||
nsIVariant
|
||||
)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//// Traits
|
||||
@ -127,6 +92,8 @@ struct variant_storage_traits
|
||||
static inline StorageType storage_conversion(ConstructorType aData) { return aData; }
|
||||
};
|
||||
|
||||
#define NO_CONVERSION return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
|
||||
template <typename DataType>
|
||||
struct variant_integer_traits
|
||||
{
|
||||
@ -158,6 +125,8 @@ struct variant_blob_traits
|
||||
{ NO_CONVERSION }
|
||||
};
|
||||
|
||||
#undef NO_CONVERSION
|
||||
|
||||
/**
|
||||
* INTEGER types
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user