Index: src/ch/ClipboardMonitor.cpp =================================================================== diff -u -r1d8d51e0dd4d8ebcf0bd457d01fab984585220c0 -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/ch/ClipboardMonitor.cpp (.../ClipboardMonitor.cpp) (revision 1d8d51e0dd4d8ebcf0bd457d01fab984585220c0) +++ src/ch/ClipboardMonitor.cpp (.../ClipboardMonitor.cpp) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -29,6 +29,8 @@ #include "FolderDialog.h" #include "ShutdownDlg.h" +using namespace chcore; + CClipboardMonitor CClipboardMonitor::S_ClipboardMonitor; CClipboardMonitor::CClipboardMonitor() @@ -181,13 +183,30 @@ chcore::SetTaskPropValue(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_FIRSTCOPY_STRING)); chcore::SetTaskPropValue(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_NEXTCOPY_STRING)); - chcore::TTaskPtr spTask = pData->m_pTasks->CreateTask(tTaskDefinition); + CString strMessage; + try + { + chcore::TTaskPtr spTask = pData->m_pTasks->CreateTask(tTaskDefinition); - // write spTask to a file - spTask->Store(); + // write spTask to a file + spTask->Store(); - // start processing - spTask->BeginProcessing(); + // start processing + spTask->BeginProcessing(); + } + catch(const std::exception& e) + { + strMessage = e.what(); + } + + if(!strMessage.IsEmpty()) + { + ictranslate::CFormat fmt; + + fmt.SetFormat(GetResManager().LoadString(IDS_TASK_CREATE_FAILED)); + fmt.SetParam(_T("%reason"), strMessage); + AfxMessageBox(fmt, MB_OK | MB_ICONERROR); + } } } Index: src/ch/MainWnd.cpp =================================================================== diff -u -r1342b18babc7e88850e74f46cb473a737a68f28a -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision 1342b18babc7e88850e74f46cb473a737a68f28a) +++ src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -41,7 +41,8 @@ #include "../libchcore/TCoreException.h" #include "../libicpf/exception.h" #include "../libchcore/TTaskManagerStatsSnapshot.h" -#include "../libchcore/TTaskManagerSerializer.h" +#include "../libchcore/TSQLiteSerializer.h" +#include "../libchcore/TTaskManagerSchema.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -186,21 +187,8 @@ // Create the tray icon ShowTrayIcon(); - CString strTasksDir = GetTasksDirectory(); - CString strTMPath = strTasksDir + _T("tasks.sqlite"); + LoadTaskManager(); - chcore::TTaskManagerSerializerPtr spSerializer(new chcore::TTaskManagerSerializer( - chcore::PathFromString(strTMPath), - chcore::PathFromString(strTasksDir))); - - m_spTasks.reset(new chcore::TTaskManager(spSerializer, m_pFeedbackFactory)); - - // load last state - LOG_INFO(_T("Loading existing tasks...")); - - // load tasks - m_spTasks->Load(); - // import tasks specified at command line (before loading current tasks) const TCommandLineParser& cmdLine = GetApp().GetCommandLine(); ProcessCommandLine(cmdLine); @@ -298,6 +286,24 @@ return 0; } +void CMainWnd::LoadTaskManager() +{ + CString strTasksDir = GetTasksDirectory(); + CString strTMPath = strTasksDir + _T("tasks.sqlite"); + + chcore::TSQLiteSerializerPtr spSerializer(new chcore::TSQLiteSerializer( + chcore::PathFromString(strTMPath), + chcore::TTaskManagerSchemaPtr(new chcore::TTaskManagerSchema))); + + m_spTasks.reset(new chcore::TTaskManager(spSerializer, m_pFeedbackFactory)); + + // load last state + LOG_INFO(_T("Loading existing tasks...")); + + // load tasks + m_spTasks->Load(); +} + LRESULT CMainWnd::OnTrayNotification(WPARAM wParam, LPARAM lParam) { if (wParam != m_ctlTray.m_tnd.uID) Index: src/ch/MainWnd.h =================================================================== diff -u -rb1ecc12ba4c1f2a7b4acd6e82fc4193535e55ff0 -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/ch/MainWnd.h (.../MainWnd.h) (revision b1ecc12ba4c1f2a7b4acd6e82fc4193535e55ff0) +++ src/ch/MainWnd.h (.../MainWnd.h) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -56,6 +56,9 @@ afx_msg void OnTimer(UINT_PTR nIDEvent); afx_msg BOOL OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct); afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + + void LoadTaskManager(); + afx_msg void OnShowMiniView(); afx_msg void OnPopupCustomCopy(); afx_msg void OnAppAbout(); Index: src/ch/ch.rc =================================================================== diff -u -r9b8cccbee0fcfeca28a112cc0253a7641f73f74f -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/ch/ch.rc (.../ch.rc) (revision 9b8cccbee0fcfeca28a112cc0253a7641f73f74f) +++ src/ch/ch.rc (.../ch.rc) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -1084,6 +1084,7 @@ "Copy Handler's component enabling integration with system was updated.\nPlease reboot your system for changes to take effect." IDS_CH_PORTABLE_STRING " (portable mode)" IDS_TASK_IMPORT_FAILED "Failed to import task '%path'." + IDS_TASK_CREATE_FAILED "Cannot create new task. Reason: %reason." END STRINGTABLE Index: src/ch/resource.h =================================================================== diff -u -r9b8cccbee0fcfeca28a112cc0253a7641f73f74f -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/ch/resource.h (.../resource.h) (revision 9b8cccbee0fcfeca28a112cc0253a7641f73f74f) +++ src/ch/resource.h (.../resource.h) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -371,6 +371,7 @@ #define IDS_SHELL_EXTENSION_REGISTERED_MISMATCH_STRING 5029 #define IDS_CH_PORTABLE_STRING 5030 #define IDS_TASK_IMPORT_FAILED 5031 +#define IDS_TASK_CREATE_FAILED 5032 #define IDS_ONECOPY_STRING 6000 #define IDS_REGISTEROK_STRING 6001 #define IDS_REGISTERERR_STRING 6002 Fisheye: tag 4a7f28238afbf60b9e3f3daeffe590ff1638ec74 is not in file src/libchcore/IColumnsDefinition.cpp Index: src/libchcore/IColumnsDefinition.h =================================================================== diff -u --- src/libchcore/IColumnsDefinition.h (revision 0) +++ src/libchcore/IColumnsDefinition.h (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -0,0 +1,47 @@ +// ============================================================================ +// 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 __ICOLUMNSDEFINITION_H__ +#define __ICOLUMNSDEFINITION_H__ + +#include "libchcore.h" +#include "TString.h" + +BEGIN_CHCORE_NAMESPACE + +class LIBCHCORE_API IColumnsDefinition +{ +public: + virtual ~IColumnsDefinition(); + + virtual size_t AddColumn(const TString& strColumnName) = 0; + virtual void Clear() = 0; + + virtual size_t GetColumnIndex(const TString& strColumnName, bool bAdd = true) = 0; + virtual TString GetColumnName(size_t stIndex) const = 0; + virtual size_t GetCount() const = 0; + virtual bool IsEmpty() const = 0; + + virtual IColumnsDefinition& operator%(const TString& strColName) = 0; +}; + +typedef boost::shared_ptr IColumnsDefinitionPtr; + +END_CHCORE_NAMESPACE + +#endif Fisheye: tag 4a7f28238afbf60b9e3f3daeffe590ff1638ec74 is not in file src/libchcore/ISQLiteSerializerSchema.cpp Fisheye: tag 4a7f28238afbf60b9e3f3daeffe590ff1638ec74 is not in file src/libchcore/ISQLiteSerializerSchema.h Index: src/libchcore/ISerializer.cpp =================================================================== diff -u -r4a7f28238afbf60b9e3f3daeffe590ff1638ec74 -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/libchcore/ISerializer.cpp (.../ISerializer.cpp) (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) +++ src/libchcore/ISerializer.cpp (.../ISerializer.cpp) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -23,7 +23,6 @@ ISerializer::~ISerializer() { - } END_CHCORE_NAMESPACE Index: src/libchcore/ISerializer.h =================================================================== diff -u -r4a7f28238afbf60b9e3f3daeffe590ff1638ec74 -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/libchcore/ISerializer.h (.../ISerializer.h) (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) +++ src/libchcore/ISerializer.h (.../ISerializer.h) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -20,13 +20,20 @@ #define __ISERIALIZER_H__ #include "libchcore.h" +#include "TPath.h" +#include "ISerializerContainer.h" BEGIN_CHCORE_NAMESPACE class LIBCHCORE_API ISerializer { public: virtual ~ISerializer(); + + virtual TSmartPath GetLocation() const = 0; + virtual ISerializerContainerPtr GetContainer(const TString& strContainerName) = 0; + + virtual void Flush() = 0; }; typedef boost::shared_ptr ISerializerPtr; Index: src/libchcore/ISerializerContainer.h =================================================================== diff -u -r4a7f28238afbf60b9e3f3daeffe590ff1638ec74 -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/libchcore/ISerializerContainer.h (.../ISerializerContainer.h) (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) +++ src/libchcore/ISerializerContainer.h (.../ISerializerContainer.h) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -20,13 +20,29 @@ #define __ISERIALIZERCONTAINER_H__ #include "libchcore.h" +#include "IColumnsDefinition.h" +#include "ISerializerRowReader.h" BEGIN_CHCORE_NAMESPACE +class ISerializerRowWriter; +typedef boost::shared_ptr ISerializerRowWriterPtr; + class LIBCHCORE_API ISerializerContainer { public: virtual ~ISerializerContainer(); + + // columns + virtual IColumnsDefinitionPtr GetColumnsDefinition() const = 0; + + // prepare data to be stored + virtual ISerializerRowWriterPtr AddRow(size_t stRowID) = 0; + virtual ISerializerRowWriterPtr GetRow(size_t stRowID) = 0; + virtual void DeleteRow(size_t stRowID) = 0; + + // getting data from the serialized archive + virtual ISerializerRowReaderPtr GetRowReader() = 0; }; typedef boost::shared_ptr ISerializerContainerPtr; Fisheye: tag 4a7f28238afbf60b9e3f3daeffe590ff1638ec74 is not in file src/libchcore/ISerializerRowReader.cpp Index: src/libchcore/ISerializerRowReader.h =================================================================== diff -u --- src/libchcore/ISerializerRowReader.h (revision 0) +++ src/libchcore/ISerializerRowReader.h (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -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 __ISERIALIZERROWREADER_H__ +#define __ISERIALIZERROWREADER_H__ + +#include "libchcore.h" +#include "TString.h" +#include "TPath.h" +#include "IColumnsDefinition.h" + +BEGIN_CHCORE_NAMESPACE + +class LIBCHCORE_API ISerializerRowReader +{ +public: + virtual ~ISerializerRowReader(); + + virtual IColumnsDefinitionPtr GetColumnsDefinitions() const = 0; + + virtual bool Next() = 0; + + virtual void GetValue(const TString& strColName, bool& bValue) = 0; + virtual void GetValue(const TString& strColName, short& iValue) = 0; + virtual void GetValue(const TString& strColName, unsigned short& uiValue) = 0; + virtual void GetValue(const TString& strColName, int& iValue) = 0; + virtual void GetValue(const TString& strColName, unsigned int& uiValue) = 0; + virtual void GetValue(const TString& strColName, long long& llValue) = 0; + virtual void GetValue(const TString& strColName, unsigned long long& llValue) = 0; + virtual void GetValue(const TString& strColName, double& dValue) = 0; + virtual void GetValue(const TString& strColName, TString& strValue) = 0; + virtual void GetValue(const TString& strColName, TSmartPath& pathValue) = 0; +}; + +typedef boost::shared_ptr ISerializerRowReaderPtr; + +END_CHCORE_NAMESPACE + +#endif Fisheye: tag 4a7f28238afbf60b9e3f3daeffe590ff1638ec74 is not in file src/libchcore/ISerializerRowWriter.cpp Fisheye: Tag 9479911a096555a7504c5c8a8eaee83ecb63440c refers to a dead (removed) revision in file `src/libchcore/ISerializerRow.cpp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: tag 4a7f28238afbf60b9e3f3daeffe590ff1638ec74 is not in file src/libchcore/ISerializerRowWriter.h Index: src/libchcore/TRowData.cpp =================================================================== diff -u -r4a7f28238afbf60b9e3f3daeffe590ff1638ec74 -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/libchcore/TRowData.cpp (.../TRowData.cpp) (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) +++ src/libchcore/TRowData.cpp (.../TRowData.cpp) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -75,6 +75,12 @@ { } +TRowData::TRowData(const TString& strColName, const TSmartPath& pathValue) : + m_strColName(strColName), + m_varValue(pathValue) +{ +} + TRowData::~TRowData() { } Index: src/libchcore/TRowData.h =================================================================== diff -u -r4a7f28238afbf60b9e3f3daeffe590ff1638ec74 -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/libchcore/TRowData.h (.../TRowData.h) (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) +++ src/libchcore/TRowData.h (.../TRowData.h) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -21,12 +21,18 @@ #include "libchcore.h" #include "TString.h" +#include "TPath.h" + #include BEGIN_CHCORE_NAMESPACE class LIBCHCORE_API TRowData { +private: + TRowData(const TRowData&); + TRowData& operator=(const TRowData&); + public: TRowData(const TString& strColName, bool bValue); TRowData(const TString& strColName, short iValue); @@ -37,6 +43,7 @@ TRowData(const TString& strColName, unsigned long long llValue); TRowData(const TString& strColName, double dValue); TRowData(const TString& strColName, const TString& strValue); + TRowData(const TString& strColName, const TSmartPath& pathValue); ~TRowData(); @@ -52,7 +59,8 @@ long long, unsigned long long, double, - TString + TString, + TSmartPath > InternalVariant; TString m_strColName; @@ -61,7 +69,7 @@ InternalVariant m_varValue; #pragma warning(pop) - friend class TSQLiteSerializerRow; + friend class TSQLiteSerializerRowWriter; }; typedef boost::shared_ptr TRowDataPtr; Index: src/libchcore/TSQLiteColumnDefinition.cpp =================================================================== diff -u -r4a7f28238afbf60b9e3f3daeffe590ff1638ec74 -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/libchcore/TSQLiteColumnDefinition.cpp (.../TSQLiteColumnDefinition.cpp) (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) +++ src/libchcore/TSQLiteColumnDefinition.cpp (.../TSQLiteColumnDefinition.cpp) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -23,26 +23,26 @@ BEGIN_CHCORE_NAMESPACE -TSQLiteColumnDefinition::TSQLiteColumnDefinition() +TSQLiteColumnsDefinition::TSQLiteColumnsDefinition() { } -TSQLiteColumnDefinition::~TSQLiteColumnDefinition() +TSQLiteColumnsDefinition::~TSQLiteColumnsDefinition() { } -size_t TSQLiteColumnDefinition::AddColumn(const TString& strColumnName) +size_t TSQLiteColumnsDefinition::AddColumn(const TString& strColumnName) { m_vColumns.push_back(strColumnName); return m_vColumns.size() - 1; } -void TSQLiteColumnDefinition::Clear() +void TSQLiteColumnsDefinition::Clear() { m_vColumns.clear(); } -size_t TSQLiteColumnDefinition::GetColumnIndex(const TString& strColumnName, bool bAdd) +size_t TSQLiteColumnsDefinition::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()) @@ -57,9 +57,37 @@ return std::distance(iterBegin, iterFnd); } -TString TSQLiteColumnDefinition::GetColumnName(size_t stIndex) const +TString TSQLiteColumnsDefinition::GetColumnName(size_t stIndex) const { return m_vColumns.at(stIndex); } +size_t TSQLiteColumnsDefinition::GetCount() const +{ + return m_vColumns.size(); +} + +bool TSQLiteColumnsDefinition::IsEmpty() const +{ + return m_vColumns.empty(); +} + +IColumnsDefinition& TSQLiteColumnsDefinition::operator%(const TString& strColName) +{ + AddColumn(strColName); + return *this; +} + +chcore::TString TSQLiteColumnsDefinition::GetCommaSeparatedColumns() const +{ + TString strColumns; + BOOST_FOREACH(const TString& strName, m_vColumns) + { + strColumns += strName + _T(","); + } + + strColumns.TrimRightSelf(_T(",")); + return strColumns; +} + END_CHCORE_NAMESPACE Index: src/libchcore/TSQLiteColumnDefinition.h =================================================================== diff -u -r4a7f28238afbf60b9e3f3daeffe590ff1638ec74 -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/libchcore/TSQLiteColumnDefinition.h (.../TSQLiteColumnDefinition.h) (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) +++ src/libchcore/TSQLiteColumnDefinition.h (.../TSQLiteColumnDefinition.h) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -22,29 +22,36 @@ #include "libchcore.h" #include "TString.h" #include +#include "IColumnsDefinition.h" BEGIN_CHCORE_NAMESPACE -class LIBCHCORE_API TSQLiteColumnDefinition +class LIBCHCORE_API TSQLiteColumnsDefinition : public IColumnsDefinition { public: - TSQLiteColumnDefinition(); - ~TSQLiteColumnDefinition(); + TSQLiteColumnsDefinition(); + virtual ~TSQLiteColumnsDefinition(); - size_t AddColumn(const TString& strColumnName); - void Clear(); + virtual size_t AddColumn(const TString& strColumnName); + virtual void Clear(); - size_t GetColumnIndex(const TString& strColumnName, bool bAdd = true); - TString GetColumnName(size_t stIndex) const; + virtual size_t GetColumnIndex(const TString& strColumnName, bool bAdd = true); + virtual TString GetColumnName(size_t stIndex) const; + virtual size_t GetCount() const; + virtual bool IsEmpty() const; + virtual IColumnsDefinition& operator%(const TString& strColName); + + virtual TString GetCommaSeparatedColumns() const; + private: #pragma warning(push) #pragma warning(disable: 4251) std::vector m_vColumns; #pragma warning(pop) }; -typedef boost::shared_ptr TSQLiteColumnDefinitionPtr; +typedef boost::shared_ptr TSQLiteColumnDefinitionPtr; END_CHCORE_NAMESPACE Index: src/libchcore/TSQLiteDatabase.cpp =================================================================== diff -u -rb1ecc12ba4c1f2a7b4acd6e82fc4193535e55ff0 -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/libchcore/TSQLiteDatabase.cpp (.../TSQLiteDatabase.cpp) (revision b1ecc12ba4c1f2a7b4acd6e82fc4193535e55ff0) +++ src/libchcore/TSQLiteDatabase.cpp (.../TSQLiteDatabase.cpp) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -26,11 +26,12 @@ namespace sqlite { - TSQLiteDatabase::TSQLiteDatabase(PCTSTR pszFilename) : + TSQLiteDatabase::TSQLiteDatabase(const TSmartPath& pathDatabase) : m_pDBHandle(NULL), - m_bInTransaction(false) + m_bInTransaction(false), + m_pathDatabase(pathDatabase) { - int iResult = sqlite3_open16(pszFilename, &m_pDBHandle); + int iResult = sqlite3_open16(m_pathDatabase.ToString(), &m_pDBHandle); if(iResult != SQLITE_OK) { const wchar_t* pszMsg = (const wchar_t*)sqlite3_errmsg16(m_pDBHandle); @@ -59,6 +60,11 @@ { m_bInTransaction = bInTransaction; } + + chcore::TSmartPath TSQLiteDatabase::GetLocation() const + { + return m_pathDatabase; + } } END_CHCORE_NAMESPACE Index: src/libchcore/TSQLiteDatabase.h =================================================================== diff -u -r3397fd021739bea537248415a7b4fc2712dd2320 -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/libchcore/TSQLiteDatabase.h (.../TSQLiteDatabase.h) (revision 3397fd021739bea537248415a7b4fc2712dd2320) +++ src/libchcore/TSQLiteDatabase.h (.../TSQLiteDatabase.h) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -20,6 +20,7 @@ #define __TSQLITEDATABASE_H__ #include "libchcore.h" +#include "TPath.h" struct sqlite3; @@ -30,16 +31,20 @@ class TSQLiteDatabase { public: - explicit TSQLiteDatabase(PCTSTR pszFilename); + explicit TSQLiteDatabase(const TSmartPath& strFilename); ~TSQLiteDatabase(); + HANDLE GetHandle(); + TSmartPath GetLocation() const; + bool GetInTransaction() const; protected: void SetInTransaction(bool bInTransaction); private: + TSmartPath m_pathDatabase; sqlite3* m_pDBHandle; bool m_bInTransaction; // global transaction state Index: src/libchcore/TSQLiteSerializer.cpp =================================================================== diff -u -r4a7f28238afbf60b9e3f3daeffe590ff1638ec74 -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/libchcore/TSQLiteSerializer.cpp (.../TSQLiteSerializer.cpp) (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) +++ src/libchcore/TSQLiteSerializer.cpp (.../TSQLiteSerializer.cpp) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -19,23 +19,42 @@ #include "stdafx.h" #include "TSQLiteSerializer.h" #include "TSQLiteSerializerContainer.h" +#include "TCoreException.h" +#include "ErrorCodes.h" BEGIN_CHCORE_NAMESPACE using namespace sqlite; -TSQLiteSerializer::TSQLiteSerializer(const TSQLiteDatabasePtr& spDatabase) : - m_spDatabase(spDatabase) +TSQLiteSerializer::TSQLiteSerializer(const TSmartPath& pathDB, const ISerializerSchemaPtr& spSchema) : + m_spDatabase(new TSQLiteDatabase(pathDB)), + m_spSchema(spSchema) { + if(!m_spDatabase || !m_spSchema) + THROW_CORE_EXCEPTION(eErr_InvalidArgument); + + m_spSchema->Setup(m_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; + iterMap = m_mapContainers.insert(std::make_pair( + strContainerName, + TSQLiteSerializerContainerPtr(new TSQLiteSerializerContainer(strContainerName, m_spDatabase)))).first; return iterMap->second; } +chcore::TSmartPath TSQLiteSerializer::GetLocation() const +{ + return m_spDatabase->GetLocation(); +} + +void TSQLiteSerializer::Flush() +{ + // TODO: generate the necessary queries and execute them +} + END_CHCORE_NAMESPACE Index: src/libchcore/TSQLiteSerializer.h =================================================================== diff -u -r4a7f28238afbf60b9e3f3daeffe590ff1638ec74 -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/libchcore/TSQLiteSerializer.h (.../TSQLiteSerializer.h) (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) +++ src/libchcore/TSQLiteSerializer.h (.../TSQLiteSerializer.h) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -25,20 +25,26 @@ #include "TSQLiteDatabase.h" #include "TString.h" #include "ISerializerContainer.h" +#include "TPath.h" +#include "ISQLiteSerializerSchema.h" BEGIN_CHCORE_NAMESPACE class LIBCHCORE_API TSQLiteSerializer : public ISerializer { public: - TSQLiteSerializer(const sqlite::TSQLiteDatabasePtr& spDatabase); + TSQLiteSerializer(const TSmartPath& pathDB, const ISerializerSchemaPtr& spSchema); - ISerializerContainerPtr GetContainer(const TString& strContainerName); + virtual TSmartPath GetLocation() const; + virtual ISerializerContainerPtr GetContainer(const TString& strContainerName); + virtual void Flush(); + private: #pragma warning(push) #pragma warning(disable: 4251) sqlite::TSQLiteDatabasePtr m_spDatabase; + ISerializerSchemaPtr m_spSchema; std::map m_mapContainers; #pragma warning(pop) }; Index: src/libchcore/TSQLiteSerializerContainer.cpp =================================================================== diff -u -r4a7f28238afbf60b9e3f3daeffe590ff1638ec74 -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/libchcore/TSQLiteSerializerContainer.cpp (.../TSQLiteSerializerContainer.cpp) (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) +++ src/libchcore/TSQLiteSerializerContainer.cpp (.../TSQLiteSerializerContainer.cpp) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -18,45 +18,72 @@ // ============================================================================ #include "stdafx.h" #include "TSQLiteSerializerContainer.h" -#include "TSQLiteSerializerRow.h" +#include "TSQLiteSerializerRowWriter.h" +#include "ErrorCodes.h" +#include "TCoreException.h" +#include +#include "TSQLiteStatement.h" +#include "TSQLiteSerializerRowReader.h" BEGIN_CHCORE_NAMESPACE -TSQLiteSerializerContainer::TSQLiteSerializerContainer() : - m_spColumns(new TSQLiteColumnDefinition) +TSQLiteSerializerContainer::TSQLiteSerializerContainer(const TString& strName, const sqlite::TSQLiteDatabasePtr& spDB) : + m_spColumns(new TSQLiteColumnsDefinition), + m_strName(strName), + m_spDB(spDB) { } -TSQLiteSerializerContainer::TSQLiteSerializerContainer(size_t stParentID) : +TSQLiteSerializerContainer::TSQLiteSerializerContainer(const TString& strName, size_t stParentID, const sqlite::TSQLiteDatabasePtr& spDB) : m_stParentID(stParentID), - m_spColumns(new TSQLiteColumnDefinition) + m_spColumns(new TSQLiteColumnsDefinition), + m_strName(strName), + m_spDB(spDB) { } TSQLiteSerializerContainer::~TSQLiteSerializerContainer() { } -chcore::ISerializerRowPtr TSQLiteSerializerContainer::GetNewRow() +chcore::ISerializerRowWriterPtr TSQLiteSerializerContainer::AddRow(size_t stRowID) { - 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; + std::map::iterator iterInsert = m_mapRows.insert( + std::make_pair(stRowID, TSQLiteSerializerRowWriterPtr(new TSQLiteSerializerRowWriter(stRowID, m_spColumns, true))) + ).first; return (*iterInsert).second; } -ISerializerRowPtr TSQLiteSerializerContainer::GetRow(size_t stRowID) +ISerializerRowWriterPtr TSQLiteSerializerContainer::GetRow(size_t stRowID) { - std::map::iterator iterFnd = m_mapRows.find(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; + iterFnd = m_mapRows.insert(std::make_pair(stRowID, ISerializerRowWriterPtr(new TSQLiteSerializerRowWriter(stRowID, m_spColumns, false)))).first; return (*iterFnd).second; } +void TSQLiteSerializerContainer::DeleteRow(size_t stRowID) +{ + std::map::iterator iterFnd = m_mapRows.find(stRowID); + if(iterFnd != m_mapRows.end()) + { + m_mapRows.erase(iterFnd); + m_setDeleteItems.insert(stRowID); + } + else + THROW_CORE_EXCEPTION(eErr_SerializeStoreError); +} + +ISerializerRowReaderPtr TSQLiteSerializerContainer::GetRowReader() +{ + TSQLiteSerializerRowReaderPtr spRowReader(new TSQLiteSerializerRowReader(m_spDB, m_spColumns, m_strName)); + return spRowReader; +} + +chcore::IColumnsDefinitionPtr TSQLiteSerializerContainer::GetColumnsDefinition() const +{ + return m_spColumns; +} + END_CHCORE_NAMESPACE Index: src/libchcore/TSQLiteSerializerContainer.h =================================================================== diff -u -r4a7f28238afbf60b9e3f3daeffe590ff1638ec74 -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/libchcore/TSQLiteSerializerContainer.h (.../TSQLiteSerializerContainer.h) (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) +++ src/libchcore/TSQLiteSerializerContainer.h (.../TSQLiteSerializerContainer.h) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -20,30 +20,44 @@ #define __TSQLITESERIALIZERCONTAINER_H__ #include "libchcore.h" -#include "ISerializerRow.h" +#include "ISerializerRowWriter.h" +#include "ISerializerRowReader.h" #include "ISerializerContainer.h" #include #include #include "TSQLiteColumnDefinition.h" +#include "TSQLiteDatabase.h" BEGIN_CHCORE_NAMESPACE class LIBCHCORE_API TSQLiteSerializerContainer : public ISerializerContainer { public: - TSQLiteSerializerContainer(); - TSQLiteSerializerContainer(size_t stParentID); + TSQLiteSerializerContainer(const TString& strName, const sqlite::TSQLiteDatabasePtr& spDB); + TSQLiteSerializerContainer(const TString& strName, size_t stParentID, const sqlite::TSQLiteDatabasePtr& spDB); + virtual ~TSQLiteSerializerContainer(); - ISerializerRowPtr GetNewRow(); - ISerializerRowPtr GetRow(size_t stRowID); + virtual IColumnsDefinitionPtr GetColumnsDefinition() const; + virtual ISerializerRowWriterPtr AddRow(size_t stRowID); + virtual ISerializerRowWriterPtr GetRow(size_t stRowID); + virtual void DeleteRow(size_t stRowID); + + virtual ISerializerRowReaderPtr GetRowReader(); + private: #pragma warning(push) #pragma warning(disable: 4251) - std::map m_mapRows; boost::optional m_stParentID; + + std::map m_mapRows; TSQLiteColumnDefinitionPtr m_spColumns; + + std::set m_setDeleteItems; + + TString m_strName; + sqlite::TSQLiteDatabasePtr m_spDB; #pragma warning(pop) }; Index: src/libchcore/TSQLiteSerializerRowReader.cpp =================================================================== diff -u --- src/libchcore/TSQLiteSerializerRowReader.cpp (revision 0) +++ src/libchcore/TSQLiteSerializerRowReader.cpp (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -0,0 +1,155 @@ +// ============================================================================ +// 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 "TSQLiteSerializerRowReader.h" +#include +#include "TCoreException.h" +#include "ErrorCodes.h" +#include +#include "TSQLiteStatement.h" + +BEGIN_CHCORE_NAMESPACE + +TSQLiteSerializerRowReader::TSQLiteSerializerRowReader(const sqlite::TSQLiteDatabasePtr& spDatabase, const TSQLiteColumnDefinitionPtr& spColumns, const TString& strContainerName) : + m_spStatement(new sqlite::TSQLiteStatement(spDatabase)), + m_spColumns(spColumns), + m_bInitialized(false), + m_strContainerName(strContainerName) +{ + if(!m_spColumns || m_strContainerName.IsEmpty()) + THROW_CORE_EXCEPTION(eErr_InvalidArgument); +} + +TSQLiteSerializerRowReader::~TSQLiteSerializerRowReader() +{ +} + +bool TSQLiteSerializerRowReader::Next() +{ + if(m_spColumns->IsEmpty()) + THROW_CORE_EXCEPTION(eErr_SerializeLoadError); + + if(!m_bInitialized) + { + // generate query to retrieve data from db + TString strQuery; + strQuery = boost::str(boost::wformat(L"SELECT %1% FROM %2%") % (PCTSTR)m_spColumns->GetCommaSeparatedColumns() % (PCTSTR)m_strContainerName).c_str(); + + m_spStatement->Prepare(strQuery); + m_bInitialized = true; + } + + return m_spStatement->Step() == sqlite::TSQLiteStatement::eStep_HasRow; +} + +void TSQLiteSerializerRowReader::GetValue(const TString& strColName, bool& bValue) +{ + if(!m_bInitialized) + THROW_CORE_EXCEPTION(eErr_SerializeLoadError); + + bValue = m_spStatement->GetInt(GetColumnIndex(strColName)) != 0; +} + +void TSQLiteSerializerRowReader::GetValue(const TString& strColName, short& iValue) +{ + if(!m_bInitialized) + THROW_CORE_EXCEPTION(eErr_SerializeLoadError); + + iValue = boost::numeric_cast(m_spStatement->GetInt(GetColumnIndex(strColName))); +} + +void TSQLiteSerializerRowReader::GetValue(const TString& strColName, unsigned short& uiValue) +{ + if(!m_bInitialized) + THROW_CORE_EXCEPTION(eErr_SerializeLoadError); + + uiValue = boost::numeric_cast(m_spStatement->GetUInt(GetColumnIndex(strColName))); +} + +void TSQLiteSerializerRowReader::GetValue(const TString& strColName, int& iValue) +{ + if(!m_bInitialized) + THROW_CORE_EXCEPTION(eErr_SerializeLoadError); + + iValue = m_spStatement->GetInt(GetColumnIndex(strColName)); +} + +void TSQLiteSerializerRowReader::GetValue(const TString& strColName, unsigned int& uiValue) +{ + if(!m_bInitialized) + THROW_CORE_EXCEPTION(eErr_SerializeLoadError); + + uiValue = m_spStatement->GetUInt(GetColumnIndex(strColName)); +} + +void TSQLiteSerializerRowReader::GetValue(const TString& strColName, long long& llValue) +{ + if(!m_bInitialized) + THROW_CORE_EXCEPTION(eErr_SerializeLoadError); + + llValue = m_spStatement->GetInt64(GetColumnIndex(strColName)); +} + +void TSQLiteSerializerRowReader::GetValue(const TString& strColName, unsigned long long& ullValue) +{ + if(!m_bInitialized) + THROW_CORE_EXCEPTION(eErr_SerializeLoadError); + + ullValue = m_spStatement->GetUInt64(GetColumnIndex(strColName)); +} + +void TSQLiteSerializerRowReader::GetValue(const TString& strColName, double& dValue) +{ + if(!m_bInitialized) + THROW_CORE_EXCEPTION(eErr_SerializeLoadError); + + dValue = m_spStatement->GetDouble(GetColumnIndex(strColName)); +} + +void TSQLiteSerializerRowReader::GetValue(const TString& strColName, TString& strValue) +{ + if(!m_bInitialized) + THROW_CORE_EXCEPTION(eErr_SerializeLoadError); + + strValue = m_spStatement->GetText(GetColumnIndex(strColName)); +} + +void TSQLiteSerializerRowReader::GetValue(const TString& strColName, TSmartPath& pathValue) +{ + if(!m_bInitialized) + THROW_CORE_EXCEPTION(eErr_SerializeLoadError); + + pathValue = PathFromString(m_spStatement->GetText(GetColumnIndex(strColName))); +} + +int TSQLiteSerializerRowReader::GetColumnIndex(const TString& strColName) const +{ + if(!m_bInitialized) + THROW_CORE_EXCEPTION(eErr_SerializeLoadError); + + size_t stColumn = m_spColumns->GetColumnIndex(strColName); + return boost::numeric_cast(stColumn); +} + +IColumnsDefinitionPtr TSQLiteSerializerRowReader::GetColumnsDefinitions() const +{ + return m_spColumns; +} + +END_CHCORE_NAMESPACE Index: src/libchcore/TSQLiteSerializerRowReader.h =================================================================== diff -u --- src/libchcore/TSQLiteSerializerRowReader.h (revision 0) +++ src/libchcore/TSQLiteSerializerRowReader.h (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -0,0 +1,67 @@ +// ============================================================================ +// 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 __TSQLITESERIALIZERROWREADER_H__ +#define __TSQLITESERIALIZERROWREADER_H__ + +#include "libchcore.h" +#include "ISerializerRowReader.h" +#include "TSQLiteStatement.h" +#include "TSQLiteColumnDefinition.h" + +BEGIN_CHCORE_NAMESPACE + +class LIBCHCORE_API TSQLiteSerializerRowReader : public ISerializerRowReader +{ +public: + TSQLiteSerializerRowReader(const sqlite::TSQLiteDatabasePtr& spDatabase, const TSQLiteColumnDefinitionPtr& spColumns, const TString& strContainerName); + virtual ~TSQLiteSerializerRowReader(); + + virtual IColumnsDefinitionPtr GetColumnsDefinitions() const; + + virtual bool Next(); + + virtual void GetValue(const TString& strColName, bool& bValue); + virtual void GetValue(const TString& strColName, short& iValue); + virtual void GetValue(const TString& strColName, unsigned short& uiValue); + virtual void GetValue(const TString& strColName, int& iValue); + virtual void GetValue(const TString& strColName, unsigned int& uiValue); + virtual void GetValue(const TString& strColName, long long& llValue); + virtual void GetValue(const TString& strColName, unsigned long long& ullValue); + virtual void GetValue(const TString& strColName, double& dValue); + virtual void GetValue(const TString& strColName, TString& strValue); + virtual void GetValue(const TString& strColName, TSmartPath& pathValue); + +private: + int GetColumnIndex(const TString& strColName) const; + +private: +#pragma warning(push) +#pragma warning(disable: 4251) + bool m_bInitialized; + sqlite::TSQLiteStatementPtr m_spStatement; + TSQLiteColumnDefinitionPtr m_spColumns; + TString m_strContainerName; +#pragma warning(pop) +}; + +typedef boost::shared_ptr TSQLiteSerializerRowReaderPtr; + +END_CHCORE_NAMESPACE + +#endif Index: src/libchcore/TSQLiteSerializerRowWriter.cpp =================================================================== diff -u --- src/libchcore/TSQLiteSerializerRowWriter.cpp (revision 0) +++ src/libchcore/TSQLiteSerializerRowWriter.cpp (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -0,0 +1,60 @@ +// ============================================================================ +// 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 "TSQLiteSerializerRowWriter.h" +#include "TSQLiteSerializerContainer.h" + +BEGIN_CHCORE_NAMESPACE + +TSQLiteSerializerRowWriter::TSQLiteSerializerRowWriter(size_t stRowID, const TSQLiteColumnDefinitionPtr& spColumnDefinition, bool bAdded) : + m_stRowID(stRowID), + m_spColumns(spColumnDefinition), + m_bAdded(bAdded) +{ +} + +TSQLiteSerializerRowWriter::~TSQLiteSerializerRowWriter() +{ +} + +ISerializerRowWriter& TSQLiteSerializerRowWriter::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; +} + +ISerializerRowWriter& TSQLiteSerializerRowWriter::SetValue(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/TSQLiteSerializerRowWriter.h =================================================================== diff -u --- src/libchcore/TSQLiteSerializerRowWriter.h (revision 0) +++ src/libchcore/TSQLiteSerializerRowWriter.h (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -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 __TSQLITESERIALIZERROWWRITER_H__ +#define __TSQLITESERIALIZERROWWRITER_H__ + +#include "libchcore.h" +#include "ISerializerRowWriter.h" +#include "TSQLiteColumnDefinition.h" +#include "ISerializerContainer.h" +#include "TRowData.h" + +BEGIN_CHCORE_NAMESPACE + +class LIBCHCORE_API TSQLiteSerializerRowWriter : public ISerializerRowWriter +{ +public: + TSQLiteSerializerRowWriter(size_t stRowID, const TSQLiteColumnDefinitionPtr& spColumnDefinition, bool bAdded); + virtual ~TSQLiteSerializerRowWriter(); + + virtual ISerializerRowWriter& operator%(const TRowData& rData); + virtual ISerializerRowWriter& SetValue(const TRowData& rData); + +private: + size_t m_stRowID; + bool m_bAdded; +#pragma warning(push) +#pragma warning(disable: 4251) + TSQLiteColumnDefinitionPtr m_spColumns; + std::map m_mapValues; +#pragma warning(pop) +}; + +typedef boost::shared_ptr TSQLiteSerializerRowWriterPtr; + +END_CHCORE_NAMESPACE + +#endif Index: src/libchcore/TString.cpp =================================================================== diff -u -rd56d66c19fc54562eb0c8e54bc6acff1e7eb4ef8 -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/libchcore/TString.cpp (.../TString.cpp) (revision d56d66c19fc54562eb0c8e54bc6acff1e7eb4ef8) +++ src/libchcore/TString.cpp (.../TString.cpp) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -463,6 +463,31 @@ } } + +void TString::TrimRightSelf(const wchar_t* pszElements) +{ + if(!pszElements || pszElements[0] == L'\0') + return; + + size_t stLen = GetLength(); + if(stLen == 0) + return; + + EnsureWritable(stLen); + + const wchar_t* pszElementsEnd = pszElements + stLen; + while(stLen -- > 0) + { + if(std::find(pszElements, pszElementsEnd, m_pszStringData[stLen]) != pszElementsEnd) + { + m_pszStringData[stLen] = _T('\0'); + GetInternalStringData()->SetStringLength(stLen); + } + else + break; + } +} + bool TString::Delete(size_t stIndex, size_t stCount) { size_t stCurrentLength = GetLength(); Index: src/libchcore/TString.h =================================================================== diff -u -r9545b48aadb1592a5bf22ac5a227b1666d7710c6 -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/libchcore/TString.h (.../TString.h) (revision 9545b48aadb1592a5bf22ac5a227b1666d7710c6) +++ src/libchcore/TString.h (.../TString.h) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -164,6 +164,8 @@ void RightSelf(size_t tLen); ///< Makes this TString it's Right part void MidSelf(size_t tStart, size_t tLen = (size_t)-1); ///< Makes this TString it's middle part + void TrimRightSelf(const wchar_t* pszElements); + bool Delete(size_t stIndex, size_t stCount); void Split(const wchar_t* pszSeparators, TStringArray& rStrings) const; Index: src/libchcore/TTask.cpp =================================================================== diff -u -r1342b18babc7e88850e74f46cb473a737a68f28a -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/libchcore/TTask.cpp (.../TTask.cpp) (revision 1342b18babc7e88850e74f46cb473a737a68f28a) +++ src/libchcore/TTask.cpp (.../TTask.cpp) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -1,5 +1,5 @@ /*************************************************************************** -* Copyright (C) 2001-2010 by Jozef Starosczyk * +* Copyright (C) 2001-2014 by Jozef Starosczyk * * ixen@copyhandler.com * * * * This program is free software; you can redistribute it and/or modify * @@ -40,7 +40,7 @@ //////////////////////////////////////////////////////////////////////////// // TTask members -TTask::TTask(const ITaskSerializerPtr& spSerializer, IFeedbackHandler* piFeedbackHandler) : +TTask::TTask(const ISerializerPtr& spSerializer, IFeedbackHandler* piFeedbackHandler) : m_log(), m_piFeedbackHandler(piFeedbackHandler), m_arrSourcePathsInfo(m_vSourcePaths), @@ -52,7 +52,8 @@ m_tSubTasksArray(), m_spSerializer(spSerializer) { - BOOST_ASSERT(piFeedbackHandler); + if(!piFeedbackHandler || !spSerializer) + THROW_CORE_EXCEPTION(eErr_InvalidPointer); } TTask::~TTask() @@ -633,7 +634,7 @@ m_pathLog = pathLog; } -chcore::ITaskSerializerPtr TTask::GetSerializer() const +chcore::ISerializerPtr TTask::GetSerializer() const { return m_spSerializer; } Index: src/libchcore/TTask.h =================================================================== diff -u -r1342b18babc7e88850e74f46cb473a737a68f28a -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/libchcore/TTask.h (.../TTask.h) (revision 1342b18babc7e88850e74f46cb473a737a68f28a) +++ src/libchcore/TTask.h (.../TTask.h) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -34,6 +34,7 @@ #include "TSubTaskContext.h" #include "TTaskStatsSnapshot.h" #include "ITaskSerializer.h" +#include "ISerializer.h" BEGIN_CHCORE_NAMESPACE @@ -45,7 +46,7 @@ class LIBCHCORE_API TTask { private: - TTask(const ITaskSerializerPtr& spSerializer, IFeedbackHandler* piFeedbackHandler); + TTask(const ISerializerPtr& spSerializer, IFeedbackHandler* piFeedbackHandler); public: ~TTask(); @@ -123,12 +124,12 @@ static void OnCfgOptionChanged(const TStringSet& rsetChanges, void* pParam); - ITaskSerializerPtr GetSerializer() const; + ISerializerPtr GetSerializer() const; private: #pragma warning(push) #pragma warning(disable: 4251) - ITaskSerializerPtr m_spSerializer; + ISerializerPtr m_spSerializer; #pragma warning(pop) TString m_strTaskName; Index: src/libchcore/TTaskInfo.cpp =================================================================== diff -u -r1342b18babc7e88850e74f46cb473a737a68f28a -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/libchcore/TTaskInfo.cpp (.../TTaskInfo.cpp) (revision 1342b18babc7e88850e74f46cb473a737a68f28a) +++ src/libchcore/TTaskInfo.cpp (.../TTaskInfo.cpp) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -19,6 +19,9 @@ #include "stdafx.h" #include "TTaskInfo.h" #include "TCoreException.h" +#include "TRowData.h" +#include "ISerializerRowWriter.h" +#include "ISerializerRowReader.h" BEGIN_CHCORE_NAMESPACE @@ -106,7 +109,46 @@ return (m_iModificationType & ~eMod_Added) != eMod_None; } +void TTaskInfoEntry::Store(const ISerializerContainerPtr& spContainer) +{ + if(m_iModificationType == eMod_None) + return; + if(m_iModificationType & eMod_Added) + { + ISerializerRowWriterPtr spRow = spContainer->AddRow(m_tTaskID); + + *spRow % TRowData(_T("path"), m_pathSerializeLocation) + % TRowData(_T("task_order"), m_iOrder); + } + else + { + ISerializerRowWriterPtr spRow = spContainer->GetRow(m_tTaskID); + if(m_iModificationType & eMod_TaskPath) + *spRow % TRowData(_T("path"), m_pathSerializeLocation); + else if(m_iModificationType & eMod_Order) + *spRow % TRowData(_T("task_order"), m_iOrder); + } +} + +bool TTaskInfoEntry::Load(const ISerializerRowReaderPtr& spRowReader) +{ + IColumnsDefinitionPtr spColumns = spRowReader->GetColumnsDefinitions(); + if(spColumns->IsEmpty()) + *spColumns % _T("task_id") % _T("path") % _T("task_order"); + + bool bResult = spRowReader->Next(); + if(bResult) + { + spRowReader->GetValue(_T("task_id"), m_tTaskID); + spRowReader->GetValue(_T("path"), m_pathSerializeLocation); + spRowReader->GetValue(_T("task_order"), m_iOrder); + } + + return bResult; +} + +/////////////////////////////////////////////////////////////////////////// TTaskInfoContainer::TTaskInfoContainer() { } @@ -269,4 +311,31 @@ } } +void TTaskInfoContainer::Store(const ISerializerContainerPtr& spContainer) +{ + BOOST_FOREACH(taskid_t stObjectID, m_setRemovedTasks) + { + spContainer->DeleteRow(stObjectID); + } + + BOOST_FOREACH(TTaskInfoEntry& rEntry, m_vTaskInfos) + { + if(rEntry.GetModifications() != TTaskInfoEntry::eMod_None) + rEntry.Store(spContainer); + } + + ClearModifications(); +} + +void TTaskInfoContainer::Load(const ISerializerContainerPtr& spContainer) +{ + ISerializerRowReaderPtr spRowReader = spContainer->GetRowReader(); + + TTaskInfoEntry tEntry; + while(tEntry.Load(spRowReader)) + { + m_vTaskInfos.push_back(tEntry); + } +} + END_CHCORE_NAMESPACE Index: src/libchcore/TTaskInfo.h =================================================================== diff -u -r1342b18babc7e88850e74f46cb473a737a68f28a -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/libchcore/TTaskInfo.h (.../TTaskInfo.h) (revision 1342b18babc7e88850e74f46cb473a737a68f28a) +++ src/libchcore/TTaskInfo.h (.../TTaskInfo.h) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -24,6 +24,7 @@ #include #include "TPath.h" #include "TaskID.h" +#include "ISerializerContainer.h" BEGIN_CHCORE_NAMESPACE @@ -64,6 +65,9 @@ bool IsAdded() const; bool IsModified() const; + void Store(const ISerializerContainerPtr& spContainer); + bool Load(const ISerializerRowReaderPtr& spRowReader); + private: taskid_t m_tTaskID; TSmartPath m_pathSerializeLocation; @@ -97,6 +101,9 @@ taskid_t GetDeletedAt(size_t stIndex) const; // modifications management + void Store(const ISerializerContainerPtr& spContainer); + void Load(const ISerializerContainerPtr& spContainer); + void GetDiffAndResetModifications(TTaskInfoContainer& rDiff); void RestoreModifications(const TTaskInfoContainer& tDataDiff) throw(); void ClearModifications(); Index: src/libchcore/TTaskManager.cpp =================================================================== diff -u -r1342b18babc7e88850e74f46cb473a737a68f28a -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/libchcore/TTaskManager.cpp (.../TTaskManager.cpp) (revision 1342b18babc7e88850e74f46cb473a737a68f28a) +++ src/libchcore/TTaskManager.cpp (.../TTaskManager.cpp) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -30,7 +30,7 @@ //////////////////////////////////////////////////////////////////////////////// // TTaskManager members -TTaskManager::TTaskManager(const ITaskManagerSerializerPtr& spSerializer, IFeedbackHandlerFactory* piFeedbackHandlerFactory) : +TTaskManager::TTaskManager(const ISerializerPtr& spSerializer, IFeedbackHandlerFactory* piFeedbackHandlerFactory) : m_stNextTaskID(NoTaskID + 1), m_spSerializer(spSerializer), m_piFeedbackFactory(piFeedbackHandlerFactory) @@ -47,7 +47,7 @@ TTaskPtr TTaskManager::CreateTask(const TTaskDefinition& tTaskDefinition) { IFeedbackHandler* piHandler = CreateNewFeedbackHandler(); - ITaskSerializerPtr spSerializer = m_spSerializer->CreateNewTaskSerializer(tTaskDefinition.GetTaskName()); + ISerializerPtr spSerializer;// = m_spSerializer->CreateNewTaskSerializer(tTaskDefinition.GetTaskName()); TTaskPtr spTask(new TTask(spSerializer, piHandler)); spTask->SetLogPath(CreateTaskLogPath(tTaskDefinition.GetTaskName())); @@ -134,7 +134,7 @@ void TTaskManager::RemoveAllFinished() { - std::vector vTasksSerializersToRemove; + std::vector vTasksSerializersToRemove; // separate scope for locking { @@ -145,6 +145,8 @@ { TTaskInfoEntry& rEntry = m_tTasks.GetAt(stIndex); TTaskPtr spTask = rEntry.GetTask(); + if(!spTask) + THROW_CORE_EXCEPTION(eErr_InvalidPointer); // delete only when the thread is finished if((spTask->GetTaskState() == eTaskState_Finished || spTask->GetTaskState() == eTaskState_Cancelled)) @@ -159,10 +161,10 @@ } } - BOOST_FOREACH(ITaskSerializerPtr& spSerializer, vTasksSerializersToRemove) + BOOST_FOREACH(ISerializerPtr& spSerializer, vTasksSerializersToRemove) { // delete associated files - m_spSerializer->RemoveTaskSerializer(spSerializer); + DeleteFile(spSerializer->GetLocation().ToString()); } } @@ -179,6 +181,8 @@ { TTaskInfoEntry& rEntry = m_tTasks.GetAt(stIndex); TTaskPtr spTask = rEntry.GetTask(); + if(!spTask) + THROW_CORE_EXCEPTION(eErr_InvalidPointer); // delete only when the thread is finished if(spTask == spSelTask && (spTask->GetTaskState() == eTaskState_Finished || spTask->GetTaskState() == eTaskState_Cancelled)) @@ -223,6 +227,8 @@ { TTaskInfoEntry& rEntry = m_tTasks.GetAt(stIndex); TTaskPtr spTask = rEntry.GetTask(); + if(!spTask) + THROW_CORE_EXCEPTION(eErr_InvalidPointer); // turn on some thread - find something with wait state if(spTask->GetTaskState() == eTaskState_Waiting) @@ -242,6 +248,8 @@ { TTaskInfoEntry& rEntry = m_tTasks.GetAt(stIndex); TTaskPtr spTask = rEntry.GetTask(); + if(!spTask) + THROW_CORE_EXCEPTION(eErr_InvalidPointer); spTask->BeginProcessing(); } } @@ -253,6 +261,8 @@ { TTaskInfoEntry& rEntry = m_tTasks.GetAt(stIndex); TTaskPtr spTask = rEntry.GetTask(); + if(!spTask) + THROW_CORE_EXCEPTION(eErr_InvalidPointer); spTask->PauseProcessing(); } } @@ -264,6 +274,8 @@ { TTaskInfoEntry& rEntry = m_tTasks.GetAt(stIndex); TTaskPtr spTask = rEntry.GetTask(); + if(!spTask) + THROW_CORE_EXCEPTION(eErr_InvalidPointer); spTask->ResumeProcessing(); } } @@ -275,6 +287,8 @@ { TTaskInfoEntry& rEntry = m_tTasks.GetAt(stIndex); TTaskPtr spTask = rEntry.GetTask(); + if(!spTask) + THROW_CORE_EXCEPTION(eErr_InvalidPointer); spTask->RestartProcessing(); } } @@ -287,6 +301,8 @@ { TTaskInfoEntry& rEntry = m_tTasks.GetAt(stIndex); TTaskPtr spTask = rEntry.GetTask(); + if(!spTask) + THROW_CORE_EXCEPTION(eErr_InvalidPointer); if(spTask->RetryProcessing()) bChanged = true; } @@ -301,6 +317,8 @@ { TTaskInfoEntry& rEntry = m_tTasks.GetAt(stIndex); TTaskPtr spTask = rEntry.GetTask(); + if(!spTask) + THROW_CORE_EXCEPTION(eErr_InvalidPointer); spTask->CancelProcessing(); } } @@ -318,6 +336,8 @@ { TTaskInfoEntry& rEntry = m_tTasks.GetAt(stIndex); TTaskPtr spTask = rEntry.GetTask(); + if(!spTask) + THROW_CORE_EXCEPTION(eErr_InvalidPointer); ETaskCurrentState eState = spTask->GetTaskState(); bFlag = (eState == eTaskState_Finished || eState == eTaskState_Cancelled || eState == eTaskState_Paused || eState == eTaskState_Error); @@ -344,6 +364,9 @@ { const TTaskInfoEntry& rEntry = m_tTasks.GetAt(stIndex); TTaskPtr spTask = rEntry.GetTask(); + if(!spTask) + THROW_CORE_EXCEPTION(eErr_InvalidPointer); + TTaskStatsSnapshotPtr spStats(new TTaskStatsSnapshot); spTask->GetStatsSnapshot(spStats); spStats->SetTaskID(rEntry.GetTaskID()); @@ -369,6 +392,9 @@ { const TTaskInfoEntry& rEntry = m_tTasks.GetAt(stIndex); TTaskPtr spTask = rEntry.GetTask(); + if(!spTask) + THROW_CORE_EXCEPTION(eErr_InvalidPointer); + if(spTask->IsRunning() && spTask->GetTaskState() == eTaskState_Processing) ++stRunningTasks; } @@ -383,6 +409,8 @@ { TTaskInfoEntry& rEntry = m_tTasks.GetAt(stIndex); TTaskPtr spTask = rEntry.GetTask(); + if(!spTask) + THROW_CORE_EXCEPTION(eErr_InvalidPointer); spTask->RequestStopThread(); } @@ -391,6 +419,8 @@ { TTaskInfoEntry& rEntry = m_tTasks.GetAt(stIndex); TTaskPtr spTask = rEntry.GetTask(); + if(!spTask) + THROW_CORE_EXCEPTION(eErr_InvalidPointer); spTask->KillThread(); } } @@ -408,34 +438,15 @@ void TTaskManager::Store() { + ISerializerContainerPtr spContainer = m_spSerializer->GetContainer(_T("tasks")); + // store this container information - TTaskInfoContainer tDataDiff; { boost::shared_lock lock(m_lock); - m_tTasks.GetDiffAndResetModifications(tDataDiff); + m_tTasks.Store(spContainer); } - try - { - m_spSerializer->Store(tDataDiff); - } - catch(const std::exception&) - { - boost::unique_lock lock(m_lock); - m_tTasks.RestoreModifications(tDataDiff); - - throw; - } - - // trigger storing tasks - boost::shared_lock lock(m_lock); - for(size_t stIndex = 0; stIndex < m_tTasks.GetCount(); ++stIndex) - { - TTaskInfoEntry& rEntry = m_tTasks.GetAt(stIndex); - TTaskPtr spTask = rEntry.GetTask(); - - spTask->Store(); - } + m_spSerializer->Flush(); } void TTaskManager::Load() @@ -445,13 +456,14 @@ if(!m_tTasks.IsEmpty()) THROW_CORE_EXCEPTION(eErr_InternalProblem); - m_spSerializer->Load(m_tTasks); + ISerializerContainerPtr spContainer = m_spSerializer->GetContainer(_T("tasks")); + m_tTasks.Load(spContainer); // clear all modifications of freshly loaded tasks (in case serializer does // not reset the modification state) m_tTasks.ClearModifications(); - // load tasks +/* for(size_t stIndex = 0; stIndex < m_tTasks.GetCount(); ++stIndex) { TTaskInfoEntry& rEntry = m_tTasks.GetAt(stIndex); @@ -467,6 +479,7 @@ rEntry.SetTask(spTask); } } +*/ } TSmartPath TTaskManager::CreateTaskLogPath(const TString& strTaskUuid) const { Index: src/libchcore/TTaskManager.h =================================================================== diff -u -r1342b18babc7e88850e74f46cb473a737a68f28a -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/libchcore/TTaskManager.h (.../TTaskManager.h) (revision 1342b18babc7e88850e74f46cb473a737a68f28a) +++ src/libchcore/TTaskManager.h (.../TTaskManager.h) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -25,6 +25,7 @@ #include "TTaskManagerStatsSnapshot.h" #include "TTaskInfo.h" #include "ITaskManagerSerializer.h" +#include "ISerializer.h" BEGIN_CHCORE_NAMESPACE @@ -37,7 +38,7 @@ class LIBCHCORE_API TTaskManager { public: - TTaskManager(const ITaskManagerSerializerPtr& spSerializer, IFeedbackHandlerFactory* piFeedbackHandlerFactory); + TTaskManager(const ISerializerPtr& spSerializer, IFeedbackHandlerFactory* piFeedbackHandlerFactory); ~TTaskManager(); void Store(); @@ -94,7 +95,7 @@ IFeedbackHandlerFactory* m_piFeedbackFactory; #pragma warning(push) #pragma warning(disable: 4251) - ITaskManagerSerializerPtr m_spSerializer; + ISerializerPtr m_spSerializer; #pragma warning(pop) }; Index: src/libchcore/TTaskManagerSchema.cpp =================================================================== diff -u --- src/libchcore/TTaskManagerSchema.cpp (revision 0) +++ src/libchcore/TTaskManagerSchema.cpp (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -0,0 +1,58 @@ +// ============================================================================ +// 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 "TTaskManagerSchema.h" +#include "TSQLiteTransaction.h" +#include "TSerializerVersion.h" +#include "TSQLiteStatement.h" + +BEGIN_CHCORE_NAMESPACE + +using namespace sqlite; + +TTaskManagerSchema::TTaskManagerSchema() +{ +} + +TTaskManagerSchema::~TTaskManagerSchema() +{ +} + +void TTaskManagerSchema::Setup(const sqlite::TSQLiteDatabasePtr& spDatabase) +{ + TSQLiteTransaction tTransaction(spDatabase); + + // check version of the database + TSerializerVersion tVersion(spDatabase); + + // if version is 0, then this is the fresh database with (almost) no tables inside + if(tVersion.GetVersion() == 0) + { + TSQLiteStatement tStatement(spDatabase); + tStatement.Prepare(_T("CREATE TABLE tasks(task_id BIGINT UNIQUE, task_order INT, path VARCHAR(32768))")); + tStatement.Step(); + + // and finally set the database version to current one + tVersion.SetVersion(1); + } + + tTransaction.Commit(); +} + +END_CHCORE_NAMESPACE Index: src/libchcore/TTaskManagerSchema.h =================================================================== diff -u --- src/libchcore/TTaskManagerSchema.h (revision 0) +++ src/libchcore/TTaskManagerSchema.h (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -0,0 +1,41 @@ +// ============================================================================ +// 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 __TTASKMANAGERSCHEMA_H__ +#define __TTASKMANAGERSCHEMA_H__ + +#include "libchcore.h" +#include "TSQLiteDatabase.h" +#include "ISQLiteSerializerSchema.h" + +BEGIN_CHCORE_NAMESPACE + +class LIBCHCORE_API TTaskManagerSchema : public ISQLiteSerializerSchema +{ +public: + TTaskManagerSchema(); + virtual ~TTaskManagerSchema(); + + virtual void Setup(const sqlite::TSQLiteDatabasePtr& spDatabase); +}; + +typedef boost::shared_ptr TTaskManagerSchemaPtr; + +END_CHCORE_NAMESPACE + +#endif Fisheye: Tag 9479911a096555a7504c5c8a8eaee83ecb63440c refers to a dead (removed) revision in file `src/libchcore/TTaskManagerSerializer.cpp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 9479911a096555a7504c5c8a8eaee83ecb63440c refers to a dead (removed) revision in file `src/libchcore/TTaskManagerSerializer.h'. Fisheye: No comparison available. Pass `N' to diff? Index: src/libchcore/Tests/TestsTString.cpp =================================================================== diff -u -rd56d66c19fc54562eb0c8e54bc6acff1e7eb4ef8 -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/libchcore/Tests/TestsTString.cpp (.../TestsTString.cpp) (revision d56d66c19fc54562eb0c8e54bc6acff1e7eb4ef8) +++ src/libchcore/Tests/TestsTString.cpp (.../TestsTString.cpp) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -607,3 +607,11 @@ EXPECT_NO_THROW(strValue = _T("")); EXPECT_EQ(strValue, _T("")); } + +TEST(TStringTests, TrimRightSelf) +{ + TString strValue(_T("Some string")); + + strValue.TrimRightSelf(L"gn"); + EXPECT_EQ(strValue, L"Some stri"); +} Index: src/libchcore/libchcore.vc90.vcproj =================================================================== diff -u -r4a7f28238afbf60b9e3f3daeffe590ff1638ec74 -r9479911a096555a7504c5c8a8eaee83ecb63440c --- src/libchcore/libchcore.vc90.vcproj (.../libchcore.vc90.vcproj) (revision 4a7f28238afbf60b9e3f3daeffe590ff1638ec74) +++ src/libchcore/libchcore.vc90.vcproj (.../libchcore.vc90.vcproj) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) @@ -1276,6 +1276,14 @@ Name="Serialization" > + + + + @@ -1292,14 +1300,22 @@ > + + + + @@ -1359,26 +1375,42 @@ > + + + + + + + +