Index: src/libchcore/ISerializer.cpp =================================================================== diff -u -N --- src/libchcore/ISerializer.cpp (revision 0) +++ src/libchcore/ISerializer.cpp (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) @@ -0,0 +1,29 @@ +// ============================================================================ +// Copyright (C) 2001-2013 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#include "stdafx.h" +#include "ISerializer.h" + +BEGIN_CHCORE_NAMESPACE + +ISerializer::~ISerializer() +{ + +} + +END_CHCORE_NAMESPACE Index: src/libchcore/ISerializer.h =================================================================== diff -u -N --- src/libchcore/ISerializer.h (revision 0) +++ src/libchcore/ISerializer.h (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) @@ -0,0 +1,36 @@ +// ============================================================================ +// Copyright (C) 2001-2014 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#ifndef __ISERIALIZER_H__ +#define __ISERIALIZER_H__ + +#include "libchcore.h" + +BEGIN_CHCORE_NAMESPACE + +class LIBCHCORE_API ISerializer +{ +public: + virtual ~ISerializer(); +}; + +typedef boost::shared_ptr ISerializerPtr; + +END_CHCORE_NAMESPACE + +#endif Index: src/libchcore/ISerializerContainer.cpp =================================================================== diff -u -N --- src/libchcore/ISerializerContainer.cpp (revision 0) +++ src/libchcore/ISerializerContainer.cpp (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) @@ -0,0 +1,28 @@ +// ============================================================================ +// Copyright (C) 2001-2013 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#include "stdafx.h" +#include "ISerializerContainer.h" + +BEGIN_CHCORE_NAMESPACE + +ISerializerContainer::~ISerializerContainer() +{ +} + +END_CHCORE_NAMESPACE Index: src/libchcore/ISerializerContainer.h =================================================================== diff -u -N --- src/libchcore/ISerializerContainer.h (revision 0) +++ src/libchcore/ISerializerContainer.h (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) @@ -0,0 +1,36 @@ +// ============================================================================ +// Copyright (C) 2001-2014 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#ifndef __ISERIALIZERCONTAINER_H__ +#define __ISERIALIZERCONTAINER_H__ + +#include "libchcore.h" + +BEGIN_CHCORE_NAMESPACE + +class LIBCHCORE_API ISerializerContainer +{ +public: + virtual ~ISerializerContainer(); +}; + +typedef boost::shared_ptr ISerializerContainerPtr; + +END_CHCORE_NAMESPACE + +#endif Index: src/libchcore/ISerializerRow.cpp =================================================================== diff -u -N --- src/libchcore/ISerializerRow.cpp (revision 0) +++ src/libchcore/ISerializerRow.cpp (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) @@ -0,0 +1,29 @@ +// ============================================================================ +// Copyright (C) 2001-2014 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#include "stdafx.h" +#include "ISerializerRow.h" + +BEGIN_CHCORE_NAMESPACE + +ISerializerRow::~ISerializerRow() +{ + +} + +END_CHCORE_NAMESPACE Index: src/libchcore/ISerializerRow.h =================================================================== diff -u -N --- src/libchcore/ISerializerRow.h (revision 0) +++ src/libchcore/ISerializerRow.h (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) @@ -0,0 +1,36 @@ +// ============================================================================ +// Copyright (C) 2001-2014 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#ifndef __ISERIALIZERROW_H__ +#define __ISERIALIZERROW_H__ + +#include "libchcore.h" + +BEGIN_CHCORE_NAMESPACE + +class LIBCHCORE_API ISerializerRow +{ +public: + virtual ~ISerializerRow(); +}; + +typedef boost::shared_ptr ISerializerRowPtr; + +END_CHCORE_NAMESPACE + +#endif Index: src/libchcore/TRowData.cpp =================================================================== diff -u -N --- src/libchcore/TRowData.cpp (revision 0) +++ src/libchcore/TRowData.cpp (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) @@ -0,0 +1,82 @@ +// ============================================================================ +// Copyright (C) 2001-2013 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#include "stdafx.h" +#include "TRowData.h" + +BEGIN_CHCORE_NAMESPACE + +TRowData::TRowData(const TString& strColName, bool bValue) : + m_strColName(strColName), + m_varValue(bValue) +{ +} + +TRowData::TRowData(const TString& strColName, short iValue) : + m_strColName(strColName), + m_varValue(iValue) +{ +} + +TRowData::TRowData(const TString& strColName, unsigned short uiValue) : + m_strColName(strColName), + m_varValue(uiValue) +{ +} + +TRowData::TRowData(const TString& strColName, int iValue) : + m_strColName(strColName), + m_varValue(iValue) +{ +} + +TRowData::TRowData(const TString& strColName, unsigned int uiValue) : + m_strColName(strColName), + m_varValue(uiValue) +{ +} + +TRowData::TRowData(const TString& strColName, long long llValue) : + m_strColName(strColName), + m_varValue(llValue) +{ +} + +TRowData::TRowData(const TString& strColName, unsigned long long ullValue) : + m_strColName(strColName), + m_varValue(ullValue) +{ +} + +TRowData::TRowData(const TString& strColName, double dValue) : + m_strColName(strColName), + m_varValue(dValue) +{ +} + +TRowData::TRowData(const TString& strColName, const TString& strValue) : + m_strColName(strColName), + m_varValue(strValue) +{ +} + +TRowData::~TRowData() +{ +} + +END_CHCORE_NAMESPACE Index: src/libchcore/TRowData.h =================================================================== diff -u -N --- src/libchcore/TRowData.h (revision 0) +++ src/libchcore/TRowData.h (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) @@ -0,0 +1,71 @@ +// ============================================================================ +// Copyright (C) 2001-2014 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#ifndef __TROWDATA_H__ +#define __TROWDATA_H__ + +#include "libchcore.h" +#include "TString.h" +#include + +BEGIN_CHCORE_NAMESPACE + +class LIBCHCORE_API TRowData +{ +public: + TRowData(const TString& strColName, bool bValue); + TRowData(const TString& strColName, short iValue); + TRowData(const TString& strColName, unsigned short uiValue); + TRowData(const TString& strColName, int iValue); + TRowData(const TString& strColName, unsigned int uiValue); + TRowData(const TString& strColName, long long llValue); + TRowData(const TString& strColName, unsigned long long llValue); + TRowData(const TString& strColName, double dValue); + TRowData(const TString& strColName, const TString& strValue); + + ~TRowData(); + +private: + typedef boost::variant< + bool, + short, + unsigned short, + int, + unsigned int, + long, + unsigned long, + long long, + unsigned long long, + double, + TString + > InternalVariant; + + TString m_strColName; +#pragma warning(push) +#pragma warning(disable: 4251) + InternalVariant m_varValue; +#pragma warning(pop) + + friend class TSQLiteSerializerRow; +}; + +typedef boost::shared_ptr TRowDataPtr; + +END_CHCORE_NAMESPACE + +#endif Index: src/libchcore/TSQLiteColumnDefinition.cpp =================================================================== diff -u -N --- src/libchcore/TSQLiteColumnDefinition.cpp (revision 0) +++ src/libchcore/TSQLiteColumnDefinition.cpp (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) @@ -0,0 +1,65 @@ +// ============================================================================ +// Copyright (C) 2001-2013 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#include "stdafx.h" +#include "TSQLiteColumnDefinition.h" +#include "ErrorCodes.h" +#include "TCoreException.h" + +BEGIN_CHCORE_NAMESPACE + +TSQLiteColumnDefinition::TSQLiteColumnDefinition() +{ +} + +TSQLiteColumnDefinition::~TSQLiteColumnDefinition() +{ +} + +size_t TSQLiteColumnDefinition::AddColumn(const TString& strColumnName) +{ + m_vColumns.push_back(strColumnName); + return m_vColumns.size() - 1; +} + +void TSQLiteColumnDefinition::Clear() +{ + m_vColumns.clear(); +} + +size_t TSQLiteColumnDefinition::GetColumnIndex(const TString& strColumnName, bool bAdd) +{ + std::vector::const_iterator iterFnd = std::find(m_vColumns.begin(), m_vColumns.end(), strColumnName); + if(iterFnd == m_vColumns.end()) + { + if(bAdd) + return AddColumn(strColumnName); + + THROW_CORE_EXCEPTION(eErr_InvalidData); + } + + std::vector::const_iterator iterBegin = m_vColumns.begin(); + return std::distance(iterBegin, iterFnd); +} + +TString TSQLiteColumnDefinition::GetColumnName(size_t stIndex) const +{ + return m_vColumns.at(stIndex); +} + +END_CHCORE_NAMESPACE Index: src/libchcore/TSQLiteColumnDefinition.h =================================================================== diff -u -N --- src/libchcore/TSQLiteColumnDefinition.h (revision 0) +++ src/libchcore/TSQLiteColumnDefinition.h (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) @@ -0,0 +1,51 @@ +// ============================================================================ +// Copyright (C) 2001-2014 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#ifndef __TSQLITECOLUMNDEFINITION_H__ +#define __TSQLITECOLUMNDEFINITION_H__ + +#include "libchcore.h" +#include "TString.h" +#include + +BEGIN_CHCORE_NAMESPACE + +class LIBCHCORE_API TSQLiteColumnDefinition +{ +public: + TSQLiteColumnDefinition(); + ~TSQLiteColumnDefinition(); + + size_t AddColumn(const TString& strColumnName); + void Clear(); + + size_t GetColumnIndex(const TString& strColumnName, bool bAdd = true); + TString GetColumnName(size_t stIndex) const; + +private: +#pragma warning(push) +#pragma warning(disable: 4251) + std::vector m_vColumns; +#pragma warning(pop) +}; + +typedef boost::shared_ptr TSQLiteColumnDefinitionPtr; + +END_CHCORE_NAMESPACE + +#endif Index: src/libchcore/TSQLiteSerializer.cpp =================================================================== diff -u -N --- src/libchcore/TSQLiteSerializer.cpp (revision 0) +++ src/libchcore/TSQLiteSerializer.cpp (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) @@ -0,0 +1,41 @@ +// ============================================================================ +// Copyright (C) 2001-2013 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#include "stdafx.h" +#include "TSQLiteSerializer.h" +#include "TSQLiteSerializerContainer.h" + +BEGIN_CHCORE_NAMESPACE + +using namespace sqlite; + +TSQLiteSerializer::TSQLiteSerializer(const TSQLiteDatabasePtr& spDatabase) : + m_spDatabase(spDatabase) +{ +} + +ISerializerContainerPtr TSQLiteSerializer::GetContainer(const TString& strContainerName) +{ + std::map::iterator iterMap = m_mapContainers.find(strContainerName); + if(iterMap == m_mapContainers.end()) + iterMap = m_mapContainers.insert(std::make_pair(strContainerName, TSQLiteSerializerContainerPtr(new TSQLiteSerializerContainer))).first; + + return iterMap->second; +} + +END_CHCORE_NAMESPACE Index: src/libchcore/TSQLiteSerializer.h =================================================================== diff -u -N --- src/libchcore/TSQLiteSerializer.h (revision 0) +++ src/libchcore/TSQLiteSerializer.h (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) @@ -0,0 +1,50 @@ +// ============================================================================ +// Copyright (C) 2001-2014 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#ifndef __TSQLITESERIALIZER_H__ +#define __TSQLITESERIALIZER_H__ + +#include "libchcore.h" +#include +#include "ISerializer.h" +#include "TSQLiteDatabase.h" +#include "TString.h" +#include "ISerializerContainer.h" + +BEGIN_CHCORE_NAMESPACE + +class LIBCHCORE_API TSQLiteSerializer : public ISerializer +{ +public: + TSQLiteSerializer(const sqlite::TSQLiteDatabasePtr& spDatabase); + + ISerializerContainerPtr GetContainer(const TString& strContainerName); + +private: +#pragma warning(push) +#pragma warning(disable: 4251) + sqlite::TSQLiteDatabasePtr m_spDatabase; + std::map m_mapContainers; +#pragma warning(pop) +}; + +typedef boost::shared_ptr TSQLiteSerializerPtr; + +END_CHCORE_NAMESPACE + +#endif Index: src/libchcore/TSQLiteSerializerContainer.cpp =================================================================== diff -u -N --- src/libchcore/TSQLiteSerializerContainer.cpp (revision 0) +++ src/libchcore/TSQLiteSerializerContainer.cpp (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) @@ -0,0 +1,62 @@ +// ============================================================================ +// Copyright (C) 2001-2013 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#include "stdafx.h" +#include "TSQLiteSerializerContainer.h" +#include "TSQLiteSerializerRow.h" + +BEGIN_CHCORE_NAMESPACE + +TSQLiteSerializerContainer::TSQLiteSerializerContainer() : + m_spColumns(new TSQLiteColumnDefinition) +{ +} + +TSQLiteSerializerContainer::TSQLiteSerializerContainer(size_t stParentID) : + m_stParentID(stParentID), + m_spColumns(new TSQLiteColumnDefinition) +{ +} + +TSQLiteSerializerContainer::~TSQLiteSerializerContainer() +{ +} + +chcore::ISerializerRowPtr TSQLiteSerializerContainer::GetNewRow() +{ + size_t stNewIndex = 0; + + if(m_mapRows.rbegin() != m_mapRows.rend()) + { + stNewIndex = m_mapRows.rbegin()->first + 1; + } + + std::map::iterator iterInsert = m_mapRows.insert(std::make_pair(stNewIndex, TSQLiteSerializerRowPtr(new TSQLiteSerializerRow(stNewIndex, m_spColumns)))).first; + return (*iterInsert).second; +} + +ISerializerRowPtr TSQLiteSerializerContainer::GetRow(size_t stRowID) +{ + std::map::iterator iterFnd = m_mapRows.find(stRowID); + if(iterFnd == m_mapRows.end()) + iterFnd = m_mapRows.insert(std::make_pair(stRowID, ISerializerRowPtr(new TSQLiteSerializerRow(stRowID, m_spColumns)))).first; + + return (*iterFnd).second; +} + +END_CHCORE_NAMESPACE Index: src/libchcore/TSQLiteSerializerContainer.h =================================================================== diff -u -N --- src/libchcore/TSQLiteSerializerContainer.h (revision 0) +++ src/libchcore/TSQLiteSerializerContainer.h (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) @@ -0,0 +1,54 @@ +// ============================================================================ +// Copyright (C) 2001-2014 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#ifndef __TSQLITESERIALIZERCONTAINER_H__ +#define __TSQLITESERIALIZERCONTAINER_H__ + +#include "libchcore.h" +#include "ISerializerRow.h" +#include "ISerializerContainer.h" +#include +#include +#include "TSQLiteColumnDefinition.h" + +BEGIN_CHCORE_NAMESPACE + +class LIBCHCORE_API TSQLiteSerializerContainer : public ISerializerContainer +{ +public: + TSQLiteSerializerContainer(); + TSQLiteSerializerContainer(size_t stParentID); + virtual ~TSQLiteSerializerContainer(); + + ISerializerRowPtr GetNewRow(); + ISerializerRowPtr GetRow(size_t stRowID); + +private: +#pragma warning(push) +#pragma warning(disable: 4251) + std::map m_mapRows; + boost::optional m_stParentID; + TSQLiteColumnDefinitionPtr m_spColumns; +#pragma warning(pop) +}; + +typedef boost::shared_ptr TSQLiteSerializerContainerPtr; + +END_CHCORE_NAMESPACE + +#endif Index: src/libchcore/TSQLiteSerializerRow.cpp =================================================================== diff -u -N --- src/libchcore/TSQLiteSerializerRow.cpp (revision 0) +++ src/libchcore/TSQLiteSerializerRow.cpp (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) @@ -0,0 +1,52 @@ +// ============================================================================ +// Copyright (C) 2001-2013 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#include "stdafx.h" +#include "TSQLiteSerializerRow.h" +#include "TSQLiteSerializerContainer.h" + +BEGIN_CHCORE_NAMESPACE + +TSQLiteSerializerRow::TSQLiteSerializerRow(size_t stRowID, const TSQLiteColumnDefinitionPtr& spColumnDefinition) : + m_stRowID(stRowID), + m_spColumns(spColumnDefinition) +{ +} + +TSQLiteSerializerRow::~TSQLiteSerializerRow() +{ +} + +ISerializerContainerPtr TSQLiteSerializerRow::GetContainer() +{ + return ISerializerContainerPtr(new TSQLiteSerializerContainer(m_stRowID)); +} + +ISerializerRow& TSQLiteSerializerRow::operator%(const TRowData& rData) +{ + size_t stColumn = m_spColumns->GetColumnIndex(rData.m_strColName); + std::map::iterator iterFnd = m_mapValues.find(stColumn); + if(iterFnd == m_mapValues.end()) + m_mapValues.insert(std::make_pair(stColumn, rData.m_varValue)); + else + (*iterFnd).second = rData.m_varValue; + + return *this; +} + +END_CHCORE_NAMESPACE Index: src/libchcore/TSQLiteSerializerRow.h =================================================================== diff -u -N --- src/libchcore/TSQLiteSerializerRow.h (revision 0) +++ src/libchcore/TSQLiteSerializerRow.h (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) @@ -0,0 +1,53 @@ +// ============================================================================ +// Copyright (C) 2001-2014 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#ifndef __TSQLITESERIALIZERROW_H__ +#define __TSQLITESERIALIZERROW_H__ + +#include "libchcore.h" +#include "ISerializerRow.h" +#include "TSQLiteColumnDefinition.h" +#include "ISerializerContainer.h" +#include "TRowData.h" + +BEGIN_CHCORE_NAMESPACE + +class LIBCHCORE_API TSQLiteSerializerRow : public ISerializerRow +{ +public: + TSQLiteSerializerRow(size_t stRowID, const TSQLiteColumnDefinitionPtr& spColumnDefinition); + virtual ~TSQLiteSerializerRow(); + + ISerializerContainerPtr GetContainer(); + + ISerializerRow& operator%(const TRowData& rData); + +private: + size_t m_stRowID; +#pragma warning(push) +#pragma warning(disable: 4251) + TSQLiteColumnDefinitionPtr m_spColumns; + std::map m_mapValues; +#pragma warning(pop) +}; + +typedef boost::shared_ptr TSQLiteSerializerRowPtr; + +END_CHCORE_NAMESPACE + +#endif Index: src/libchcore/libchcore.vc90.vcproj =================================================================== diff -u -N -rb1ecc12ba4c1f2a7b4acd6e82fc4193535e55ff0 -r4a7f28238afbf60b9e3f3daeffe590ff1638ec74 --- src/libchcore/libchcore.vc90.vcproj (.../libchcore.vc90.vcproj) (revision b1ecc12ba4c1f2a7b4acd6e82fc4193535e55ff0) +++ src/libchcore/libchcore.vc90.vcproj (.../libchcore.vc90.vcproj) (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) @@ -1276,6 +1276,30 @@ Name="Serialization" > + + + + + + + + + + + + @@ -1295,6 +1319,14 @@ Name="SQLite" > + + + + @@ -1303,6 +1335,42 @@ > + + + + + + + + + + + + + + + + + +