diff --git a/ChangeLog b/ChangeLog index 0baf8f9a..749d0efc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,8 @@ VERSION 0.6.4cvs as defined by RFC-3798 and RFC-1892. This is a very first implementation, API is subject to changes... + * Some fixes for Visual C++/Windows. + 2005-03-24 Vincent Richard * Added 'HACKING' file. diff --git a/src/propertySet.cpp b/src/propertySet.cpp index 17117138..67f923ef 100644 --- a/src/propertySet.cpp +++ b/src/propertySet.cpp @@ -285,6 +285,8 @@ void propertySet::property::setValue(const string& value) } +#ifndef VMIME_INLINE_TEMPLATE_SPECIALIZATION + template <> void propertySet::property::setValue(const string& value) { @@ -322,5 +324,7 @@ const bool propertySet::property::getValue() const } } +#endif // VMIME_INLINE_TEMPLATE_SPECIALIZATION + } // vmime diff --git a/src/typeAdapter.cpp b/src/typeAdapter.cpp index 327d5c37..b65e6bd4 100644 --- a/src/typeAdapter.cpp +++ b/src/typeAdapter.cpp @@ -25,7 +25,7 @@ namespace vmime { -#if !defined(__GNUC__) || ((__GNUC__ >= 3) && (__GNUC_MINOR__ >= 3)) +#if (!defined(__GNUC__) || ((__GNUC__ >= 3) && (__GNUC_MINOR__ >= 3))) && !defined(_MSC_VER) template <> void typeAdapter ::parse(const string& buffer, const string::size_type position, @@ -39,7 +39,7 @@ void typeAdapter ::parse(const string& buffer, const string::size_type p *newPosition = end; } -#endif // !defined(__GNUC__) || ((__GNUC__ >= 3) && (__GNUC_MINOR__ >= 3)) +#endif // (!defined(__GNUC__) || ((__GNUC__ >= 3) && (__GNUC_MINOR__ >= 3))) && !defined(_MSC_VER) } // vmime diff --git a/vmime/constants.hpp b/vmime/constants.hpp index bbb11a9a..7a3482f1 100644 --- a/vmime/constants.hpp +++ b/vmime/constants.hpp @@ -26,6 +26,13 @@ #include "vmime/types.hpp" +// Remove Windows defines of ERROR and WARNING +#ifdef WIN32 + #undef ERROR + #undef WARNING +#endif + + namespace vmime { /** Constants for media types. */ diff --git a/vmime/propertySet.hpp b/vmime/propertySet.hpp index 7ca37dde..1a05c632 100644 --- a/vmime/propertySet.hpp +++ b/vmime/propertySet.hpp @@ -75,7 +75,13 @@ public: * * @param value new value for property */ - template void setValue(const TYPE& value); + template void setValue(const TYPE& value) + { + std::ostringstream oss; + oss << value; + + m_value = oss.str(); + } /** Get the value of the property as a generic type. * @@ -84,7 +90,57 @@ public: * converted using std::istringstream) * @return current value of the property */ - template const TYPE getValue() const; + template const TYPE getValue() const + { + TYPE val = TYPE(); + + std::istringstream iss(m_value); + iss >> val; + + if (iss.fail()) + throw exceptions::invalid_property_type(); + + return (val); + } + + +#ifdef VMIME_INLINE_TEMPLATE_SPECIALIZATION + + template <> + void propertySet::property::setValue(const string& value) + { + m_value = value; + } + + template <> + void propertySet::property::setValue(const bool& value) + { + m_value = value ? "true" : "false"; + } + + template <> + const string propertySet::property::getValue() const + { + return (m_value); + } + + template <> + const bool propertySet::property::getValue() const + { + if (utility::stringUtils::toLower(m_value) == "true") + return true; + else + { + int val = 0; + + std::istringstream iss(m_value); + iss >> val; + + return (!iss.fail() && val != 0); + } + } + +#endif // VMIME_INLINE_TEMPLATE_SPECIALIZATION private: @@ -300,31 +356,7 @@ public: }; - -template -void propertySet::property::setValue(const TYPE& value) -{ - std::ostringstream oss; - oss << value; - - m_value = oss.str(); -} - - -template -const TYPE propertySet::property::getValue() const -{ - TYPE val = TYPE(); - - std::istringstream iss(m_value); - iss >> val; - - if (iss.fail()) - throw exceptions::invalid_property_type(); - - return (val); -} - +#ifndef VMIME_INLINE_TEMPLATE_SPECIALIZATION template <> void propertySet::property::setValue(const string& value); template <> void propertySet::property::setValue(const bool& value); @@ -332,6 +364,8 @@ template <> void propertySet::property::setValue(const bool& value); template <> const string propertySet::property::getValue() const; template <> const bool propertySet::property::getValue() const; +#endif // VMIME_INLINE_TEMPLATE_SPECIALIZATION + } // vmime diff --git a/vmime/typeAdapter.hpp b/vmime/typeAdapter.hpp index b1229f35..9565b567 100644 --- a/vmime/typeAdapter.hpp +++ b/vmime/typeAdapter.hpp @@ -123,7 +123,7 @@ private: }; -#if defined(__GNUC__) && (__GNUC__ >= 3) && (__GNUC_MINOR__ <= 2) +#if (defined(__GNUC__) && (__GNUC__ >= 3) && (__GNUC_MINOR__ <= 2)) || defined(_MSC_VER) // Because of a bug with g++ <= 3.2, we have to put the implementation // of the function inline. @@ -146,7 +146,7 @@ private: (const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition); -#endif // defined(__GNUC__) && (__GNUC__ >= 3) && (__GNUC_MINOR__ <= 2) +#endif // (defined(__GNUC__) && (__GNUC__ >= 3) && (__GNUC_MINOR__ <= 2)) || defined(_MSC_VER) } // vmime