Some fixes for Visual C++/Windows.

This commit is contained in:
Vincent Richard 2005-03-25 21:37:36 +00:00
parent 433f21263f
commit d6f67b0a4a
6 changed files with 78 additions and 31 deletions

View File

@ -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 <vincent@vincent-richard.net>
* Added 'HACKING' file.

View File

@ -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

View File

@ -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 <string>::parse(const string& buffer, const string::size_type position,
@ -39,7 +39,7 @@ void typeAdapter <string>::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

View File

@ -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. */

View File

@ -75,7 +75,13 @@ public:
*
* @param value new value for property
*/
template <class TYPE> void setValue(const TYPE& value);
template <class TYPE> 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 <class TYPE> const TYPE getValue() const;
template <class TYPE> 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 <class TYPE>
void propertySet::property::setValue(const TYPE& value)
{
std::ostringstream oss;
oss << value;
m_value = oss.str();
}
template <class TYPE>
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

View File

@ -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