Index: src/libchcore/TCoreException.cpp =================================================================== diff -u --- src/libchcore/TCoreException.cpp (revision 0) +++ src/libchcore/TCoreException.cpp (revision 39db7f4bffdd185122d8dab0772bd6fc49a0b675) @@ -0,0 +1,58 @@ +/*************************************************************************** +* Copyright (C) 2001-2008 by J�zef 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 "TCoreException.h" + +// ============================================================================ +/// chcore::TCoreException::TCoreException +/// @date 2009/11/30 +/// +/// @brief Constructs the core exception object. +/// @param[in] eErrorCode - error code +/// @param[in] pszInternalError - internal error message +// ============================================================================ +BEGIN_CHCORE_NAMESPACE + +TCoreException::TCoreException(EGeneralErrors eErrorCode, const tchar_t* pszInternalError) : + m_eErrorCode(eErrorCode), + m_strInternalMessage(pszInternalError ? pszInternalError : _t("")) +{ +} + +// ============================================================================ +/// chcore::TCoreException::TCoreException +/// @date 2009/11/30 +/// +/// @brief Constructs core exception object with additional data. +/// @param[in] eErrorCode - error code +/// @param[in] pszInternalError - error description +/// @param[in] pszFile - source file name +/// @param[in] stLineNumber - source line number +/// @param[in] pszFunction - function name in which the problem occured. +// ============================================================================ +TCoreException::TCoreException(EGeneralErrors eErrorCode, const tchar_t* pszInternalError, const tchar_t* pszFile, size_t stLineNumber, const tchar_t* pszFunction) : + m_eErrorCode(eErrorCode), + m_strInternalMessage(pszInternalError ? pszInternalError : _t("")), + m_strFile(pszFile ? pszFile : _t("")), + m_strLineNumber(stLineNumber), + m_strFunction(pszFunction ? pszFunction : _t("")) +{ +} + +END_CHCORE_NAMESPACE Index: src/libchcore/TCoreException.h =================================================================== diff -u --- src/libchcore/TCoreException.h (revision 0) +++ src/libchcore/TCoreException.h (revision 39db7f4bffdd185122d8dab0772bd6fc49a0b675) @@ -0,0 +1,63 @@ +/*************************************************************************** +* Copyright (C) 2001-2008 by J�zef 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 __TEXCEPTION_H__ +#define __TEXCEPTION_H__ + +#include "libchcore.h" + +BEGIN_CHCORE_NAMESPACE + +// throws core exception object +#define THROW_CORE_EXCEPTION(error_code)\ + throw TCoreException(error_code, _t(""), __FILEW__, __LINE__, __FUNCTIONW__) +#define THROW_CORE_EXCEPTION_STR(error_code, error_string)\ + throw TCoreException(error_code, error_string, __FILEW__, __LINE__, __FUNCTIONW__) + +class LIBCHCORE_API TCoreException +{ +public: + TCoreException(EGeneralErrors eErrorCode, const tchar_t* pszInternalError); + TCoreException(EGeneralErrors eErrorCode, const tchar_t* pszInternalError, const tchar_t* pszFile, size_t stLineNumber, const tchar_t* pszFunction); + + // error information + EGeneralErrors GetErrorCode() const { return m_eErrorCode; } + tstring_t GetInternalErrorString() const { return m_strInternalMessage; } + + // location info + tstring_t GetSourceFile() const { return m_strFile; } + size_t GetSourceLineNumber() const { return m_strLineNumber; } + tstring_t GetFunctionName() const { return m_strFunction; } + +private: + TCoreException() {} + +protected: + // what happened? + tstring_t m_strInternalMessage; + EGeneralErrors m_eErrorCode; + + // where it happened? + tstring_t m_strFile; + size_t m_strLineNumber; + tstring_t m_strFunction; +}; + +END_CHCORE_NAMESPACE + +#endif Index: src/libchcore/TPath.cpp =================================================================== diff -u -r920ccbb7d5163da9980901b4c6fa9ac69b85ad6d -r39db7f4bffdd185122d8dab0772bd6fc49a0b675 --- src/libchcore/TPath.cpp (.../TPath.cpp) (revision 920ccbb7d5163da9980901b4c6fa9ac69b85ad6d) +++ src/libchcore/TPath.cpp (.../TPath.cpp) (revision 39db7f4bffdd185122d8dab0772bd6fc49a0b675) @@ -20,15 +20,17 @@ #include "TPath.h" #include +BEGIN_CHCORE_NAMESPACE + // ============================================================================ /// TPath::TPath /// @date 2009/11/29 /// /// @brief Constructs the TPath object. // ============================================================================ TPath::TPath() : - m_lRefCount(1), - m_strPath() + m_strPath(), + m_lRefCount(1) { } @@ -383,3 +385,153 @@ else return boost::istarts_with(m_pPath->m_strPath, rPath.m_pPath->m_strPath); } + +// ============================================================================ +/// TPathContainer::TPathContainer +/// @date 2009/11/30 +/// +/// @brief Constructs an empty path container object. +// ============================================================================ +TPathContainer::TPathContainer() : + m_vPaths() +{ +} + +// ============================================================================ +/// TPathContainer::TPathContainer +/// @date 2009/11/30 +/// +/// @brief Constructs the path container object from another path container. +/// @param[in] rSrcContainer - path container to copy paths from. +// ============================================================================ +TPathContainer::TPathContainer(const TPathContainer& rSrcContainer) : + m_vPaths(rSrcContainer.m_vPaths) +{ +} + +// ============================================================================ +/// TPathContainer::~TPathContainer +/// @date 2009/11/30 +/// +/// @brief Destructs this path container object. +// ============================================================================ +TPathContainer::~TPathContainer() +{ + +} + +// ============================================================================ +/// TPathContainer::operator= +/// @date 2009/11/30 +/// +/// @brief Assigns another path container object to this one. +/// @param[in] rSrcContainer - container with paths to copy from. +/// @return Reference to this object. +// ============================================================================ +TPathContainer& TPathContainer::operator=(const TPathContainer& rSrcContainer) +{ + if(this != &rSrcContainer) + m_vPaths = rSrcContainer.m_vPaths; + + return *this; +} + +// ============================================================================ +/// TPathContainer::Add +/// @date 2009/11/30 +/// +/// @brief Adds a path to the end of list. +/// @param[in] spPath - path to be added. +// ============================================================================ +void TPathContainer::Add(const TSmartPath& spPath) +{ + m_vPaths.push_back(spPath); +} + +// ============================================================================ +/// TPathContainer::GetAt +/// @date 2009/11/30 +/// +/// @brief Retrieves path at specified index. +/// @param[in] stIndex - index at which to retrieve item. +/// @return Reference to the path object. +// ============================================================================ +const TSmartPath& TPathContainer::GetAt(size_t stIndex) const +{ + if(stIndex > m_vPaths.size()) + THROW_CORE_EXCEPTION(eBoundsExceeded); + + return m_vPaths.at(stIndex); +} + +// ============================================================================ +/// TPathContainer::GetAt +/// @date 2009/11/30 +/// +/// @brief Retrieves path at specified index. +/// @param[in] stIndex - index at which to retrieve item. +/// @return Reference to the path object. +// ============================================================================ +TSmartPath& TPathContainer::GetAt(size_t stIndex) +{ + if(stIndex > m_vPaths.size()) + THROW_CORE_EXCEPTION(eBoundsExceeded); + + return m_vPaths.at(stIndex); +} + +// ============================================================================ +/// chcore::TPathContainer::SetAt +/// @date 2009/11/30 +/// +/// @brief Sets a path at a specified index. +/// @param[in] stIndex - index at which to set the path. +/// @param[in] spPath - path to be set. +// ============================================================================ +void TPathContainer::SetAt(size_t stIndex, const TSmartPath& spPath) +{ + if(stIndex > m_vPaths.size()) + THROW_CORE_EXCEPTION(eBoundsExceeded); + + m_vPaths[stIndex] = spPath; +} + +// ============================================================================ +/// chcore::TPathContainer::DeleteAt +/// @date 2009/11/30 +/// +/// @brief Removes a path from container at specified index. +/// @param[in] stIndex - index at which to delete. +// ============================================================================ +void TPathContainer::DeleteAt(size_t stIndex) +{ + if(stIndex > m_vPaths.size()) + THROW_CORE_EXCEPTION(eBoundsExceeded); + + m_vPaths.erase(m_vPaths.begin() + stIndex); +} + +// ============================================================================ +/// chcore::TPathContainer::Clear +/// @date 2009/11/30 +/// +/// @brief Removes all paths from this container. +// ============================================================================ +void TPathContainer::Clear() +{ + m_vPaths.clear(); +} + +// ============================================================================ +/// chcore::TPathContainer::GetCount +/// @date 2009/11/30 +/// +/// @brief Retrieves count of elements in the container. +/// @return Count of elements. +// ============================================================================ +size_t TPathContainer::GetCount() const +{ + return m_vPaths.size(); +} + +END_CHCORE_NAMESPACE Index: src/libchcore/TPath.h =================================================================== diff -u -r920ccbb7d5163da9980901b4c6fa9ac69b85ad6d -r39db7f4bffdd185122d8dab0772bd6fc49a0b675 --- src/libchcore/TPath.h (.../TPath.h) (revision 920ccbb7d5163da9980901b4c6fa9ac69b85ad6d) +++ src/libchcore/TPath.h (.../TPath.h) (revision 39db7f4bffdd185122d8dab0772bd6fc49a0b675) @@ -21,6 +21,8 @@ #include "libchcore.h" +BEGIN_CHCORE_NAMESPACE + class LIBCHCORE_API TPath { public: @@ -74,4 +76,34 @@ TPath* m_pPath; }; +class LIBCHCORE_API TPathContainer +{ +public: + TPathContainer(); + TPathContainer(const TPathContainer& rSrcContainer); + ~TPathContainer(); + + TPathContainer& operator=(const TPathContainer& rSrcContainer); + + void Add(const TSmartPath& spPath); + + const TSmartPath& GetAt(size_t stIndex) const; + TSmartPath& GetAt(size_t stIndex); + + void SetAt(size_t stIndex, const TSmartPath& spPath); + + void DeleteAt(size_t stIndex); + void Clear(); + + size_t GetCount() const; + +private: +#pragma warning(push) +#pragma warning(disable: 4251) + std::vector m_vPaths; +#pragma warning(pop) +}; + +END_CHCORE_NAMESPACE + #endif Index: src/libchcore/libchcore.vc90.vcproj =================================================================== diff -u -r920ccbb7d5163da9980901b4c6fa9ac69b85ad6d -r39db7f4bffdd185122d8dab0772bd6fc49a0b675 --- src/libchcore/libchcore.vc90.vcproj (.../libchcore.vc90.vcproj) (revision 920ccbb7d5163da9980901b4c6fa9ac69b85ad6d) +++ src/libchcore/libchcore.vc90.vcproj (.../libchcore.vc90.vcproj) (revision 39db7f4bffdd185122d8dab0772bd6fc49a0b675) @@ -330,22 +330,6 @@ RelativePath=".\FeedbackHandlerBase.h" > - - - - - - - - @@ -437,7 +421,39 @@ RelativePath=".\stdafx.h" > + + + + + + + + + + + + + + + + Index: src/libchcore/stdafx.h =================================================================== diff -u -r920ccbb7d5163da9980901b4c6fa9ac69b85ad6d -r39db7f4bffdd185122d8dab0772bd6fc49a0b675 --- src/libchcore/stdafx.h (.../stdafx.h) (revision 920ccbb7d5163da9980901b4c6fa9ac69b85ad6d) +++ src/libchcore/stdafx.h (.../stdafx.h) (revision 39db7f4bffdd185122d8dab0772bd6fc49a0b675) @@ -12,4 +12,9 @@ #include #include +#include + #include "../libicpf/gen_types.h" + +#include "ErrorCodes.h" +#include "TCoreException.h"