RTBKit
0.9
Open-source framework to create real-time ad bidding systems.
|
00001 /* js_value_fwd.h -*- C++ -*- 00002 Jeremy Barnes, 27 October 2010 00003 Copyright (c) 2010 Datacratic. All rights reserved. 00004 00005 Forward definitions for js_value. 00006 */ 00007 00008 #ifndef __js__js_value_fwd_h__ 00009 #define __js__js_value_fwd_h__ 00010 00011 #include <string> 00012 #include "soa/types/string.h" 00013 #include <boost/utility/enable_if.hpp> 00014 #include <boost/type_traits/is_enum.hpp> 00015 #include <boost/type_traits/is_same.hpp> 00016 00017 namespace Json { 00018 00019 struct Value; 00020 00021 } // namespace Json 00022 00023 namespace Datacratic { 00024 namespace JS { 00025 00026 struct JSValue; 00027 struct JSObject; 00028 00029 void to_js(JSValue & jsval, signed int value); 00030 void to_js(JSValue & jsval, unsigned int value); 00031 void to_js(JSValue & jsval, signed long value); 00032 void to_js(JSValue & jsval, unsigned long value); 00033 void to_js(JSValue & jsval, signed long long value); 00034 void to_js(JSValue & jsval, unsigned long long value); 00035 void to_js(JSValue & jsval, float value); 00036 void to_js(JSValue & jsval, double value); 00037 void to_js_bool(JSValue & jsval, bool value); 00038 void to_js(JSValue & jsval, const char * value); 00039 void to_js(JSValue & jsval, const std::string & value); 00040 void to_js(JSValue & jsval, const Utf8String & value); 00041 void to_js(JSValue & jsval, const Json::Value & value); 00042 void to_js(JSValue & jsval, const JSValue & value); 00043 00045 template<typename T> 00046 void to_js(JSValue & jsval, T value, 00047 typename boost::enable_if<typename boost::is_same<T, bool>::type, void *>::type = 0) 00048 { 00049 to_js_bool(jsval, value); 00050 } 00051 00052 signed int from_js(const JSValue & val, signed int *); 00053 unsigned int from_js(const JSValue & val, unsigned *); 00054 signed long from_js(const JSValue & val, signed long *); 00055 unsigned long from_js(const JSValue & val, unsigned long *); 00056 signed long long from_js(const JSValue & val, signed long long *); 00057 unsigned long long from_js(const JSValue & val, unsigned long long *); 00058 float from_js(const JSValue & val, float *); 00059 double from_js(const JSValue & val, double *); 00060 std::string from_js(const JSValue & val, std::string *); 00061 Utf8String from_js(const JSValue & val, Utf8String *); 00062 bool from_js(const JSValue & val, bool *); 00063 Json::Value from_js(const JSValue & val, Json::Value *); 00064 Json::Value from_js_ref(const JSValue & val, Json::Value *); 00065 00066 inline const JSValue & from_js(const JSValue & val, JSValue *) { return val; } 00067 00068 template<typename T> 00069 typename boost::enable_if<typename boost::is_enum<T>, T>::type 00070 from_js(const JSValue & val, T *) 00071 { 00072 int ival = from_js(val, (int *)0); 00073 return static_cast<T>(ival); 00074 } 00075 00076 } // namespace JS 00077 } // namespace Datacratic 00078 00079 00080 #endif /* __js__js_value_fwd_h__ */