[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a
Maximiliano Curia
maxy at moszumanska.debian.org
Thu Jul 13 17:41:08 UTC 2017
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=18f1cc9
The following commit has been merged in the master branch:
commit 18f1cc97b736a0d67280b65f323fc1a98bd7cfb3
Author: Andreas Huggel <ahuggel at gmx.net>
Date: Mon Jan 25 15:00:54 2010 +0000
More W/Error changes to better support w/what().
---
src/error.cpp | 79 ++++++++++++++++++++++++++++++++++++++++++-----------------
src/error.hpp | 72 ++++++++++++++++++-----------------------------------
2 files changed, 81 insertions(+), 70 deletions(-)
diff --git a/src/error.cpp b/src/error.cpp
index 6914608..4017df3 100644
--- a/src/error.cpp
+++ b/src/error.cpp
@@ -115,34 +115,69 @@ namespace Exiv2 {
{
}
- //! Specialization for Error
template<>
- const char* BasicError<char>::what() const throw()
+ void BasicError<char>::setMsg()
{
- return msg_.c_str();
+ std::string msg = _(errMsg(code_));
+ std::string::size_type pos;
+ pos = msg.find("%0");
+ if (pos != std::string::npos) {
+ msg.replace(pos, 2, toString(code_));
+ }
+ if (count_ > 0) {
+ pos = msg.find("%1");
+ if (pos != std::string::npos) {
+ msg.replace(pos, 2, arg1_);
+ }
+ }
+ if (count_ > 1) {
+ pos = msg.find("%2");
+ if (pos != std::string::npos) {
+ msg.replace(pos, 2, arg2_);
+ }
+ }
+ if (count_ > 2) {
+ pos = msg.find("%3");
+ if (pos != std::string::npos) {
+ msg.replace(pos, 2, arg3_);
+ }
+ }
+ msg_ = msg;
+#ifdef EXV_UNICODE_PATH
+ wmsg_ = s2ws(msg);
+#endif
}
- //! Specialization for WError
template<>
- const char* BasicError<wchar_t>::what() const throw()
+ void BasicError<wchar_t>::setMsg()
{
- // Todo: Return something more useful
- return 0;
- }
-
- //! Specialization for Error
- template<>
- const wchar_t* BasicError<char>::wwhat() const throw()
- {
- // Todo: Return something more useful
- return 0;
- }
-
- //! Specialization for Error
- template<>
- const wchar_t* BasicError<wchar_t>::wwhat() const throw()
- {
- return msg_.c_str();
+ std::string s = _(errMsg(code_));
+ std::wstring wmsg(s.begin(), s.end());
+ std::wstring::size_type pos;
+ pos = wmsg.find(L"%0");
+ if (pos != std::wstring::npos) {
+ wmsg.replace(pos, 2, toBasicString<wchar_t>(code_));
+ }
+ if (count_ > 0) {
+ pos = wmsg.find(L"%1");
+ if (pos != std::wstring::npos) {
+ wmsg.replace(pos, 2, arg1_);
+ }
+ }
+ if (count_ > 1) {
+ pos = wmsg.find(L"%2");
+ if (pos != std::wstring::npos) {
+ wmsg.replace(pos, 2, arg2_);
+ }
+ }
+ if (count_ > 2) {
+ pos = wmsg.find(L"%3");
+ if (pos != std::wstring::npos) {
+ wmsg.replace(pos, 2, arg3_);
+ }
+ }
+ wmsg_ = wmsg;
+// msg_ = ws2s(wmsg);
}
const char* errMsg(int code)
diff --git a/src/error.hpp b/src/error.hpp
index 8cf6a8b..ccd992a 100644
--- a/src/error.hpp
+++ b/src/error.hpp
@@ -120,18 +120,18 @@ namespace Exiv2 {
@brief Return the error message as a C-string. The pointer returned by what()
is valid only as long as the BasicError object exists.
*/
- EXIV2API virtual const char* what() const throw();
+ EXV_DLLLOCAL virtual const char* what() const throw();
/*!
@brief Return the error message as a wchar_t-string. The pointer returned by
wwhat() is valid only as long as the BasicError object exists.
*/
- EXIV2API virtual const wchar_t* wwhat() const throw();
+ EXV_DLLLOCAL virtual const wchar_t* wwhat() const throw();
//@}
private:
//! @name Manipulators
//@{
- EXV_DLLLOCAL void setMsg();
+ EXIV2API void setMsg();
//@}
// DATA
@@ -140,7 +140,8 @@ namespace Exiv2 {
std::basic_string<charT> arg1_; //!< First argument
std::basic_string<charT> arg2_; //!< Second argument
std::basic_string<charT> arg3_; //!< Third argument
- std::basic_string<charT> msg_; //!< Complete error message
+ std::string msg_; //!< Complete error message
+ std::wstring wmsg_; //!< Complete error message as a wide string
}; // class BasicError
@@ -160,17 +161,6 @@ namespace Exiv2 {
setMsg();
}
- template<typename charT>
- BasicError<charT>::~BasicError() throw()
- {
- }
-
- template<typename charT>
- int BasicError<charT>::code() const throw()
- {
- return code_;
- }
-
template<typename charT> template<typename A>
BasicError<charT>::BasicError(int code, const A& arg1)
: code_(code), count_(1), arg1_(toBasicString<charT>(arg1))
@@ -198,40 +188,26 @@ namespace Exiv2 {
}
template<typename charT>
- void BasicError<charT>::setMsg()
+ BasicError<charT>::~BasicError() throw()
+ {
+ }
+
+ template<typename charT>
+ int BasicError<charT>::code() const throw()
+ {
+ return code_;
+ }
+
+ template<typename charT>
+ const char* BasicError<charT>::what() const throw()
+ {
+ return msg_.c_str();
+ }
+
+ template<typename charT>
+ const wchar_t* BasicError<charT>::wwhat() const throw()
{
- std::string s(exvGettext(errMsg(code_)));
- msg_.assign(s.begin(), s.end());
- std::string ph("%0");
- std::basic_string<charT> tph(ph.begin(), ph.end());
- size_t pos = msg_.find(tph);
- if (pos != std::basic_string<charT>::npos) {
- msg_.replace(pos, 2, toBasicString<charT>(code_));
- }
- if (count_ > 0) {
- ph = "%1";
- tph.assign(ph.begin(), ph.end());
- pos = msg_.find(tph);
- if (pos != std::basic_string<charT>::npos) {
- msg_.replace(pos, 2, arg1_);
- }
- }
- if (count_ > 1) {
- ph = "%2";
- tph.assign(ph.begin(), ph.end());
- pos = msg_.find(tph);
- if (pos != std::basic_string<charT>::npos) {
- msg_.replace(pos, 2, arg2_);
- }
- }
- if (count_ > 2) {
- ph = "%3";
- tph.assign(ph.begin(), ph.end());
- pos = msg_.find(tph);
- if (pos != std::basic_string<charT>::npos) {
- msg_.replace(pos, 2, arg3_);
- }
- }
+ return wmsg_.c_str();
}
#ifdef _MSC_VER
--
exiv2 packaging
More information about the pkg-kde-commits
mailing list