merge with master
[platform/framework/web/wrt-plugins-common.git] / src / CommonsJavaScript / Converter.h
index 302141d..ff196b6 100644 (file)
@@ -29,7 +29,6 @@
 
 namespace WrtDeviceApis {
 namespace CommonsJavaScript {
-
 class Converter : private DPL::Noncopyable
 {
   public:
@@ -229,14 +228,14 @@ class Converter : private DPL::Noncopyable
     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.
@@ -277,12 +276,12 @@ class Converter : private DPL::Noncopyable
     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.
@@ -292,7 +291,7 @@ class Converter : private DPL::Noncopyable
      */
     JSValueRef toJSValueRef(long long int arg);
 
-  /**
+    /**
      * Converts STL string to JSValueRef.
      * @param arg STL string to convert.
      * @return JSValueRef object.
@@ -325,22 +324,22 @@ class Converter : private DPL::Noncopyable
     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.
@@ -397,16 +396,18 @@ class Converter : private DPL::Noncopyable
 
     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;
@@ -420,15 +421,17 @@ class Converter : private DPL::Noncopyable
 
     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;
@@ -442,13 +445,14 @@ class Converter : private DPL::Noncopyable
 
     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) {
@@ -489,7 +493,8 @@ class Converter : private DPL::Noncopyable
         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();
@@ -506,13 +511,14 @@ class Converter : private DPL::Noncopyable
 
     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();
@@ -534,7 +540,8 @@ class Converter : private DPL::Noncopyable
     {
         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();
     }
@@ -572,7 +579,6 @@ class ConverterFactory : private DPL::Noncopyable
 typedef ConverterFactory<Converter> BasicConverterFactory;
 
 typedef BasicConverterFactory::ConverterType BasicConverter;
-
 } // CommonsJavaScript
 } // WrtDeviceApis