feisty meow concerns codebase  2.140
string_convert.h
Go to the documentation of this file.
1 #ifndef STRING_CONVERSION_GROUP
2 #define STRING_CONVERSION_GROUP
3 
4 /*****************************************************************************\
5 * *
6 * Name : string_convert *
7 * Author : Chris Koeritz *
8 * *
9 *******************************************************************************
10 * Copyright (c) 2007-$now By Author. This program is free software; you can *
11 * redistribute it and/or modify it under the terms of the GNU General Public *
12 * License as published by the Free Software Foundation; either version 2 of *
13 * the License or (at your option) any later version. This is online at: *
14 * http://www.fsf.org/copyleft/gpl.html *
15 * Please send any updates to: fred@gruntose.com *
16 \*****************************************************************************/
17 
18 #include <basis/astring.h>
19 #include <basis/utf_conversion.h>
20 
21 /*
22 #ifdef __WIN32__
23  #ifndef _MANAGED
24  #define _WINSOCKAPI_ // the dance of the windows headers.
25  // winsock support...
26 // #undef FD_SETSIZE
27 // #define FD_SETSIZE 1000
28  // if you don't set this, you can only select on a default of 64 sockets.
29  #include <winsock2.h>
30  #include <windows.h>
31  #ifndef __GNU_WINDOWS__
32  #include <comdef.h>
33  #endif
34  #endif
35 #endif
36 */
37 
38 // forward.
39 class _bstr_t; // ATL (Active Template Library) string type.
40 
42 
43 namespace string_convert
44 {
45 
46 #ifdef _AFXDLL
48  inline astring to_astring(const CString &original)
49  { return astring(from_unicode_temp(original)); }
50 
52  inline CString to_CString(const astring &original)
53  { return CString(to_unicode_temp(original)); }
54 #endif
55 
56 #ifdef WIN32
57  #ifndef _MANAGED
58  #ifndef __GNU_WINDOWS__
60  inline basis::astring to_astring(const _bstr_t &original) {
61  return basis::astring(basis::astring::UNTERMINATED, (const char *)original,
62  original.length());
63  }
64 
66  inline _bstr_t to_bstr_t(const basis::astring &original)
67  { return _bstr_t(original.s()); }
68  #endif
69  #endif
70 #endif
71 
72 //other conversions.
73 
74 } //namespace
75 
76 #endif
77 
Provides a dynamically resizable ASCII character string.
Definition: astring.h:35
const char * s() const
synonym for observe. the 's' stands for "string", if that helps.
Definition: astring.h:113
A collection of conversions between popular string types.
Support for unicode builds.