/* * mptStringParse.cpp * ------------------ * Purpose: Convert strings to other types. * Notes : (currently none) * Authors: OpenMPT Devs * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. */ #include "stdafx.h" #include "mptStringParse.h" #include "mpt/parse/parse.hpp" OPENMPT_NAMESPACE_BEGIN template inline T ConvertStrToHelper(const std::string &str) { return mpt::ConvertStringTo(str); } template<> inline bool ConvertStrToHelper(const std::string &str) { return ConvertStrToHelper(str)?true:false; } template<> inline signed char ConvertStrToHelper(const std::string &str) { return static_cast(ConvertStrToHelper(str)); } template<> inline unsigned char ConvertStrToHelper(const std::string &str) { return static_cast(ConvertStrToHelper(str)); } #if MPT_WSTRING_FORMAT template inline T ConvertStrToHelper(const std::wstring &str) { return mpt::ConvertStringTo(str); } template<> inline bool ConvertStrToHelper(const std::wstring &str) { return ConvertStrToHelper(str)?true:false; } template<> inline signed char ConvertStrToHelper(const std::wstring &str) { return static_cast(ConvertStrToHelper(str)); } template<> inline unsigned char ConvertStrToHelper(const std::wstring &str) { return static_cast(ConvertStrToHelper(str)); } #endif bool ConvertStrToBool(const std::string &str) { return ConvertStrToHelper(str); } signed char ConvertStrToSignedChar(const std::string &str) { return ConvertStrToHelper(str); } unsigned char ConvertStrToUnsignedChar(const std::string &str) { return ConvertStrToHelper(str); } signed short ConvertStrToSignedShort(const std::string &str) { return ConvertStrToHelper(str); } unsigned short ConvertStrToUnsignedShort(const std::string &str) { return ConvertStrToHelper(str); } signed int ConvertStrToSignedInt(const std::string &str) { return ConvertStrToHelper(str); } unsigned int ConvertStrToUnsignedInt(const std::string &str) { return ConvertStrToHelper(str); } signed long ConvertStrToSignedLong(const std::string &str) { return ConvertStrToHelper(str); } unsigned long ConvertStrToUnsignedLong(const std::string &str) { return ConvertStrToHelper(str); } signed long long ConvertStrToSignedLongLong(const std::string &str) { return ConvertStrToHelper(str); } unsigned long long ConvertStrToUnsignedLongLong(const std::string &str) { return ConvertStrToHelper(str); } float ConvertStrToFloat(const std::string &str) { return ConvertStrToHelper(str); } double ConvertStrToDouble(const std::string &str) { return ConvertStrToHelper(str); } long double ConvertStrToLongDouble(const std::string &str) { return ConvertStrToHelper(str); } #if MPT_WSTRING_FORMAT bool ConvertStrToBool(const std::wstring &str) { return ConvertStrToHelper(str); } signed char ConvertStrToSignedChar(const std::wstring &str) { return ConvertStrToHelper(str); } unsigned char ConvertStrToUnsignedChar(const std::wstring &str) { return ConvertStrToHelper(str); } signed short ConvertStrToSignedShort(const std::wstring &str) { return ConvertStrToHelper(str); } unsigned short ConvertStrToUnsignedShort(const std::wstring &str) { return ConvertStrToHelper(str); } signed int ConvertStrToSignedInt(const std::wstring &str) { return ConvertStrToHelper(str); } unsigned int ConvertStrToUnsignedInt(const std::wstring &str) { return ConvertStrToHelper(str); } signed long ConvertStrToSignedLong(const std::wstring &str) { return ConvertStrToHelper(str); } unsigned long ConvertStrToUnsignedLong(const std::wstring &str) { return ConvertStrToHelper(str); } signed long long ConvertStrToSignedLongLong(const std::wstring &str) { return ConvertStrToHelper(str); } unsigned long long ConvertStrToUnsignedLongLong(const std::wstring &str) { return ConvertStrToHelper(str); } float ConvertStrToFloat(const std::wstring &str) { return ConvertStrToHelper(str); } double ConvertStrToDouble(const std::wstring &str) { return ConvertStrToHelper(str); } long double ConvertStrToLongDouble(const std::wstring &str) { return ConvertStrToHelper(str); } #endif namespace mpt { namespace String { namespace Parse { template T HexToHelper(const std::string &str) { return mpt::ConvertHexStringTo(str); } template<> unsigned char HexToHelper(const std::string &str) { return static_cast(HexToHelper(str)); } unsigned char HexToUnsignedChar(const std::string &str) { return HexToHelper(str); } unsigned short HexToUnsignedShort(const std::string &str) { return HexToHelper(str); } unsigned int HexToUnsignedInt(const std::string &str) { return HexToHelper(str); } unsigned long HexToUnsignedLong(const std::string &str) { return HexToHelper(str); } unsigned long long HexToUnsignedLongLong(const std::string &str) { return HexToHelper(str); } } // namespace Parse } // namespace String } // namespace mpt OPENMPT_NAMESPACE_END