1/* 2 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with this library; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 */ 18 19#ifndef JavaScriptVariant_h 20#define JavaScriptVariant_h 21 22#include "BlackBerryGlobal.h" 23 24#include <BlackBerryPlatformString.h> 25 26namespace BlackBerry { 27namespace WebKit { 28 29class BLACKBERRY_EXPORT JavaScriptVariant { 30public: 31 enum DataType { 32 Undefined = 0, 33 Null, 34 Boolean, 35 Number, 36 String, 37 Object, 38 Exception 39 }; 40 41 JavaScriptVariant(); 42 JavaScriptVariant(const JavaScriptVariant&); 43 JavaScriptVariant(double); 44 JavaScriptVariant(int); 45 explicit JavaScriptVariant(bool); 46 JavaScriptVariant(const BlackBerry::Platform::String&); 47 ~JavaScriptVariant(); 48 49 JavaScriptVariant& operator=(const JavaScriptVariant&); 50 51 void setType(const DataType&); 52 DataType type() const; 53 54 void setDouble(double); 55 double doubleValue() const; 56 57 void setString(const BlackBerry::Platform::String&); 58 const BlackBerry::Platform::String& stringValue() const; 59 60 void setBoolean(bool); 61 bool booleanValue() const; 62 63private: 64 JavaScriptVariant(const char*); 65 DataType m_type; 66 67 union { 68 bool m_booleanValue; 69 double m_doubleValue; 70 }; 71 72 BlackBerry::Platform::String m_stringValue; 73}; 74 75} 76} 77 78#endif // JavaScriptVariant_h 79