]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/corefoundation/cfstring.h
Document the cfstring.h/cfstring.cpp as being used by all Darwin ports (it's
[wxWidgets.git] / include / wx / mac / corefoundation / cfstring.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mac/corefoundation/cfstring.h
3 // Purpose: wxMacCFStringHolder and other string functions
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 2004-10-29 (from code in wx/mac/carbon/private.h)
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 // Usage: Darwin (base library)
11 /////////////////////////////////////////////////////////////////////////////
12
13 #ifndef __WX_CFSTRINGHOLDER_H__
14 #define __WX_CFSTRINGHOLDER_H__
15
16 #ifdef __DARWIN__
17 #include <CoreFoundation/CFString.h>
18 #else
19 #include <CFString.h>
20 #endif
21
22 #include "wx/dlimpexp.h"
23 #include "wx/fontenc.h"
24
25 class WXDLLIMPEXP_FWD_BASE wxString;
26
27 WXDLLIMPEXP_BASE void wxMacConvertNewlines13To10( wxString *data ) ;
28 WXDLLIMPEXP_BASE void wxMacConvertNewlines10To13( wxString *data ) ;
29
30 WXDLLIMPEXP_BASE void wxMacConvertNewlines13To10( char * data ) ;
31 WXDLLIMPEXP_BASE void wxMacConvertNewlines10To13( char * data ) ;
32
33 WXDLLIMPEXP_BASE wxUint32 wxMacGetSystemEncFromFontEnc(wxFontEncoding encoding) ;
34 WXDLLIMPEXP_BASE wxFontEncoding wxMacGetFontEncFromSystemEnc(wxUint32 encoding) ;
35 WXDLLIMPEXP_BASE void wxMacWakeUp() ;
36
37 class WXDLLIMPEXP_BASE wxMacCFStringHolder
38 {
39 public:
40 wxMacCFStringHolder()
41 : m_cfs(NULL) , m_release(false)
42 {
43 }
44
45 wxMacCFStringHolder(const wxString &str,
46 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
47 : m_cfs(NULL) , m_release(false)
48 {
49 Assign( str , encoding ) ;
50 }
51
52 wxMacCFStringHolder(CFStringRef ref , bool release = true )
53 : m_cfs(ref) , m_release(release)
54 {
55 }
56
57 ~wxMacCFStringHolder()
58 {
59 Release() ;
60 }
61
62 CFStringRef Detach()
63 {
64 CFStringRef retval = m_cfs ;
65 m_release = false ;
66 m_cfs = NULL ;
67 return retval ;
68 }
69
70 void Release()
71 {
72 if ( m_release && m_cfs)
73 CFRelease( m_cfs ) ;
74 m_cfs = NULL ;
75 }
76
77 void Assign(const wxString &str,
78 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
79
80 operator CFStringRef () const { return m_cfs; }
81 wxString AsString( wxFontEncoding encoding = wxFONTENCODING_DEFAULT ) ;
82
83 private:
84
85 CFStringRef m_cfs;
86 bool m_release ;
87
88 DECLARE_NO_COPY_CLASS( wxMacCFStringHolder )
89 } ;
90
91 // corresponding class for holding UniChars (native unicode characters)
92
93 class WXDLLIMPEXP_BASE wxMacUniCharBuffer
94 {
95 public :
96 wxMacUniCharBuffer( const wxString &str ) ;
97
98 ~wxMacUniCharBuffer() ;
99
100 UniChar* GetBuffer() ;
101
102 UniCharCount GetChars() ;
103
104 private :
105 UniChar* m_ubuf ;
106 UniCharCount m_chars ;
107 };
108 #endif //__WXCFSTRINGHOLDER_H__