namespace WrtDeviceApis {
namespace CommonsJavaScript {
-
class Converter : private DPL::Noncopyable
{
public:
std::vector<std::string> toVectorOfStrings(const JSValueRef& arg);
/**
- * Converts JSValueRef to vector of time_t.
- * @param arg JSValueRef to convert.
- * @return std::vector<std::time_t>
- * @throw ConversionException Thrown when conversion fails.
- */
- std::vector<std::time_t> toVectorOfTimeT(const JSValueRef& arg);
+ * Converts JSValueRef to vector of time_t.
+ * @param arg JSValueRef to convert.
+ * @return std::vector<std::time_t>
+ * @throw ConversionException Thrown when conversion fails.
+ */
+ std::vector<std::time_t> toVectorOfTimeT(const JSValueRef& arg);
- /**
+ /**
* Converts boolean value to JSValueRef.
* @param arg Boolean value to convert.
* @return JSValueRef object.
JSValueRef toJSValueRef(unsigned long arg);
/**
- * Converts long value to JSValueRef.
- * @param arg long value to convert.
- * @return JSValueRef object.
- * @throw ConversionException Thrown when conversion fails.
- */
- JSValueRef toJSValueRefLong(const long arg);
+ * Converts long value to JSValueRef.
+ * @param arg long value to convert.
+ * @return JSValueRef object.
+ * @throw ConversionException Thrown when conversion fails.
+ */
+ JSValueRef toJSValueRefLong(const long arg);
/**
* Converts unsigned long value to JSValueRef.
*/
JSValueRef toJSValueRef(long long int arg);
- /**
+ /**
* Converts STL string to JSValueRef.
* @param arg STL string to convert.
* @return JSValueRef object.
JSValueRef toJSValueRef(const tm& arg);
/**
- * Converts STL vector of integer to JSValueRef.
- * @param arg STL vector of integer to convert.
- * @return JSValueRef object.
- * @throw ConversionException Thrown when conversion fails.
- */
- JSValueRef toJSValueRef(const std::vector<int>& arg);
+ * Converts STL vector of integer to JSValueRef.
+ * @param arg STL vector of integer to convert.
+ * @return JSValueRef object.
+ * @throw ConversionException Thrown when conversion fails.
+ */
+ JSValueRef toJSValueRef(const std::vector<int>& arg);
- /**
- * Converts STL vector of time_t to JSValueRef.
- * @param arg STL vector of time_t to convert.
- * @return JSValueRef object.
- * @throw ConversionException Thrown when conversion fails.
- */
- JSValueRef toJSValueRef(const std::vector<time_t>& arg);
+ /**
+ * Converts STL vector of time_t to JSValueRef.
+ * @param arg STL vector of time_t to convert.
+ * @return JSValueRef object.
+ * @throw ConversionException Thrown when conversion fails.
+ */
+ JSValueRef toJSValueRef(const std::vector<time_t>& arg);
- /**
+ /**
* Converts STL vector of string to JSStringRef.
* @param arg STL string to convert.
* @return JSValueRef object.
template<typename T, class Derived>
std::vector<T> toVectorOfT_(const JSValueRef& arg,
- T (Derived::*f)(const JSValueRef &),
- Derived* object)
+ T (Derived::*f)(const JSValueRef &),
+ Derived* object)
{
if (JSValueIsNull(m_context,
- arg) || JSValueIsUndefined(m_context, arg)) {
+ arg) || JSValueIsUndefined(m_context, arg))
+ {
return std::vector<T>();
}
if (!JSIsArrayValue(m_context, arg)) {
- ThrowMsg(Commons::ConversionException, "Argument is not an JS array.");
+ ThrowMsg(Commons::ConversionException,
+ "Argument is not an JS array.");
}
std::vector<T> result;
template<typename T>
std::vector<T> toVectorOfT_(const JSValueRef& arg,
- T (Converter::*f)(const JSValueRef &))
+ T (Converter::*f)(const JSValueRef &))
{
if (JSValueIsNull(m_context,
- arg) || JSValueIsUndefined(m_context, arg)) {
+ arg) || JSValueIsUndefined(m_context, arg))
+ {
return std::vector<T>();
}
if (!JSIsArrayValue(m_context, arg)) {
- ThrowMsg(Commons::ConversionException, "Argument is not an JS array.");
+ ThrowMsg(Commons::ConversionException,
+ "Argument is not an JS array.");
}
std::vector<T> result;
template<class T, class Derived>
JSValueRef toJSValueRef_(const std::vector<T>& arg,
- JSValueRef (Derived::*f)(const T &),
- Derived* object)
+ JSValueRef (Derived::*f)(const T &),
+ Derived* object)
{
JSObjectRef jsResult = JSCreateArrayObject(m_context, 0, NULL);
if (NULL == jsResult) {
- ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Could not create js array object");
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException,
+ "Could not create js array object");
}
for (std::size_t i = 0; i < arg.size(); ++i) {
JSObjectRef jsResult = JSCreateArrayObject(m_context, 0, NULL);
if (NULL == jsResult) {
- ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Could not create js array object");
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException,
+ "Could not create js array object");
}
typename std::list<T>::const_iterator it = arg.begin();
template<class T, class Derived>
JSValueRef toJSValueRef_(const std::list<T>& arg,
- JSValueRef (Derived::*f)(const T &),
- Derived* object)
+ JSValueRef (Derived::*f)(const T &),
+ Derived* object)
{
JSObjectRef jsResult = JSCreateArrayObject(m_context, 0, NULL);
if (NULL == jsResult) {
- ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Could not create js array object");
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException,
+ "Could not create js array object");
}
typename std::list<T>::const_iterator it = arg.begin();
{
std::stringstream ss;
if (!(ss << arg)) {
- ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Could not convert to string.");
+ ThrowMsg(WrtDeviceApis::Commons::ConversionException,
+ "Could not convert to string.");
}
return ss.str();
}
typedef ConverterFactory<Converter> BasicConverterFactory;
typedef BasicConverterFactory::ConverterType BasicConverter;
-
} // CommonsJavaScript
} // WrtDeviceApis