00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __JSVALUE_H__
00009 #define __JSVALUE_H__
00010
00011 #include <string>
00012 #include <vector>
00013 #include <map>
00014 #include "PlatformUtils.h"
00015
00016 namespace Impl { struct VariantValue; }
00017
00018 namespace Awesomium
00019 {
00020
00021 class WebView;
00022
00023 class _OSMExport JSIdentifier
00024 {
00025 public:
00026 JSIdentifier(const char* value);
00027 JSIdentifier(const std::string& value);
00028 JSIdentifier(const wchar_t* value);
00029 JSIdentifier(const std::wstring& value);
00030 JSIdentifier(int value);
00031 JSIdentifier(const JSIdentifier& original);
00032 ~JSIdentifier();
00033 bool operator<(const JSIdentifier& rhs) const;
00034
00035 bool isString() const;
00036
00037 const std::wstring& getString() const;
00038 int getInteger() const;
00039
00040 protected:
00041 union { int intValue; std::wstring* strValue; } data;
00042 bool isStringData;
00043 };
00044
00049 class _OSMExport JSValue
00050 {
00051 Impl::VariantValue* varValue;
00052 public:
00053
00054 typedef std::map<std::wstring, JSValue> Object;
00055 typedef std::vector<JSValue> Array;
00056
00058 JSValue();
00059
00061 JSValue(bool value);
00062
00064 JSValue(int value);
00065
00067 JSValue(double value);
00068
00070 JSValue(const char* value);
00071
00073 JSValue(const std::string& value);
00074
00076 JSValue(const wchar_t* value);
00077
00079 JSValue(const std::wstring& value);
00080
00082 JSValue(const Object& value);
00083
00085 JSValue(const Array& value);
00086
00087 JSValue(const JSValue& original);
00088
00089 ~JSValue();
00090
00091 JSValue& operator=(const JSValue& rhs);
00092
00094 bool isBoolean() const;
00095
00097 bool isInteger() const;
00098
00100 bool isDouble() const;
00101
00103 bool isNumber() const;
00104
00106 bool isString() const;
00107
00109 bool isArray() const;
00110
00112 bool isObject() const;
00113
00115 bool isNull() const;
00116
00118 const std::wstring& toString() const;
00119
00121 int toInteger() const;
00122
00124 double toDouble() const;
00125
00127 bool toBoolean() const;
00128
00130 Array& getArray();
00131
00133 const Array& getArray() const;
00134
00136 Object& getObject();
00137
00139 const Object& getObject() const;
00140 };
00141
00142 typedef std::vector<JSValue> JSArguments;
00143
00151 class _OSMExport FutureJSValue
00152 {
00153 public:
00154 FutureJSValue();
00155 ~FutureJSValue();
00156
00161 const JSValue& get();
00162
00163 protected:
00164 void init(WebView* source, int requestID);
00165
00166 JSValue value;
00167 WebView* source;
00168 int requestID;
00169
00170 friend class WebView;
00171 };
00172
00173 }
00174
00175 #endif