Merge "[2.2.1] Modify doxygen example of Encode/DecodeBase64StringN" into tizen_2.2
[platform/framework/native/appfw.git] / src / io / FIo_DataSetEnumeratorImpl.cpp
old mode 100755 (executable)
new mode 100644 (file)
index b3e5d8f..ff0f4a2
@@ -1,5 +1,4 @@
 //
-// Open Service Platform
 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
 //
 // Licensed under the Apache License, Version 2.0 (the License);
@@ -52,24 +51,33 @@ namespace Tizen { namespace Io
 {
 
 _DataSetEnumeratorImpl::_DataSetEnumeratorImpl(void)
-       : __pDataSet(null),
-       __pColumnList(null),
-       __pCurrentRow(null),
-       __columnCount(0),
-       __rowCount(0),
-       __currentRowIndex(-1)
+       : __pDataSet(null)
+       , __pColumnList(null)
+       , __pCurrentRow(null)
+       , __columnCount(0)
+       , __rowCount(0)
+       , __currentRowIndex(-1)
+       , __dataSetDeleted(false)
 {
 
 }
 
 _DataSetEnumeratorImpl::~_DataSetEnumeratorImpl(void)
 {
-
+       if (!__dataSetDeleted)
+       {
+               __pEnumImplList->Remove(*this);
+       }
 }
 
 result
 _DataSetEnumeratorImpl::MoveNext(void)
 {
+       SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE,
+                               "The Object is not constructed.");
+       SysTryReturnResult(NID_IO, __dataSetDeleted != true, E_INVALID_STATE,
+                               "The dataset is already been deleted.");
+
        if (__currentRowIndex +1  == __rowCount)
                return E_OUT_OF_RANGE;
 
@@ -85,6 +93,11 @@ _DataSetEnumeratorImpl::MoveNext(void)
 result
 _DataSetEnumeratorImpl::MovePrevious(void)
 {
+       SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE,
+                               "The Object is not constructed.");
+       SysTryReturnResult(NID_IO, __dataSetDeleted != true, E_INVALID_STATE,
+                               "The dataset is already been deleted.");
+
        if (__currentRowIndex == 0)
                return E_OUT_OF_RANGE;
 
@@ -100,6 +113,11 @@ _DataSetEnumeratorImpl::MovePrevious(void)
 result
 _DataSetEnumeratorImpl::MoveFirst(void)
 {
+       SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE,
+                               "The Object is not constructed.");
+       SysTryReturnResult(NID_IO, __dataSetDeleted != true, E_INVALID_STATE,
+                               "The dataset is already been deleted.");
+
        __currentRowIndex = 0;
        __pCurrentRow = static_cast<ArrayList*>(__pDataSet->GetAt(__currentRowIndex));
 
@@ -112,6 +130,11 @@ _DataSetEnumeratorImpl::MoveFirst(void)
 result
 _DataSetEnumeratorImpl::MoveLast(void)
 {
+       SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE,
+                               "The Object is not constructed.");
+       SysTryReturnResult(NID_IO, __dataSetDeleted != true, E_INVALID_STATE,
+                               "The dataset is already been deleted.");
+
        __currentRowIndex = __rowCount -1;
        __pCurrentRow = static_cast<ArrayList*>(__pDataSet->GetAt(__currentRowIndex));
 
@@ -124,6 +147,11 @@ _DataSetEnumeratorImpl::MoveLast(void)
 result
 _DataSetEnumeratorImpl::Reset(void)
 {
+       SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE,
+                               "The Object is not constructed.");
+       SysTryReturnResult(NID_IO, __dataSetDeleted != true, E_INVALID_STATE,
+                               "The dataset is already been deleted.");
+
        __currentRowIndex = -1;
        __pCurrentRow = null;
 
@@ -136,7 +164,9 @@ _DataSetEnumeratorImpl::GetIntAt(int columnIndex, int& value) const
        result r = E_SUCCESS;
 
        SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE,
-                               "The Object is not constructed or the dataset is already been deleted.");
+                               "The Object is not constructed.");
+       SysTryReturnResult(NID_IO, __dataSetDeleted != true, E_INVALID_STATE,
+                               "The dataset is already been deleted.");
        SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG,
                                "Given column index is out of range.");
        SysTryReturnResult(NID_IO, __pCurrentRow != null, E_INVALID_STATE,
@@ -166,7 +196,9 @@ _DataSetEnumeratorImpl::GetInt64At(int columnIndex, long long& value) const
        result r = E_SUCCESS;
 
        SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE,
-                               "The Object is not constructed or the dataset is already been deleted.");
+                               "The Object is not constructed.");
+       SysTryReturnResult(NID_IO, __dataSetDeleted != true, E_INVALID_STATE,
+                               "The dataset is already been deleted.");
        SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG,
                                "Given column index is out of range.");
        SysTryReturnResult(NID_IO, __pCurrentRow != null, E_INVALID_STATE,
@@ -196,7 +228,9 @@ _DataSetEnumeratorImpl::GetDoubleAt(int columnIndex, double& value) const
        result r = E_SUCCESS;
 
        SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE,
-                               "The Object is not constructed or the dataset is already been deleted.");
+                               "The Object is not constructed.");
+       SysTryReturnResult(NID_IO, __dataSetDeleted != true, E_INVALID_STATE,
+                               "The dataset is already been deleted.");
        SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG,
                                "Given column index is out of range.");
        SysTryReturnResult(NID_IO, __pCurrentRow != null, E_INVALID_STATE,
@@ -226,7 +260,9 @@ _DataSetEnumeratorImpl::GetStringAt(int columnIndex, String& value) const
        result r = E_SUCCESS;
 
        SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE,
-                               "The Object is not constructed or the dataset is already been deleted.");
+                               "The Object is not constructed.");
+       SysTryReturnResult(NID_IO, __dataSetDeleted != true, E_INVALID_STATE,
+                               "The dataset is already been deleted.");
        SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG,
                                "Given column index is out of range.");
        SysTryReturnResult(NID_IO, __pCurrentRow != null, E_INVALID_STATE,
@@ -256,7 +292,9 @@ _DataSetEnumeratorImpl::GetBlobAt(int columnIndex, ByteBuffer& value) const
        ByteBuffer* pBuffer = null;
 
        SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE,
-                               "The Object is not constructed or the dataset is already been deleted.");
+                               "The Object is not constructed.");
+       SysTryReturnResult(NID_IO, __dataSetDeleted != true, E_INVALID_STATE,
+                               "The dataset is already been deleted.");
        SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG,
                                "Given column index is out of range.");
        SysTryReturnResult(NID_IO, __pCurrentRow != null, E_INVALID_STATE,
@@ -290,7 +328,9 @@ _DataSetEnumeratorImpl::GetBlobAt(int columnIndex, void* buffer, int size) const
        ByteBuffer* pBuffer = null;
 
        SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE,
-                               "The Object is not constructed or the dataset is already been deleted.");
+                               "The Object is not constructed.");
+       SysTryReturnResult(NID_IO, __dataSetDeleted != true, E_INVALID_STATE,
+                               "The dataset is already been deleted.");
        SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG,
                                "Given column index is out of range.");
        SysTryReturnResult(NID_IO, __pCurrentRow != null, E_INVALID_STATE,
@@ -329,7 +369,9 @@ _DataSetEnumeratorImpl::GetDateTimeAt(int columnIndex, DateTime& value) const
        String* pStr = null;
 
        SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE,
-                               "The instance is not constructed or the dataset is already been deleted.");
+                               "The Object is not constructed.");
+       SysTryReturnResult(NID_IO, __dataSetDeleted != true, E_INVALID_STATE,
+                               "The dataset is already been deleted.");
        SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG,
                                "Given column index is out of range.");
        SysTryReturnResult(NID_IO, __pCurrentRow != null, E_INVALID_STATE,
@@ -357,8 +399,10 @@ CATCH:
 int
 _DataSetEnumeratorImpl::GetColumnCount(void) const
 {
-       SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE,
-                               "The Object is not constructed or the dataset is already been deleted.");
+       SysTryReturn(NID_IO, __pDataSet != null, -1, E_INVALID_STATE,
+                               "[E_INVALID_STATE] The Object is not constructed.");
+       SysTryReturn(NID_IO, __dataSetDeleted != true, -1, E_INVALID_STATE,
+                               "[E_INVALID_STATE] The dataset is already been deleted.");
 
        return __columnCount;
 }
@@ -369,8 +413,9 @@ _DataSetEnumeratorImpl::GetColumnType(int columnIndex) const
        DbColumnType type = DB_COLUMNTYPE_UNDEFINED;
 
        SysTryReturn(NID_IO, __pDataSet != null, DB_COLUMNTYPE_UNDEFINED, E_INVALID_STATE,
-                               "[E_INVALID_STATE] The instance is not constructed or the dataset is already been deleted.");
-
+                               "[E_INVALID_STATE] The instance is not constructed.");
+       SysTryReturn(NID_IO, __dataSetDeleted != true, DB_COLUMNTYPE_UNDEFINED, E_INVALID_STATE,
+                               "[E_INVALID_STATE] The dataset is already been deleted.");
        SysTryReturn(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, DB_COLUMNTYPE_UNDEFINED, E_INVALID_ARG,
                                "[E_INVALID_ARG] Given column index is out of range.");
 
@@ -383,10 +428,10 @@ _DataSetEnumeratorImpl::GetColumnType(int columnIndex) const
                        return DB_COLUMNTYPE_UNDEFINED;
                }
 
-               type = pDataItem->type;
-               switch (type)
+               switch (pDataItem->type)
                {
                case DB_COLUMNTYPE_INT:
+               case DB_COLUMNTYPE_INT64:
                case DB_COLUMNTYPE_DOUBLE:
                case DB_COLUMNTYPE_TEXT:
                case DB_COLUMNTYPE_BLOB:
@@ -407,8 +452,9 @@ String
 _DataSetEnumeratorImpl::GetColumnName(int columnIndex) const
 {
        SysTryReturn(NID_IO, __pDataSet != null, null, E_INVALID_STATE,
-                               "[E_INVALID_STATE] The instance is not constructed or the dataset is already been deleted.");
-
+                               "[E_INVALID_STATE] The instance is not constructed.");
+       SysTryReturn(NID_IO, __dataSetDeleted != true, null, E_INVALID_STATE,
+                               "[E_INVALID_STATE] The dataset is already been deleted.");
        SysTryReturn(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, null, E_INVALID_ARG,
                                "[E_INVALID_ARG] Given column index is out of range.");
 
@@ -429,13 +475,13 @@ _DataSetEnumeratorImpl::GetColumnSize(int columnIndex) const
 {
        int bytes = 0;
 
-       SysTryReturn(NID_IO, __pDataSet != null, 0, E_INVALID_STATE,
-                               "[E_INVALID_STATE] The instance is not constructed or the dataset is already been deleted.");
-
-       SysTryReturn(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, 0, E_INVALID_ARG,
+       SysTryReturn(NID_IO, __pDataSet != null, -1, E_INVALID_STATE,
+               "[E_INVALID_STATE] The instance is not constructed.");
+       SysTryReturn(NID_IO, __dataSetDeleted != true, -1, E_INVALID_STATE,
+                               "[E_INVALID_STATE] The dataset is already been deleted.");
+       SysTryReturn(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, -1, E_INVALID_ARG,
                                "[E_INVALID_ARG] Given column index is out of range.");
-
-       SysTryReturn(NID_IO, __pCurrentRow != null, 0, E_INVALID_STATE,
+       SysTryReturn(NID_IO, __pCurrentRow != null, -1, E_INVALID_STATE,
                                "[E_INVALID_STATE] The method has tried to fetch the column data of a result set that is not activated.");
 
        _DataItem* pDataItem = dynamic_cast < _DataItem* >(__pCurrentRow->GetAt(columnIndex));