From c23921609ced7d8dacd757e9298e76093d708c81 Mon Sep 17 00:00:00 2001 From: SeungYeup Kim Date: Mon, 18 Mar 2013 12:42:07 +0900 Subject: [PATCH] Implement DataSet/DataRow/DataSetEnumerator Class Change-Id: Iaa382d014b92ed67739472326ff9e71728f354c6 --- inc/FIoDataRow.h | 186 +++++++++++++ inc/FIoDataSet.h | 161 +++++++++++ inc/FIoDataSetEnumerator.h | 380 ++++++++++++++++++++++++++ src/io/CMakeLists.txt | 6 + src/io/FIoDataRow.cpp | 85 ++++++ src/io/FIoDataSet.cpp | 113 ++++++++ src/io/FIoDataSetEnumerator.cpp | 158 +++++++++++ src/io/FIo_DataRowImpl.cpp | 410 ++++++++++++++++++++++++++++ src/io/FIo_DataSetEnumeratorImpl.cpp | 476 +++++++++++++++++++++++++++++++++ src/io/FIo_DataSetImpl.cpp | 159 +++++++++++ src/io/inc/FIo_DataRowImpl.h | 113 ++++++++ src/io/inc/FIo_DataSetEnumeratorImpl.h | 177 ++++++++++++ src/io/inc/FIo_DataSetImpl.h | 78 ++++++ 13 files changed, 2502 insertions(+) create mode 100755 inc/FIoDataRow.h create mode 100755 inc/FIoDataSet.h create mode 100755 inc/FIoDataSetEnumerator.h mode change 100644 => 100755 src/io/CMakeLists.txt create mode 100755 src/io/FIoDataRow.cpp create mode 100755 src/io/FIoDataSet.cpp create mode 100755 src/io/FIoDataSetEnumerator.cpp create mode 100755 src/io/FIo_DataRowImpl.cpp create mode 100755 src/io/FIo_DataSetEnumeratorImpl.cpp create mode 100755 src/io/FIo_DataSetImpl.cpp create mode 100755 src/io/inc/FIo_DataRowImpl.h create mode 100755 src/io/inc/FIo_DataSetEnumeratorImpl.h create mode 100755 src/io/inc/FIo_DataSetImpl.h diff --git a/inc/FIoDataRow.h b/inc/FIoDataRow.h new file mode 100755 index 0000000..d3b37fa --- /dev/null +++ b/inc/FIoDataRow.h @@ -0,0 +1,186 @@ +// +// Open Service Platform +// Copyright (c) 2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** +* @file FIoDataRow.h +* @brief This is the header file for the %DataRow class. +* +* This header file contains the declarations of the %DataRow class. +*/ + +#ifndef _FIO_DATA_ROW_H_ +#define _FIO_DATA_ROW_H_ + +#include +#include +#include + +namespace Tizen { namespace Io +{ + +/** +* @class DataRow + +* @brief This class provides methods to create a row in in-memory table. +* +* @since 2.1 +* +* @final This class is not intended for extension. +* +* The %DataRow class provides methods to create a row in in-memory table. +* +* @see Tizen::Io::DataSet +*/ +class _OSP_EXPORT_ DataRow + : public Tizen::Base::Object +{ + +public: + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.1 + */ + virtual ~DataRow(void); + + /** + * Sets a @c ByteBuffer value to the column whose index is specified. + * + * @since 2.1 + * + * @return An error code + * @param[in] columnIndex The index of the column whose value is set @n + * The column index starts from 0. + * @param[in] pValue The value to set @n + * The specified @c pValue is pointer to user-provided @c ByteBuffer type buffer. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG Either of the following conditions has occurred: @n + * - The specified @c columnIndex is out of range. + * - The specified @c pValue is null. + * @exception E_TYPE_MISMATCH The operation has attempted to access columns of different types. + * @remarks This method performs a shallow copy. It copies only the pointer; not the element itself. @n + * The platform will take the ownership of @c pValue after calling this method. + */ + result SetBlobAt(int columnIndex, Tizen::Base::ByteBuffer* pValue); + + + /** + * Sets a @c DateTime value to the column whose index is specified. + * + * @since 2.1 + * + * @return An error code + * @param[in] columnIndex The index of the column whose value is set @n + * The column index starts from 0. + * @param[in] value The value to set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c columnIndex is out of range. + * @exception E_TYPE_MISMATCH The operation has attempted to access columns of different types. + */ + result SetDateTimeAt(int columnIndex, const Tizen::Base::DateTime& value); + + + /** + * Sets a @c double value to the column whose index is specified. + * + * @since 2.1 + * + * @return An error code + * @param[in] columnIndex The index of the column whose value is set @n + * The column index starts from 0. + * @param[in] value The value to set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c columnIndex is out of range. + * @exception E_TYPE_MISMATCH The operation has attempted to access columns of different types. + */ + result SetDoubleAt(int columnIndex, double value); + + /** + * Sets an @c int value to the column whose index is specified. + * + * @since 2.1 + * + * @return An error code + * @param[in] columnIndex The index of the column whose value is set @n + * The column index starts from 0. + * @param[in] value The value to set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c columnIndex is out of range. + * @exception E_TYPE_MISMATCH The operation has attempted to access columns of different types. + */ + result SetIntAt(int columnIndex, int value); + + /** + * Sets a @c long @c long value to the column whose index is specified. + * + * @since 2.1 + * + * @return An error code + * @param[in] columnIndex The index of the column whose value is set @n + * The column index starts from 0. + * @param[in] value The value to set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c columnIndex is out of range. + * @exception E_TYPE_MISMATCH The operation has attempted to access columns of different types. + */ + result SetInt64At(int columnIndex, long long value); + + /** + * Sets a @c String value to the column whose index is specified. + * + * @since 2.1 + * + * @return An error code + * @param[in] columnIndex The index of the column whose value is set @n + * The column index starts from 0. + * @param[in] value The value to set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c columnIndex is out of range. + * @exception E_TYPE_MISMATCH The operation has attempted to access columns of different types. + */ + result SetStringAt(int columnIndex, const Tizen::Base::String& value); + +private: + // + // This default constructor is intentionally declared as private so that only the platform can create an instance. + // + // @since 2.1 + // + DataRow(void); + + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + // @since 2.1 + // + DataRow(const DataRow& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + // @since 2.1 + // + DataRow& operator =(const DataRow& rhs); + + class _DataRowImpl* __pDataRowImpl; + friend class _DataRowImpl; + +}; // DataRow + +}} // Tizen::Io + +#endif // _FIO_DATA_ROW_H_ diff --git a/inc/FIoDataSet.h b/inc/FIoDataSet.h new file mode 100755 index 0000000..2edbd79 --- /dev/null +++ b/inc/FIoDataSet.h @@ -0,0 +1,161 @@ +// +// Open Service Platform +// Copyright (c) 2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** +* @file FIoDataSet.h +* @brief This is the header file for the %DataSet class. +* +* This header file contains the declarations of the %DataSet class. +*/ + +#ifndef _FIO_DATA_SET_H_ +#define _FIO_DATA_SET_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Io +{ + +/** +* @class DataSet +* @brief This class provides methods to manipulate in-memory table. +* +* @since 2.1 +* +* @final This class is not intended for extension. +* +* The %DataSet class provides methods to manipulate in-memory table. +*/ +class _OSP_EXPORT_ DataSet + : public Tizen::Base::Object +{ + +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, + * the Construct() method must be called right after calling this constructor. + * + * @since 2.1 + */ + DataSet(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.1 + */ + virtual ~DataSet(void); + + /** + * Creates in-memory table. + * + * @since 2.1 + * + * @return An error code + * @param[in] columnNames The list of column name to create @n + * The object type in the specified list should be String. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c columnNames has no element. + */ + result Construct(const Tizen::Base::Collection::IList& columnNames); + + /** + * Creates a row in the table. + * + * @since 2.1 + * + * @return A pointer to the DataRow instance, @n + * else @c null if the memory is insufficient + * @remarks The column type is decided by the type of each element inserted in first row. + * If a specific column element on the first row is not inserted, then the column's type is DB_COLUMNTYPE_NULL + * On that case, when a new column element is added later, + * then the column's type will be changed according to the new element. + */ + DataRow* CreateDataRowN(void); + + /** + * Gets table enumerator. + * + * @since 2.1 + * + * @return A pointer to the DataSetEnumerator instance, @n + * else @c null if the memory is insufficient + */ + DataSetEnumerator* GetDataSetEnumeratorN(void); + + + /** + * Get copy of this instance. + * + * @since 2.1 + * + * @return A pointer to the copy of the DataSet instance, @n + + * else @c null if the memory is insufficient + */ + DataSet* CloneN(void) const; + + /** + * Checks whether the value of the specified instance of Object is equal to the value of the current instance of + * %DataSet. + * + * @since 2.1 + * + * @return @c true if the value of the specified instance of Object is equal to the value of the current + * instance of %DataSet, @n + * else @c false + * @param[in] obj An instance of Object to compare + * @remarks The method returns @c false if the specified @c obj is not a %DataSet instance. + */ + virtual bool Equals(const Tizen::Base::Object& obj) const; + + /** + * Gets the hash value of the current instance. + * + * @since 2.1 + * + * @return The hash value of the current instance + */ + virtual int GetHashCode(void) const; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + // @since 2.1 + // + + DataSet(const DataSet& value); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + // @since 2.1 + // + DataSet& operator =(const DataSet& rhs); + + class _DataSetImpl* __pDataSetImpl; + friend class _DataSetImpl; + +}; // DataSet + +}} // Tizen::Io + +#endif // _FIO_DATA_SET_H_ diff --git a/inc/FIoDataSetEnumerator.h b/inc/FIoDataSetEnumerator.h new file mode 100755 index 0000000..2b80057 --- /dev/null +++ b/inc/FIoDataSetEnumerator.h @@ -0,0 +1,380 @@ +// +// Open Service Platform +// Copyright (c) 2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** +* @file FIoDataSetEnumerator.h +* @brief This is the header file for the %DataSetEnumerator class. +* +* This header file contains the declarations of the %DataSetEnumerator class. +*/ + +#ifndef _FIO_DATA_SET_ENUMERATOR_H_ +#define _FIO_DATA_SET_ENUMERATOR_H_ + +#include +#include +#include +#include +#include + +namespace Tizen { namespace Base +{ +class String; +class ByteBuffer; +class DateTime; +}} + +namespace Tizen { namespace Io +{ + +/** +* @class DataSetEnumerator +* @brief This class provides methods for navigating the set of data in in-memory table. +* +* @since 2.1 +* +* @final This class is not intended for extension. +* +* The %DataSetEnumerator class provides methods for navigating the set of data in in-memory table. +* +* @see Tizen::Io::DataSet +*/ +class _OSP_EXPORT_ DataSetEnumerator + : public Tizen::Base::Object + , public Tizen::Io::IDbEnumerator +{ + +public: + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.1 + */ + virtual ~DataSetEnumerator(void); + + /** + * Moves the enumerator to the next position. + * + * @since 2.1 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE The DataSet instance associated with this instance is deleted. + * @exception E_OUT_OF_RANGE The enumerator has reached out of the data set. + * @exception E_OBJECT_LOCKED The DataSet instance is locked. + * @exception E_INVALID_FORMAT The in-memory data is malformed. + * @exception E_IO Either of the following conditions has occurred: @n + * - An unexpected device failure has occurred as the media ejected suddenly. @n + * - %File corruption is detected. + * @exception E_SYSTEM The method cannot proceed due to a severe system error. + * @remarks After getting this DataSetEnumerator instance, + * if MoveNext() is called at first, the cursor goes to the first position. + * @see Tizen::Io::DataSetEnumerator::MovePrevious() + * @see Tizen::Io::DataSetEnumerator::MoveFirst() + * @see Tizen::Io::DataSetEnumerator::MoveLast() + */ + virtual result MoveNext(void); + + + /** + * Moves the enumerator to the previous position. + * + * @since 2.1 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE The DataSet instance associated with this instance is deleted. + * @exception E_OUT_OF_RANGE The enumerator has reached out of the data set. + * @exception E_OBJECT_LOCKED The DataSet instance is locked. + * @exception E_INVALID_FORMAT The in-memory data is malformed. + * @exception E_IO Either of the following conditions has occurred: @n + * - An unexpected device failure has occurred as the media ejected suddenly. @n + * - %File corruption is detected. + * @exception E_SYSTEM The method cannot proceed due to a severe system error. + * @see Tizen::Io::DataSetEnumerator::MoveNext() + * @see Tizen::Io::DataSetEnumerator::MoveFirst() + * @see Tizen::Io::DataSetEnumerator::MoveLast() + */ + virtual result MovePrevious(void); + + /** + * Moves the enumerator to the first position. + * + * @since 2.1 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE The DataSet instance associated with this instance is deleted. + * @exception E_OBJECT_LOCKED The DataSet instance is locked. + * @exception E_INVALID_FORMAT The in-memory data is malformed. + * @exception E_IO Either of the following conditions has occurred: @n + * - An unexpected device failure has occurred as the media ejected suddenly. @n + * - %File corruption is detected. + * @exception E_SYSTEM The method cannot proceed due to a severe system error. + * @see Tizen:Io::DataSetEnumerator::MoveNext() + * @see Tizen:Io::DataSetEnumerator::MovePrevious() + * @see Tizen:Io::DataSetEnumerator::MoveLast() + */ + virtual result MoveFirst(void); + + /** + * Moves the enumerator to the last position. + * + * @since 2.1 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE The DataSet instance associated with this instance is deleted. + * @exception E_OBJECT_LOCKED The DataSet instance is locked. + * @exception E_INVALID_FORMAT The in-memory data is malformed. + * @exception E_IO Either of the following conditions has occurred: @n + * - An unexpected device failure has occurred as the media ejected suddenly. @n + * - %File corruption is detected. + * @exception E_SYSTEM The method cannot proceed due to a severe system error. + * @see Tizen:Io::DataSetEnumerator::MoveNext() + * @see Tizen:Io::DataSetEnumerator::MovePrevious() + * @see Tizen:Io::DataSetEnumerator::MoveFirst() + */ + virtual result MoveLast(void); + + /** + * Resets the calling %DataSetEnumerator instance back to its initial state. + * + * @since 2.1 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE The DataSet instance associated with this instance is deleted. + * @exception E_OBJECT_LOCKED The DataSet instance is locked. + * @exception E_SYSTEM The method cannot proceed due to a severe system error. + * @remarks After this method is called, if MoveNext() is called the cursor goes to the first position. + */ + virtual result Reset(void); + + /** + * Gets an @c int value from the column whose index is specified. + * + * @since 2.1 + * + * @return An error code + * @param[in] columnIndex The index of the column whose value is required + * @param[in,out] value The integer value obtained from the specified column + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE The DataSet instance associated with this instance is deleted. + * @exception E_INVALID_ARG The specified @c columnIndex is out of range. + * @exception E_TYPE_MISMATCH The operation has attempted to access columns of different types. + */ + virtual result GetIntAt(int columnIndex, int& value) const; + + /** + * Gets a @c long @c long value from the column whose index is specified. + * + * @since 2.1 + * + * @return An error code + * @param[in] columnIndex The index of the column whose value is required + * @param[in,out] value The 64-bit integer value obtained from the specified column + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE The DataSet instance associated with this instance is deleted. + * @exception E_INVALID_ARG The specified @c columnIndex is out of range. + * @exception E_TYPE_MISMATCH The operation has attempted to access columns of different types. + */ + virtual result GetInt64At(int columnIndex, long long& value) const; + + /** + * Gets a @c double value from the column whose index is specified. + * + * @since 2.1 + * + * @return An error code + * @param[in] columnIndex The index of the column whose value is required + * @param[in,out] value The double value obtained from the specified column + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE The DataSet instance associated with this instance is deleted. + * @exception E_INVALID_ARG The specified @c columnIndex is out of range. + * @exception E_TYPE_MISMATCH The operation has attempted to access columns of different types. + */ + virtual result GetDoubleAt(int columnIndex, double& value) const; + + /** + * Gets a @c String value from the column whose index is specified. + * + * @since 2.1 + * + * @return An error code + * @param[in] columnIndex The index of the column whose value is required + * @param[in,out] value The String value obtained from the specified column + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE The DataSet instance associated with this instance is deleted. + * @exception E_INVALID_ARG The specified @c columnIndex is out of range. + * @exception E_TYPE_MISMATCH The operation has attempted to access columns of different types. + * @exception E_INVALID_ENCODING_RANGE The string conversion has failed due to invalid encoding range. + */ + virtual result GetStringAt(int columnIndex, Tizen::Base::String& value) const; + + /** + * Gets a @c ByteBuffer value from the column whose index is specified. + * + * @since 2.1 + * + * @return An error code + * @param[in] columnIndex The index of the column whose value is required + * @param[in,out] value The ByteBuffer value obtained from the specified column @n + * The ByteBuffer will be filled from the current position and data copy + * will be continued until ByteBuffer limitation is reached or no more + * blob data remains. @n + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE The DataSet instance associated with this instance is deleted. + + * @exception E_INVALID_ARG The specified @c columnIndex is out of range. + * @exception E_TYPE_MISMATCH The operation has attempted to access columns of different types. + * @exception E_OVERFLOW The specified ByteBuffer @c value is insufficient to save the data. + * @see Tizen::Base::ByteBuffer + */ + virtual result GetBlobAt(int columnIndex, Tizen::Base::ByteBuffer& value) const; + + /** + * Gets a blob data from the column whose index is specified. + * + * @since 2.1 + * + * @return An error code + * @param[in] columnIndex The index of the column whose value is required + * @param[in,out] buffer The user-provided buffer used to receive the blob data @n + * @param[in] size The maximum buffer length in bytes + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE The DataSet instance associated with this instance is deleted. + * @exception E_INVALID_ARG The specified @c columnIndex is out of range, or the specified @c size is invalid. + * @exception E_TYPE_MISMATCH The operation has attempted to access columns of different types. + * @exception E_OVERFLOW The specified @c buffer is insufficient to save the data. + */ + virtual result GetBlobAt(int columnIndex, void* buffer, int size) const; + + /** + * Gets a @c DateTime value from the column whose index is specified. + * + * @since 2.1 + * + * @return An error code + * @param[in] columnIndex The index of the column whose value is required + * @param[in,out] value The DateTime value obtained from the specified column + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE The DataSet instance associated with this instance is deleted. + * @exception E_INVALID_ARG The specified @c columnIndex is out of range. + * @exception E_TYPE_MISMATCH The operation has attempted to access columns of different types. + * @exception E_INVALID_FORMAT The date is not correctly formatted, or the method is trying to access column of type String. @n + * The date format should be 'mm/dd/yyyy hh:mm:ss'. + * @exception E_OUT_OF_RANGE Either the year, month, day, hour, minute, or second value is out of range, + * or the method is trying to access a column of type String. + */ + virtual result GetDateTimeAt(int columnIndex, Tizen::Base::DateTime& value) const; + + /** + * Gets the number of columns for this enumerator. + * + * @since 2.1 + * + * @return The number of columns in the calling enumerator, @n + * else @c -1 if an exception occurs + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE The DataSet instance associated with this instance is deleted. + * @remarks The method must be called after MoveNext(), MoveFirst(), or MoveLast(). @n + * The specific error code can be accessed using the GetLastResult() method. + */ + virtual int GetColumnCount(void) const; + + /** + * Gets the type of the column indicated by the specified index. + * + * @since 2.1 + * + * @return The type of column, @n + * else DB_COLUMNTYPE_UNDEFINED if an exception occurs + * @param[in] columnIndex The index of the destination column + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE The DataSet instance associated with this instance is deleted. + * @exception E_INVALID_ARG The specified @c columnIndex is out of range. + * @remarks The method must be called after MoveNext(), MoveFirst(), or MoveLast(). @n + * Currently, DB_COLUMNTYPE_INT is returned for a 64-bit integer. @n + * The specific error code can be accessed using the GetLastResult() method. + */ + virtual DbColumnType GetColumnType(int columnIndex) const; + + /** + * Gets the name of the column indicated by the specified index. + * + * @since 2.1 + * + * @return The name of the column, @n + * else an empty string if an exception occurs + * @param[in] columnIndex The index of the destination column + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE The DataSet instance associated with this instance is deleted. + * @exception E_INVALID_ARG The specified @c columnIndex is out of range. + * @exception E_INVALID_ENCODING_RANGE The string conversion has failed due to invalid encoding range. + * @remarks The method must be called after MoveNext(), MoveFirst(), or MoveLast(). @n + * The specific error code can be accessed using the GetLastResult() method. + */ + virtual Tizen::Base::String GetColumnName(int columnIndex) const; + + /** + * Gets the size of data in bytes. + * + * @since 2.1 + * + * @return The size of the data in bytes, @n + * else @c -1 if an exception occurs + * @param[in] columnIndex The index of the destination column + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE The DataSet instance associated with this instance is deleted. + * @exception E_INVALID_ARG The specified @c columnIndex is out of range. + * @remarks The method must be called after MoveNext(), MoveFirst(), or MoveLast(). @n + * If the destination column is of type String, this method returns the @c byte length excluding + * the @c null terminator character. @n + * The specific error code can be accessed using the GetLastResult() method. + */ + virtual int GetColumnSize(int columnIndex) const; + +private: + // + // This default constructor is intentionally declared as private so that only the platform can create an instance. + // + // @since 2.1 + // + DataSetEnumerator(void); + + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + // @since 2.1 + // + DataSetEnumerator(const DataSetEnumerator& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // @since 2.1 + // + DataSetEnumerator& operator =(const DataSetEnumerator& rhs); + + class _DataSetEnumeratorImpl* __pDataSetEnumeratorImpl; + friend class _DataSetEnumeratorImpl; + +}; // DataSetEnumerator + +}} // Tizen::Io + +#endif // _FIO_DATA_SET_ENUMERATOR_H_ diff --git a/src/io/CMakeLists.txt b/src/io/CMakeLists.txt old mode 100644 new mode 100755 index 0258a3b..ea5f0e8 --- a/src/io/CMakeLists.txt +++ b/src/io/CMakeLists.txt @@ -71,6 +71,12 @@ SET (${this_target}_SOURCE_FILES FIoRemoteMessagePort.cpp FIo_RemoteMessagePortImpl.cpp FIo_MessagePortProxy.cpp + FIoDataSet.cpp + FIo_DataSetImpl.cpp + FIoDataSetEnumerator.cpp + FIo_DataSetEnumeratorImpl.cpp + FIoDataRow.cpp + FIo_DataRowImpl.cpp FIo_ZipFileArchive.cpp FIoFileLock.cpp FIo_FileLockImpl.cpp diff --git a/src/io/FIoDataRow.cpp b/src/io/FIoDataRow.cpp new file mode 100755 index 0000000..b8f4860 --- /dev/null +++ b/src/io/FIoDataRow.cpp @@ -0,0 +1,85 @@ +// +// Open Service Platform +// Copyright (c) 2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** +* @file FIoDataRow.cpp +* @brief This is the implementation file for the DataRow class. +*/ + +#include +#include + +#include + +#define FIO_DATAROW_COL_NUM_MAX 999 + +using namespace Tizen::Base; + +namespace Tizen { namespace Io +{ + +DataRow::DataRow(void) + : __pDataRowImpl(null) +{ + __pDataRowImpl = new (std::nothrow) _DataRowImpl; + + SysTryReturnVoidResult(NID_IO, __pDataRowImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); +} + +DataRow::~DataRow(void) +{ + delete __pDataRowImpl; +} + +result +DataRow::SetBlobAt(int columnIndex, Tizen::Base::ByteBuffer* pValue) +{ + return __pDataRowImpl->SetBlobAt(columnIndex, pValue); +} + +result +DataRow::SetDateTimeAt(int columnIndex, const Tizen::Base::DateTime& value) +{ + return __pDataRowImpl->SetDateTimeAt(columnIndex, value); +} + +result +DataRow::SetDoubleAt(int columnIndex, double value) +{ + return __pDataRowImpl->SetDoubleAt(columnIndex, value); +} + +result +DataRow::SetIntAt(int columnIndex, int value) +{ + return __pDataRowImpl->SetIntAt(columnIndex, value); +} + +result +DataRow::SetInt64At(int columnIndex, long long value) +{ + return __pDataRowImpl->SetInt64At(columnIndex, value); +} + +result +DataRow::SetStringAt(int columnIndex, const Tizen::Base::String& value) +{ + return __pDataRowImpl->SetStringAt(columnIndex, value); +} + +}} // Tizen::Io + diff --git a/src/io/FIoDataSet.cpp b/src/io/FIoDataSet.cpp new file mode 100755 index 0000000..c76b316 --- /dev/null +++ b/src/io/FIoDataSet.cpp @@ -0,0 +1,113 @@ +// +// Open Service Platform +// Copyright (c) 2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** +* @file FIoDataSet.cpp +* @brief This is the implementation file for the DataSet class. +*/ +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::System; + +namespace Tizen { namespace Io +{ + + +DataSet::DataSet(void) + : __pDataSetImpl(null) +{ +} + +DataSet::~DataSet(void) +{ + delete __pDataSetImpl; +} + +result +DataSet::Construct(const Tizen::Base::Collection::IList& columnNames) +{ + SysAssertf(__pDataSetImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + + unique_ptr<_DataSetImpl> pDataSetImpl(new (std::nothrow) _DataSetImpl); + SysTryReturnResult(NID_IO, pDataSetImpl != null, E_OUT_OF_MEMORY, "The memory is insufficient."); + + result r = pDataSetImpl->Construct(columnNames); + SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r)); + + __pDataSetImpl = pDataSetImpl.release(); + + return E_SUCCESS; +} + +DataRow* +DataSet::CreateDataRowN(void) +{ + SysAssertf(__pDataSetImpl != null, "Not yet constructed. Construct() should be called before use.\n"); + + return __pDataSetImpl->CreateDataRowN(); +} + +DataSetEnumerator* +DataSet::GetDataSetEnumeratorN(void) +{ + SysAssertf(__pDataSetImpl != null, "Not yet constructed. Construct() should be called before use.\n"); + + return __pDataSetImpl->GetDataSetEnumeratorN(); +} + +DataSet* +DataSet::CloneN(void) const +{ + SysAssertf(__pDataSetImpl != null, "Not yet constructed. Construct() should be called before use.\n"); + + return __pDataSetImpl->CloneN(); +} + +bool +DataSet::Equals(const Tizen::Base::Object& obj) const +{ + SysAssertf(__pDataSetImpl != null, "Not yet constructed. Construct() should be called before use.\n"); + + return __pDataSetImpl->Equals(obj); +} + +int +DataSet::GetHashCode(void) const +{ + SysAssertf(__pDataSetImpl != null, "Not yet constructed. Construct() should be called before use.\n"); + + return __pDataSetImpl->GetHashCode(); +} + +}} // Tizen::Io + + diff --git a/src/io/FIoDataSetEnumerator.cpp b/src/io/FIoDataSetEnumerator.cpp new file mode 100755 index 0000000..74f0256 --- /dev/null +++ b/src/io/FIoDataSetEnumerator.cpp @@ -0,0 +1,158 @@ +// +// Open Service Platform +// Copyright (c) 2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** +* @file FIoDataSetEnumerator.cpp +* @brief This is the implementation file for DataSetEnumerator class. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace Tizen::Base; +using namespace Tizen::Base::Utility; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Io +{ +DataSetEnumerator::DataSetEnumerator(void) + : __pDataSetEnumeratorImpl(null) +{ + + __pDataSetEnumeratorImpl = new (std::nothrow)_DataSetEnumeratorImpl; + + SysTryReturnVoidResult(NID_IO, __pDataSetEnumeratorImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); +} + +DataSetEnumerator::~DataSetEnumerator(void) +{ + delete __pDataSetEnumeratorImpl; +} + +result +DataSetEnumerator::MoveNext(void) +{ + return __pDataSetEnumeratorImpl->MoveNext(); +} + +result +DataSetEnumerator::MovePrevious(void) +{ + return __pDataSetEnumeratorImpl->MovePrevious(); +} + +result +DataSetEnumerator::MoveFirst(void) +{ + return __pDataSetEnumeratorImpl->MoveFirst(); +} + +result +DataSetEnumerator::MoveLast(void) +{ + return __pDataSetEnumeratorImpl->MoveLast(); +} + +result +DataSetEnumerator::Reset(void) +{ + return __pDataSetEnumeratorImpl->Reset(); +} + +result +DataSetEnumerator::GetIntAt(int columnIndex, int& value) const +{ + return __pDataSetEnumeratorImpl->GetIntAt(columnIndex, value); +} + +result +DataSetEnumerator::GetInt64At(int columnIndex, long long& value) const +{ + return __pDataSetEnumeratorImpl->GetInt64At(columnIndex, value); +} + +result +DataSetEnumerator::GetDoubleAt(int columnIndex, double& value) const +{ + return __pDataSetEnumeratorImpl->GetDoubleAt(columnIndex, value); +} + +result +DataSetEnumerator::GetStringAt(int columnIndex, String& value) const +{ + return __pDataSetEnumeratorImpl->GetStringAt(columnIndex, value); +} + +result +DataSetEnumerator::GetBlobAt(int columnIndex, ByteBuffer& value) const +{ + return __pDataSetEnumeratorImpl->GetBlobAt(columnIndex, value); +} + +result +DataSetEnumerator::GetBlobAt(int columnIndex, void* buffer, int size) const +{ + + SysTryReturnResult(NID_IO, buffer != null, E_INVALID_ARG, "Null pointer was passed."); + SysTryReturnResult(NID_IO, size > 0, E_INVALID_ARG, "Invalid size was passed."); + + return __pDataSetEnumeratorImpl->GetBlobAt(columnIndex, buffer, size); +} + +result +DataSetEnumerator::GetDateTimeAt(int columnIndex, DateTime& value) const +{ + return __pDataSetEnumeratorImpl->GetDateTimeAt(columnIndex, value); +} + +int +DataSetEnumerator::GetColumnCount(void) const +{ + return __pDataSetEnumeratorImpl->GetColumnCount(); +} + +DbColumnType +DataSetEnumerator::GetColumnType(int columnIndex) const +{ + return __pDataSetEnumeratorImpl->GetColumnType(columnIndex); +} + +String +DataSetEnumerator::GetColumnName(int columnIndex) const +{ + return __pDataSetEnumeratorImpl->GetColumnName(columnIndex); +} + +int +DataSetEnumerator::GetColumnSize(int columnIndex) const +{ + return __pDataSetEnumeratorImpl->GetColumnSize(columnIndex); +} + +}} // Tizen::Io + diff --git a/src/io/FIo_DataRowImpl.cpp b/src/io/FIo_DataRowImpl.cpp new file mode 100755 index 0000000..58a86ac --- /dev/null +++ b/src/io/FIo_DataRowImpl.cpp @@ -0,0 +1,410 @@ +// +// Open Service Platform +// Copyright (c) 2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FIo_DataRowImpl.cpp + * @brief This is the implementation file for _DataRowImpl class. + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::App; + +namespace Tizen { namespace Io +{ +_DataItem::_DataItem(void) + : type(DB_COLUMNTYPE_NULL) + , size(0) + , intValue(0) + , int64Value(0) + , doubleValue(0) + , pObj(null) +{ +} + +_DataItem::~_DataItem(void) +{ + delete pObj; +} + +int +_DataItem::GetHashCode(void) const +{ + int hash = 0; + + String str; + + str.Append(static_cast(type)); + str.Append(size); + str.Append(intValue); + str.Append(int64Value); + str.Append(doubleValue); + hash += str.GetHashCode(); + + if (type == DB_COLUMNTYPE_TEXT ) + hash += ((String*)pObj)->GetHashCode(); + else if (type == DB_COLUMNTYPE_BLOB) + hash += ((ByteBuffer*)pObj)->GetHashCode(); + + return hash; +} + +_DataRowImpl::_DataRowImpl(void) + : __pDataRow(null) + , __pColumnTypeList(null) + , __columnCount(0) +{ +} + +_DataRowImpl::~_DataRowImpl(void) +{ +} + +result +_DataRowImpl::SetBlobAt(int columnIndex, Tizen::Base::ByteBuffer* pValue) +{ + result r = E_SUCCESS; + Integer* pColumnType = null; + int nColumnType = DB_COLUMNTYPE_UNDEFINED; + + SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG, + "Wrong column index."); + SysTryReturnResult(NID_IO, pValue != null, E_INVALID_ARG, "pValue is null"); + + pColumnType = static_cast(__pColumnTypeList->GetAt(columnIndex)); + nColumnType = pColumnType->ToInt(); + SysTryReturnResult(NID_IO, nColumnType == DB_COLUMNTYPE_BLOB || nColumnType == DB_COLUMNTYPE_NULL, + E_TYPE_MISMATCH, "Type mismatch"); + + unique_ptr<_DataItem>pItem(new (std::nothrow) _DataItem()); + SysTryReturnResult(NID_IO, pItem != null, E_OUT_OF_MEMORY, + "The memory is insufficient."); + + pItem->type = DB_COLUMNTYPE_BLOB; + pItem->size = pValue->GetLimit(); + pItem->pObj = pValue; + + _DataItem* pOldItem = static_cast<_DataItem*>(__pDataRow->GetAt(columnIndex)); + r = __pDataRow->SetAt(pItem.release(), columnIndex); + SysTryReturnResult(NID_IO, r == E_SUCCESS, E_OUT_OF_MEMORY, + "The memory is insufficient. Set failed"); + delete pOldItem; + + if (nColumnType == DB_COLUMNTYPE_NULL) + { + __pColumnTypeList->SetAt(new Integer(DB_COLUMNTYPE_BLOB), columnIndex); + delete pColumnType; + } + + return r; +} + +result +_DataRowImpl::SetDateTimeAt(int columnIndex, const Tizen::Base::DateTime& value) +{ + result r = E_SUCCESS; + Integer* pColumnType = null; + int nColumnType = DB_COLUMNTYPE_UNDEFINED; + + SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG, + "Wrong column index."); + + pColumnType = static_cast(__pColumnTypeList->GetAt(columnIndex)); + nColumnType = pColumnType->ToInt(); + SysTryReturnResult(NID_IO, nColumnType == DB_COLUMNTYPE_TEXT || nColumnType == DB_COLUMNTYPE_NULL, + E_TYPE_MISMATCH, "Type mismatch"); + + unique_ptr<_DataItem>pItem(new (std::nothrow) _DataItem()); + unique_ptr pString(new (std::nothrow) String(_StringConverter::CopyToCharArrayN(value.ToString()))); + SysTryReturnResult(NID_IO, pItem != null && pString != null, E_OUT_OF_MEMORY, + "The memory is insufficient."); + + pItem->type = DB_COLUMNTYPE_TEXT; + pItem->size = pString->GetLength(); + pItem->pObj = pString.release(); + + _DataItem* pOldItem = static_cast<_DataItem*>(__pDataRow->GetAt(columnIndex)); + r = __pDataRow->SetAt(pItem.release(), columnIndex); + SysTryReturnResult(NID_IO, r == E_SUCCESS, E_OUT_OF_MEMORY, + "The memory is insufficient. Set failed"); + delete pOldItem; + + if (nColumnType == DB_COLUMNTYPE_NULL) + { + __pColumnTypeList->SetAt(new Integer(DB_COLUMNTYPE_TEXT), columnIndex); + delete pColumnType; + } + + return r; + +} + +result +_DataRowImpl::SetDoubleAt(int columnIndex, double value) +{ + result r = E_SUCCESS; + int size = sizeof(double); + Integer* pColumnType = null; + int nColumnType = DB_COLUMNTYPE_UNDEFINED; + + SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG, + "Wrong column index."); + + pColumnType = static_cast(__pColumnTypeList->GetAt(columnIndex)); + nColumnType = pColumnType->ToInt(); + SysTryReturnResult(NID_IO, nColumnType == DB_COLUMNTYPE_DOUBLE || nColumnType == DB_COLUMNTYPE_NULL, + E_TYPE_MISMATCH, "Type mismatch"); + + unique_ptr<_DataItem>pItem(new (std::nothrow) _DataItem()); + SysTryReturnResult(NID_IO, pItem != null, E_OUT_OF_MEMORY, + "The memory is insufficient."); + + pItem->type = DB_COLUMNTYPE_DOUBLE; + pItem->size = size; + pItem->doubleValue = value; + + _DataItem* pOldItem = static_cast<_DataItem*>(__pDataRow->GetAt(columnIndex)); + r = __pDataRow->SetAt(pItem.release(), columnIndex); + SysTryReturnResult(NID_IO, r == E_SUCCESS, E_OUT_OF_MEMORY, + "The memory is insufficient. Set failed"); + delete pOldItem; + + if (nColumnType == DB_COLUMNTYPE_NULL) + { + __pColumnTypeList->SetAt(new Integer(DB_COLUMNTYPE_DOUBLE), columnIndex); + delete pColumnType; + } + + return r; + +} + +result +_DataRowImpl::SetIntAt(int columnIndex, int value) +{ + result r = E_SUCCESS; + int size = sizeof(int); + Integer* pColumnType = null; + int nColumnType = DB_COLUMNTYPE_UNDEFINED; + + SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG, + "Wrong column index."); + + pColumnType = static_cast(__pColumnTypeList->GetAt(columnIndex)); + nColumnType = pColumnType->ToInt(); + SysTryReturnResult(NID_IO, nColumnType == DB_COLUMNTYPE_INT || nColumnType == DB_COLUMNTYPE_NULL, + E_TYPE_MISMATCH, "Type mismatch"); + + unique_ptr<_DataItem>pItem(new (std::nothrow) _DataItem()); + SysTryReturnResult(NID_IO, pItem != null , E_OUT_OF_MEMORY, + "The memory is insufficient."); + + pItem->type = DB_COLUMNTYPE_INT; + pItem->size = size; + pItem->intValue = value; + + _DataItem* pOldItem = static_cast<_DataItem*>(__pDataRow->GetAt(columnIndex)); + r = __pDataRow->SetAt(pItem.release(), columnIndex); + SysTryReturnResult(NID_IO, r == E_SUCCESS, E_OUT_OF_MEMORY, + "The memory is insufficient. Set failed"); + delete pOldItem; + + if (nColumnType == DB_COLUMNTYPE_NULL) + { + __pColumnTypeList->SetAt(new Integer(DB_COLUMNTYPE_INT), columnIndex); + delete pColumnType; + } + + return r; +} + +result +_DataRowImpl::SetInt64At(int columnIndex, long long value) +{ + result r = E_SUCCESS; + int size = sizeof(long long); + Integer* pColumnType = null; + int nColumnType = DB_COLUMNTYPE_UNDEFINED; + + SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG, + "Wrong column index."); + + pColumnType = static_cast(__pColumnTypeList->GetAt(columnIndex)); + nColumnType = pColumnType->ToInt(); + SysTryReturnResult(NID_IO, nColumnType == DB_COLUMNTYPE_INT64 || nColumnType == DB_COLUMNTYPE_NULL, + E_TYPE_MISMATCH, "Type mismatch"); + + unique_ptr<_DataItem>pItem(new (std::nothrow) _DataItem()); + SysTryReturnResult(NID_IO, pItem != null, E_OUT_OF_MEMORY, + "The memory is insufficient."); + + pItem->type = DB_COLUMNTYPE_INT64; + pItem->size = size; + pItem->int64Value = value; + + _DataItem* pOldItem = static_cast<_DataItem*>(__pDataRow->GetAt(columnIndex)); + r = __pDataRow->SetAt(pItem.release(), columnIndex); + SysTryReturnResult(NID_IO, r == E_SUCCESS, E_OUT_OF_MEMORY, + "The memory is insufficient. Set failed"); + delete pOldItem; + + if (nColumnType == DB_COLUMNTYPE_NULL) + { + __pColumnTypeList->SetAt(new Integer(DB_COLUMNTYPE_INT64), columnIndex); + delete pColumnType; + } + + return r; +} + +result +_DataRowImpl::SetStringAt(int columnIndex, const Tizen::Base::String& value) +{ + result r = E_SUCCESS; + Integer* pColumnType = null; + int nColumnType = DB_COLUMNTYPE_UNDEFINED; + + SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG, + "Wrong column index."); + + pColumnType = static_cast(__pColumnTypeList->GetAt(columnIndex)); + nColumnType = pColumnType->ToInt(); + SysTryReturnResult(NID_IO, nColumnType == DB_COLUMNTYPE_TEXT || nColumnType == DB_COLUMNTYPE_NULL, + E_TYPE_MISMATCH, "Type mismatch"); + + unique_ptr<_DataItem>pItem(new (std::nothrow) _DataItem()); + unique_ptr pString(new (std::nothrow) String(value)); + SysTryReturnResult(NID_IO, pItem != null && pString != null, E_OUT_OF_MEMORY, + "The memory is insufficient."); + + pItem->type = DB_COLUMNTYPE_TEXT; + pItem->size = value.GetLength(); + pItem->pObj = pString.release(); + + _DataItem* pOldItem = static_cast<_DataItem*>(__pDataRow->GetAt(columnIndex)); + r = __pDataRow->SetAt(pItem.release(), columnIndex); + SysTryReturnResult(NID_IO, r == E_SUCCESS, E_OUT_OF_MEMORY, + "The memory is insufficient. Set failed"); + delete pOldItem; + + if (nColumnType == DB_COLUMNTYPE_NULL) + { + __pColumnTypeList->SetAt(new Integer(DB_COLUMNTYPE_TEXT), columnIndex); + delete pColumnType; + } + + return r; +} + +result +_DataRowImpl::Clone(const ArrayList* pOthersRowArrayList) const +{ + result r = E_SUCCESS; + + for (int i = 0; i < __columnCount; i++) + { + const _DataItem* pOthersItem = static_cast(pOthersRowArrayList->GetAt(i)); + + unique_ptr<_DataItem>pItem(new (std::nothrow) _DataItem()); + SysTryReturnResult(NID_IO, pItem != null, E_OUT_OF_MEMORY, + "The memory is insufficient."); + + pItem->type = pOthersItem->type; + pItem->size = pOthersItem->size; + pItem->pObj = pOthersItem->pObj; + pItem->intValue = pOthersItem->intValue; + pItem->int64Value = pOthersItem->int64Value; + pItem->doubleValue = pOthersItem->doubleValue; + + _DataItem* pOldItem = static_cast<_DataItem*>(__pDataRow->GetAt(i)); + r = __pDataRow->SetAt(pItem.release(), i); + delete pOldItem; + if (r != E_SUCCESS) + break; + } + + return r; +} + +ArrayList* +_DataRowImpl::GetRowArrayList(void) const +{ + return __pDataRow; +} + +_DataRowImpl* +_DataRowImpl::GetInstance(DataRow& dataRow) +{ + return dataRow.__pDataRowImpl; +} + +const _DataRowImpl* +_DataRowImpl::GetInstance(const DataRow& dataRow) +{ + return dataRow.__pDataRowImpl; +} + +DataRow* +_DataRowImpl::CreateDataRowInstanceN(int columnCount, ArrayList* pArrayListRow) +{ + unique_ptr pDataRow(new (std::nothrow) DataRow()); + SysTryReturn(NID_IO, pDataRow != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pDataRow->__pDataRowImpl->__pDataRow = pArrayListRow; + pDataRow->__pDataRowImpl->__columnCount = columnCount; + + for (int i = 0 ; i < columnCount ; i++) + { + result r = pArrayListRow->Add(new (std::nothrow) _DataItem()); + SysTryReturn(NID_IO, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + } + + return pDataRow.release(); +} + +int +_DataRowImpl::GetHashCode(const ArrayList* pRowArrayList) +{ + int hash = 0; + + for (int i = 0; i < pRowArrayList->GetCount(); i++) + { + const _DataItem* pItem = static_cast(pRowArrayList->GetAt(i)); + hash += pItem->GetHashCode(); + } + + return hash; +} + +}} // Tizen::Io + diff --git a/src/io/FIo_DataSetEnumeratorImpl.cpp b/src/io/FIo_DataSetEnumeratorImpl.cpp new file mode 100755 index 0000000..c8daadd --- /dev/null +++ b/src/io/FIo_DataSetEnumeratorImpl.cpp @@ -0,0 +1,476 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FIo_DataSetEnumeratorImpl.cpp + * @brief This is the implementation file for _DataSetEnumeratorImpl class. + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Base::Utility; +using namespace Tizen::Base::Runtime; +using namespace Tizen::System; +using namespace Tizen::App; +using namespace Tizen::Base::Collection; + +namespace Tizen { namespace Io +{ + +_DataSetEnumeratorImpl::_DataSetEnumeratorImpl(void) + : __pDataSet(null), + __pColumnList(null), + __pCurrentRow(null), + __columnCount(0), + __rowCount(0), + __currentRowIndex(-1) +{ + +} + +_DataSetEnumeratorImpl::~_DataSetEnumeratorImpl(void) +{ + +} + +result +_DataSetEnumeratorImpl::MoveNext(void) +{ + if (__currentRowIndex +1 == __rowCount) + return E_OUT_OF_RANGE; + + ++__currentRowIndex; + __pCurrentRow = static_cast(__pDataSet->GetAt(__currentRowIndex)); + + if (__pCurrentRow == null) + return E_INVALID_STATE; + + return E_SUCCESS; +} + +result +_DataSetEnumeratorImpl::MovePrevious(void) +{ + if (__currentRowIndex == 0) + return E_OUT_OF_RANGE; + + --__currentRowIndex; + __pCurrentRow = static_cast(__pDataSet->GetAt(__currentRowIndex)); + + if (__pCurrentRow == null) + return E_INVALID_STATE; + + return E_SUCCESS; +} + +result +_DataSetEnumeratorImpl::MoveFirst(void) +{ + __currentRowIndex = 0; + __pCurrentRow = static_cast(__pDataSet->GetAt(__currentRowIndex)); + + if (__pCurrentRow == null) + return E_INVALID_STATE; + + return E_SUCCESS; +} + +result +_DataSetEnumeratorImpl::MoveLast(void) +{ + __currentRowIndex = __rowCount -1; + __pCurrentRow = static_cast(__pDataSet->GetAt(__currentRowIndex)); + + if (__pCurrentRow == null) + return E_INVALID_STATE; + + return E_SUCCESS; +} + +result +_DataSetEnumeratorImpl::Reset(void) +{ + __currentRowIndex = -1; + __pCurrentRow = null; + + return E_SUCCESS; +} + +result +_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."); + 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, + "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)); + if (pDataItem) + { + if (pDataItem->type != DB_COLUMNTYPE_INT) + { + r = E_TYPE_MISMATCH; + SysLog(NID_IO, "[E_TYPE_MISMATCH] Trying to access column of different type."); + goto CATCH; + } + + value = pDataItem->intValue; + } + return E_SUCCESS; + + CATCH: + return r; +} + +result +_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."); + 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, + "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)); + if (pDataItem) + { + if (pDataItem->type != DB_COLUMNTYPE_INT64) + { + r = E_TYPE_MISMATCH; + SysLog(NID_IO, "[E_TYPE_MISMATCH] Trying to access column of different type."); + goto CATCH; + } + + value = pDataItem->int64Value; + } + return E_SUCCESS; + +CATCH: + return r; +} + +result +_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."); + 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, + "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)); + if (pDataItem) + { + if (pDataItem->type != DB_COLUMNTYPE_DOUBLE) + { + r = E_TYPE_MISMATCH; + SysLog(NID_IO, "[E_TYPE_MISMATCH] Trying to access column of different type."); + goto CATCH; + } + + value = pDataItem->doubleValue; + } + return E_SUCCESS; + +CATCH: + return r; +} + +result +_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."); + 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, + "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)); + if (pDataItem) + { + if (pDataItem->type != DB_COLUMNTYPE_TEXT) + { + r = E_TYPE_MISMATCH; + SysLog(NID_IO, "[E_TYPE_MISMATCH] Trying to access column of different type."); + goto CATCH; + } + + value = *((String*)pDataItem->pObj); + } + +CATCH: + return r; +} + +result +_DataSetEnumeratorImpl::GetBlobAt(int columnIndex, ByteBuffer& value) const +{ + result r = E_SUCCESS; + ByteBuffer* pBuffer = null; + + SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE, + "The Object is not constructed or 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, + "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)); + if (pDataItem) + { + if (pDataItem->type != DB_COLUMNTYPE_BLOB) + { + r = E_TYPE_MISMATCH; + SysLog(NID_IO, "[E_TYPE_MISMATCH] Trying to access column of different type."); + goto CATCH; + } + + pBuffer = (ByteBuffer*)pDataItem->pObj; + pBuffer->SetPosition(0); + r = value.CopyFrom(*pBuffer); + } + + // fall thru +CATCH: + return r; +} + +result +_DataSetEnumeratorImpl::GetBlobAt(int columnIndex, void* buffer, int size) const +{ + result r = E_SUCCESS; + int blobLen = 0; + ByteBuffer* pBuffer = null; + + SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE, + "The Object is not constructed or 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, + "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)); + if (pDataItem) + { + if (pDataItem->type != DB_COLUMNTYPE_BLOB) + { + r = E_TYPE_MISMATCH; + SysLog(NID_IO, "[E_TYPE_MISMATCH] Trying to access column of different type."); + goto CATCH; + } + + pBuffer = (ByteBuffer*)pDataItem->pObj; + pBuffer->SetPosition(0); + blobLen = pBuffer->GetLimit(); + memcpy(buffer, pBuffer->GetPointer(), (blobLen < size) ? blobLen : size); + } + + if (size < blobLen) + { + r = E_OVERFLOW; + } + + // fall thru +CATCH: + return r; +} + +result +_DataSetEnumeratorImpl::GetDateTimeAt(int columnIndex, DateTime& value) const +{ + result r = E_SUCCESS; + String* pStr = null; + + SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE, + "The instance is not constructed or 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, + "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)); + if (pDataItem) + { + if (pDataItem->type != DB_COLUMNTYPE_TEXT) + { + r = E_TYPE_MISMATCH; + SysLog(NID_IO, "[E_TYPE_MISMATCH] Trying to access column of different type."); + goto CATCH; + } + + pStr = (String*)pDataItem->pObj; + } + + r = DateTime::Parse(*pStr, value); + + // fall thru +CATCH: + return r; +} + +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."); + + return __columnCount; +} + +DbColumnType +_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."); + + SysTryReturn(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, DB_COLUMNTYPE_UNDEFINED, E_INVALID_ARG, + "[E_INVALID_ARG] Given column index is out of range."); + + if (__pCurrentRow) + { + _DataItem* pDataItem = dynamic_cast < _DataItem* >(__pCurrentRow->GetAt(columnIndex)); + if (!pDataItem) + { + SetLastResult(E_INVALID_STATE); + return DB_COLUMNTYPE_UNDEFINED; + } + + type = pDataItem->type; + switch (type) + { + case DB_COLUMNTYPE_INT: + case DB_COLUMNTYPE_DOUBLE: + case DB_COLUMNTYPE_TEXT: + case DB_COLUMNTYPE_BLOB: + case DB_COLUMNTYPE_NULL: + type = pDataItem->type; + break; + + default: + SetLastResult(E_INVALID_STATE); + break; + } + } + + return type; +} + +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."); + + SysTryReturn(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, null, E_INVALID_ARG, + "[E_INVALID_ARG] Given column index is out of range."); + + + String* pString = dynamic_cast (__pColumnList->GetAt(columnIndex)); + + if (!pString) + { + SetLastResult(E_INVALID_STATE); + return String(""); + } + + return String(pString->GetPointer()); +} + +int +_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, + "[E_INVALID_ARG] Given column index is out of range."); + + SysTryReturn(NID_IO, __pCurrentRow != null, 0, 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)); + if (!pDataItem) + { + SetLastResult(E_INVALID_STATE); + return 0; + } + + bytes = pDataItem->size; + //SysLog(NID_IO, "Size is %d", bytes); + + return bytes; +} + +_DataSetEnumeratorImpl* +_DataSetEnumeratorImpl::GetInstance(DataSetEnumerator& dataSetEnumerator) +{ + return dataSetEnumerator.__pDataSetEnumeratorImpl; +} + +const _DataSetEnumeratorImpl* +_DataSetEnumeratorImpl::GetInstance(const DataSetEnumerator& dataSetEnumerator) +{ + return dataSetEnumerator.__pDataSetEnumeratorImpl; +} + +DataSetEnumerator* +_DataSetEnumeratorImpl::CreateDataSetEnumeratorInstanceN(void) +{ + unique_ptr pDataSetEnumerator(new (std::nothrow) DataSetEnumerator()); + SysTryReturn(NID_IO, pDataSetEnumerator != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + return pDataSetEnumerator.release(); +} + +}} // Tizen::Io + diff --git a/src/io/FIo_DataSetImpl.cpp b/src/io/FIo_DataSetImpl.cpp new file mode 100755 index 0000000..e0d5d58 --- /dev/null +++ b/src/io/FIo_DataSetImpl.cpp @@ -0,0 +1,159 @@ +// +// Open Service Platform +// Copyright (c) 2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** +* @file FIo_DataSetImpl.cpp +* @brief This is the implementation file for the _DataSetImpl class. +*/ + +#include +#include + +#include +#include +#include +#include +#include +#include + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; + +namespace Tizen { namespace Io +{ +_DataSetImpl::_DataSetImpl(void) + :__rowCount(0) +{ + +} + +_DataSetImpl::~_DataSetImpl(void) +{ + +} + +result +_DataSetImpl::Construct(const IList& columnNames) +{ + result r = E_SUCCESS; + + r = __columnList.Construct(columnNames); + SysTryReturn(NID_IO, r == E_SUCCESS, E_INVALID_ARG, r, "[E_INVALID_ARG] columnNames is invalid."); + + __columnCount = __columnList.GetCount(); + SysTryReturn(NID_IO, __columnCount > 0, E_INVALID_ARG, r, "[E_INVALID_ARG] column count is 0."); + + __columnTypeList.Construct(__columnCount); + + for (int i = 0 ; i < __columnCount ; i++) + { + result r = __columnTypeList.Add(new (std::nothrow) Integer(DB_COLUMNTYPE_NULL)); + SysTryReturn(NID_IO, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + } + //SysLog(NID_IO, "column count is %d", __columnCount); + + return r; +} + +DataRow* +_DataSetImpl::CreateDataRowN(void) +{ + result r; + unique_ptr pNewRowArrayList(new (std::nothrow) ArrayList); + SysTryReturn(NID_IO, pNewRowArrayList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + unique_ptr pDataRow(_DataRowImpl::CreateDataRowInstanceN(__columnCount, pNewRowArrayList.get())); + SysTryReturn(NID_IO, pDataRow != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = __dataSet.Add(pNewRowArrayList.release()); + SysTryReturn(NID_IO, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Add Row to DataSet is failed"); + + _DataRowImpl::GetInstance(*pDataRow)->__pColumnTypeList = &__columnTypeList; + + __rowCount = __dataSet.GetCount(); + //SysLog(NID_IO, "row count is %d", __rowCount); + + return pDataRow.release(); + +} + +DataSetEnumerator* +_DataSetImpl::GetDataSetEnumeratorN(void) +{ + unique_ptr pDataSetEnum(_DataSetEnumeratorImpl::CreateDataSetEnumeratorInstanceN()); + + _DataSetEnumeratorImpl::GetInstance(*pDataSetEnum)->__pDataSet = &__dataSet; + _DataSetEnumeratorImpl::GetInstance(*pDataSetEnum)->__pColumnList = &__columnList; + _DataSetEnumeratorImpl::GetInstance(*pDataSetEnum)->__columnCount = __columnCount; + _DataSetEnumeratorImpl::GetInstance(*pDataSetEnum)->__rowCount = __rowCount; + + //SysLog(NID_IO, "row count is %d, column count is %d", __rowCount, __columnCount); + + return pDataSetEnum.release(); +} + +DataSet* +_DataSetImpl::CloneN(void) const +{ + result r; + unique_ptr< DataSet > pDataSet(new (std::nothrow) DataSet()); + SysTryReturn(NID_IO, pDataSet != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pDataSet->Construct(__columnList); + + for (int i = 0; i < __rowCount; i++) + { + DataRow* pNewRow = pDataSet->CreateDataRowN(); + r = _DataRowImpl::GetInstance(*pNewRow)->Clone((const ArrayList*)(__dataSet.GetAt(i))); + delete pNewRow; + + SysTryReturn(NID_IO, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] DataRow Clone Falied"); + } + + return pDataSet.release(); +} + +bool +_DataSetImpl::Equals(const Tizen::Base::Object& obj) const +{ + int thisHash = this->GetHashCode(); + int othersHash = obj.GetHashCode(); + + if (thisHash == othersHash ) + return true; + else + return false; +} + +int +_DataSetImpl::GetHashCode(void) const +{ + int hash = 0; + + for (int i = 0; i < __rowCount; i++) + { + const ArrayList* pDataRowArrayList = static_cast(__dataSet.GetAt(i)); + hash += _DataRowImpl::GetHashCode(pDataRowArrayList); + } + + return hash; +} + +}} // Tizen::Io + + diff --git a/src/io/inc/FIo_DataRowImpl.h b/src/io/inc/FIo_DataRowImpl.h new file mode 100755 index 0000000..52701f2 --- /dev/null +++ b/src/io/inc/FIo_DataRowImpl.h @@ -0,0 +1,113 @@ +// +// Open Service Platform +// Copyright (c) 2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FIo_DataRowImpl.h + * @brief This is the header file for the %_DataRowImpl class. + * + * This header file contains declarations of the %_DataRowImpl class. + */ + +#ifndef _FIO_INTERNAL_DATAROW_IMPL_H_ +#define _FIO_INTERNAL_DATAROW_IMPL_H_ + +#include +#include +#include +#include +#include + +namespace Tizen { namespace Base +{ +class String; +class ByteBuffer; +class DateTime; +}} + +namespace Tizen { namespace Io +{ + +class _DataItem + : public Tizen::Base::Object +{ +public: + _DataItem(void); + ~_DataItem(void); + virtual int GetHashCode(void) const; + + DbColumnType type; + int size; + int intValue; + long long int64Value; + double doubleValue; + Tizen::Base::Object* pObj; +}; + + +/** + * @class _DataRowImpl + * @brief This class implements the DataRow. + * @since 2.1 + * + * @see Tizen::Io::DataRow + */ +class _DataRowImpl + : public Tizen::Base::Object +{ + +public: + _DataRowImpl(void); + + virtual ~_DataRowImpl(void); + + result SetBlobAt(int columnIndex, Tizen::Base::ByteBuffer* pValue); + + result SetDateTimeAt(int columnIndex, const Tizen::Base::DateTime& value); + + result SetDoubleAt(int columnIndex, double value); + + result SetIntAt(int columnIndex, int value); + + result SetInt64At(int columnIndex, long long value); + + result SetStringAt(int columnIndex, const Tizen::Base::String& value); + + static int GetHashCode(const Tizen::Base::Collection::ArrayList* pRowArrayList); + + static _DataRowImpl* GetInstance(DataRow& dataRow); + + static const _DataRowImpl* GetInstance(const DataRow& dataRow); + + static DataRow* CreateDataRowInstanceN(int columnCount, Tizen::Base::Collection::ArrayList* pArrayListRow); + + Tizen::Base::Collection::ArrayList* GetRowArrayList(void) const; + + result Clone(const Tizen::Base::Collection::ArrayList* pOthersRowArrayList) const; + +private: + Tizen::Base::Collection::ArrayList* __pDataRow; + Tizen::Base::Collection::ArrayList* __pColumnTypeList; + int __columnCount; + + friend class _DataSetImpl; + +}; //_DataRowImpl + +}} // Tizen::Io + +#endif //_FIO_INTERNAL_DATAROW_IMPL_H_ + diff --git a/src/io/inc/FIo_DataSetEnumeratorImpl.h b/src/io/inc/FIo_DataSetEnumeratorImpl.h new file mode 100755 index 0000000..9586c4a --- /dev/null +++ b/src/io/inc/FIo_DataSetEnumeratorImpl.h @@ -0,0 +1,177 @@ +// +// Open Service Platform +// Copyright (c) 2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FIo_DataSetEnumeratorImpl.h + * @brief This is the header file for the %_DataSetEnumeratorImpl class. + * + * This header file contains declarations of the %_DataSetEnumeratorImpl class. + */ + +#ifndef _FIO_INTERNAL_DATASETENUMERATOR_IMPL_H_ +#define _FIO_INTERNAL_DATASETENUMERATOR_IMPL_H_ + +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Base +{ +class String; +class ByteBuffer; +class DateTime; +}} + +namespace Tizen { namespace Io +{ + +class _DataSetRow; + +/** + * @class _DataSetEnumeratorImpl + * @brief This class implements the DataSetEnumerator. + * @since 2.1 + * + * @see Tizen::Io::DataSetEnumerator + */ +class _DataSetEnumeratorImpl + : public Tizen::Base::Object +{ + +public: + /** + * This is the default constructor for this class. + */ + _DataSetEnumeratorImpl(void); + + /** + * This is the default destructor for this class. + */ + virtual ~_DataSetEnumeratorImpl(void); + + /** + * @see DataSetEnumerator::MoveNext() + */ + result MoveNext(void); + + /** + * @see DataSetEnumerator::MovePrevious() + */ + result MovePrevious(void); + + /** + * @see DataSetEnumerator::MoveFirst() + */ + result MoveFirst(void); + + /** + * @see DataSetEnumerator::MoveLast() + */ + result MoveLast(void); + + /** + * @see DataSetEnumerator::Reset() + */ + result Reset(void); + + /** + * @see DataSetEnumerator::GetIntAt() + */ + result GetIntAt(int columnIndex, int& value) const; + + /** + * @see DataSetEnumerator::GetInt64At() + */ + result GetInt64At(int columnIndex, long long& value) const; + + /** + * @see DataSetEnumerator::GetDoubleAt() + */ + result GetDoubleAt(int columnIndex, double& value) const; + + /** + * @see DataSetEnumerator::GetStringAt() + */ + result GetStringAt(int columnIndex, Tizen::Base::String& value) const; + + /** + * @see DataSetEnumerator::GetBlobAt() + */ + result GetBlobAt(int columnIndex, Tizen::Base::ByteBuffer& value) const; + + /** + * @see DataSetEnumerator::GetBlobAt() + */ + result GetBlobAt(int columnIndex, void* buffer, int size) const; + + /** + * @see DataSetEnumerator::GetDateTimeAt() + */ + result GetDateTimeAt(int columnIndex, Tizen::Base::DateTime& value) const; + + /** + * @see DataSetEnumerator::GetColumnCount() + */ + int GetColumnCount(void) const; + + /** + * @see DataSetEnumerator::GetColumnType() + */ + DbColumnType GetColumnType(int columnIndex) const; + + /** + * @see DataSetEnumerator::GetColumnName() + */ + Tizen::Base::String GetColumnName(int columnIndex) const; + + /** + * @see DataSetEnumerator::GetColumnSize() + */ + int GetColumnSize(int columnIndex) const; + + static _DataSetEnumeratorImpl* GetInstance(DataSetEnumerator& dataSetEnumerator); + + static const _DataSetEnumeratorImpl* GetInstance(const DataSetEnumerator& dataSetEnumerator); + + static DataSetEnumerator* CreateDataSetEnumeratorInstanceN(void); + +private: + _DataSetEnumeratorImpl(_DataSetEnumeratorImpl& dataSetEnumeratorImpl); + + _DataSetEnumeratorImpl& operator =(const _DataSetEnumeratorImpl& dataSetEnumeratorImpl); + + Tizen::Base::Collection::LinkedList* __pDataSet; + Tizen::Base::Collection::ArrayList* __pColumnList; + Tizen::Base::Collection::ArrayList* __pCurrentRow; + + int __columnCount; + + int __rowCount; + + int __currentRowIndex; + + friend class _DataSetImpl; + +}; // _DataSetEnumeratorImpl + +}} // Tizen::Io + +#endif //_FIO_INTERNAL_DATASETENUMERATOR_IMPL_H_ + diff --git a/src/io/inc/FIo_DataSetImpl.h b/src/io/inc/FIo_DataSetImpl.h new file mode 100755 index 0000000..44d828a --- /dev/null +++ b/src/io/inc/FIo_DataSetImpl.h @@ -0,0 +1,78 @@ +// +// Open Service Platform +// Copyright (c) 2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FIoDataSet.h + * @brief This is the header file for the %_DataSetImpl class. + * + * This header file contains the declarations of the %_DataSetImpl class. + */ + +#ifndef _FIO_INTERNAL_DATASET_IMPL_H_ +#define _FIO_INTERNAL_DATASET_IMPL_H_ + +#include +#include +#include +#include +#include + +namespace Tizen { namespace Io +{ + +class DataRow; +class DataSetEnumerator; + +class _DataSetImpl + : public Tizen::Base::Object +{ + +public: + _DataSetImpl(void); + + virtual ~_DataSetImpl(void); + + result Construct(const Tizen::Base::Collection::IList& columnNames); + + DataRow* CreateDataRowN(void); + + DataSetEnumerator* GetDataSetEnumeratorN(void); + + DataSet* CloneN(void) const; + + virtual bool Equals(const Tizen::Base::Object& obj) const; + + virtual int GetHashCode(void) const; + + +private: + _DataSetImpl(_DataSetImpl& dataSetImpl); + + _DataSetImpl& operator =(const _DataSetImpl& dataSetImpl); + + Tizen::Base::Collection::LinkedList __dataSet; + Tizen::Base::Collection::ArrayList __columnList; + Tizen::Base::Collection::ArrayList __columnTypeList; + + int __columnCount; + int __rowCount; +}; // _DataSetImpl + +}} // Tizen::Io + +#endif //_FIO_INTERNAL_DATASET_IMPL_H_ + -- 2.7.4