tizen 2.4 release
[framework/web/wrt-commons.git] / modules / db / include / dpl / db / orm.h
old mode 100644 (file)
new mode 100755 (executable)
similarity index 96%
rename from modules_wearable/db/include/dpl/db/orm.h
rename to modules/db/include/dpl/db/orm.h
index 652e8e1..fc5f88f
 #include <typeinfo>
 #include <utility>
 #include <set>
+#include <list>
 #include <memory>
+#include <boost/optional.hpp>
 
+#include <dpl/log/wrt_log.h>
 #include <dpl/db/sql_connection.h>
 #include <dpl/db/orm_interface.h>
 #include <dpl/string.h>
-#include <dpl/optional.h>
 #include <dpl/type_list.h>
 #include <dpl/assert.h>
 #include <dpl/foreach.h>
@@ -56,8 +58,8 @@ namespace ORM {
 
 typedef size_t ColumnIndex;
 typedef size_t ArgumentIndex;
-typedef DPL::Optional<DPL::String> OptionalString;
-typedef DPL::Optional<int> OptionalInteger;
+typedef boost::optional<DPL::String> OptionalString;
+typedef boost::optional<int> OptionalInteger;
 typedef DPL::DB::SqlConnection::DataCommand DataCommand;
 
 namespace RelationTypes {
@@ -430,6 +432,12 @@ public:
     {
         CustomRowUtil<ColumnList>::CopyColumnList(r.m_columns, m_columns);
     }
+    CustomRow& operator=(const CustomRow& r)
+    {
+        if(this == &r) return *this;
+        CustomRowUtil<ColumnList>::CopyColumnList(r.m_columns, m_columns);
+        return *this;
+    }
 
     virtual ~CustomRow()
     {
@@ -663,7 +671,7 @@ protected:
             this->m_command = TableDefinition::AllocTableDataCommand(
                     this->m_commandString.c_str(),
                     Query<TableDefinition>::m_interface);
-            LogPedantic("Prepared SQL command " << this->m_commandString);
+            //WrtLogD("Prepared SQL command %s", this->m_commandString.c_str());
         }
     }
 
@@ -719,7 +727,7 @@ public:
     typedef DPL::DB::SqlConnection::RowID RowID;
 
 protected:
-    DPL::Optional<std::string> m_orClause;
+    boost::optional<std::string> m_orClause;
     Row m_row;
 
     class PrepareVisitor {
@@ -761,7 +769,7 @@ protected:
             this->m_commandString += " ( " + visitor.m_columnNames + " ) ";
             this->m_commandString += "VALUES ( " + visitor.m_values + " )";
 
-            LogPedantic("Prepared SQL command " << this->m_commandString);
+            //WrtLogD("Prepared SQL command %s", this->m_commandString.c_str());
             this->m_command = TableDefinition::AllocTableDataCommand(
                 this->m_commandString.c_str(),
                 Query<TableDefinition>::m_interface);
@@ -777,7 +785,7 @@ protected:
 public:
     explicit Insert(
             IOrmInterface* interface = NULL,
-            const DPL::Optional<std::string>& orClause = DPL::Optional<std::string>::Null) :
+            const boost::optional<std::string>& orClause = boost::optional<std::string>()) :
         Query<TableDefinition>(interface),
         m_orClause(orClause)
     {
@@ -820,7 +828,7 @@ public:
 
     typedef std::list<Row>                             RowList;
 protected:
-    DPL::Optional<std::string> m_orderBy;
+    boost::optional<std::string> m_orderBy;
     std::string m_JoinClause;
     bool                       m_distinctResults;
 
@@ -839,7 +847,7 @@ protected:
 
             QueryWithWhereClause<TableDefinition>::Prepare();
 
-            if ( !m_orderBy.IsNull() )
+            if ( !!m_orderBy )
             {
                 this->m_commandString += " ORDER BY " + *m_orderBy;
             }
@@ -848,7 +856,7 @@ protected:
                 this->m_commandString.c_str(),
                 Query<TableDefinition>::m_interface);
 
-            LogPedantic("Prepared SQL command " << this->m_commandString);
+            //WrtLogD("Prepared SQL command %s", this->m_commandString.c_str());
         }
     }
 
@@ -1012,7 +1020,7 @@ public:
     typedef typename TableDefinition::Row Row;
 
 protected:
-    DPL::Optional<std::string> m_orClause;
+    boost::optional<std::string> m_orClause;
     Row m_row;
 
     class PrepareVisitor {
@@ -1064,7 +1072,7 @@ protected:
             this->m_command = TableDefinition::AllocTableDataCommand(
                     this->m_commandString.c_str(),
                     Query<TableDefinition>::m_interface);
-            LogPedantic("Prepared SQL command " << this->m_commandString);
+            //WrtLogD("Prepared SQL command %s", this->m_commandString.c_str());
         }
     }
 
@@ -1080,7 +1088,7 @@ protected:
 
 public:
     explicit Update(IOrmInterface *interface = NULL,
-                    const DPL::Optional<std::string>& orClause = DPL::Optional<std::string>::Null) :
+                    const boost::optional<std::string>& orClause = boost::optional<std::string>()) :
         QueryWithWhereClause<TableDefinition>(interface),
         m_orClause(orClause)
     {