X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=nucleus%2Flibrary%2Ftextual%2Fstring_convert.h;fp=nucleus%2Flibrary%2Ftextual%2Fstring_convert.h;h=697439e7a1951957ad0c4d4a3e578d6fcff18ab4;hb=457b128b77b5b4a0b7dd3094de543de2ce1477ad;hp=0000000000000000000000000000000000000000;hpb=32d7caf45d886d0d24e69eea00511c7815ac15d0;p=feisty_meow.git diff --git a/nucleus/library/textual/string_convert.h b/nucleus/library/textual/string_convert.h new file mode 100644 index 00000000..697439e7 --- /dev/null +++ b/nucleus/library/textual/string_convert.h @@ -0,0 +1,70 @@ +#ifndef STRING_CONVERSION_GROUP +#define STRING_CONVERSION_GROUP + +/*****************************************************************************\ +* * +* Name : string_convert * +* Author : Chris Koeritz * +* * +******************************************************************************* +* Copyright (c) 2007-$now By Author. This program is free software; you can * +* redistribute it and/or modify it under the terms of the GNU General Public * +* License as published by the Free Software Foundation; either version 2 of * +* the License or (at your option) any later version. This is online at: * +* http://www.fsf.org/copyleft/gpl.html * +* Please send any updates to: fred@gruntose.com * +\*****************************************************************************/ + +#include +#include + +#ifdef __WIN32__ + #ifndef _MANAGED + #ifndef __MINGW32__ + #define _WINSOCKAPI_ // the dance of the windows headers. + #include + #include + #endif + #endif +#endif + +// forward. +class _bstr_t; // ATL (Active Template Library) string type. + +//! A collection of conversions between popular string types. + +namespace string_convert +{ + +#ifdef _AFXDLL + //! conversion from MFC CString to astring. + inline astring to_astring(const CString &original) + { return astring(from_unicode_temp(original)); } + + //! conversion from astring to MFC CString. + inline CString to_CString(const astring &original) + { return CString(to_unicode_temp(original)); } +#endif + +#ifdef WIN32 + #ifndef _MANAGED + #ifndef __MINGW32__ + //! conversion from ATL's _bstr_t object to astring. + inline basis::astring to_astring(const _bstr_t &original) { + return basis::astring(basis::astring::UNTERMINATED, (const char *)original, + original.length()); + } + + //! conversion from astring to the ATL _bstr_t object. + inline _bstr_t to_bstr_t(const basis::astring &original) + { return _bstr_t(original.s()); } + #endif + #endif +#endif + +//other conversions. + +} //namespace + +#endif +