00001 #ifndef guard_string_traits_base_hpp 00002 #define guard_string_traits_base_hpp 00003 /** 00004 * @file 00005 * 00006 * @brief Isolate the string_traits from the accidental differences 00007 * between wstring and string. 00008 * 00009 * $Id: String_Traits_Base_T.h 73128 2006-06-19 14:51:36Z parsons $ 00010 * 00011 * @author Carlos O'Ryan 00012 */ 00013 00014 #include "tao/String_Alloc.h" 00015 #include "ace/CDR_Stream.h" 00016 00017 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00018 00019 namespace TAO 00020 { 00021 template<typename charT> 00022 class String_Manager_T; 00023 00024 template<typename charT> 00025 class String_var; 00026 00027 template<typename charT> 00028 class String_out; 00029 00030 namespace details 00031 { 00032 00033 template<typename charT> 00034 struct string_traits_base 00035 { 00036 }; 00037 00038 template<> 00039 struct string_traits_base<char> 00040 { 00041 typedef char char_type; 00042 typedef TAO::String_var <char_type> string_var; 00043 typedef TAO::String_out <char_type> string_out; 00044 typedef TAO::String_Manager_T <char_type> string_mgr; 00045 typedef ACE_InputCDR::to_string to_type; 00046 typedef ACE_OutputCDR::from_string from_type; 00047 00048 inline static char_type * default_initializer() 00049 { 00050 return CORBA::string_dup(""); 00051 } 00052 00053 inline static char_type * duplicate(char_type const * s) 00054 { 00055 return CORBA::string_dup(s); 00056 } 00057 00058 inline static void release(char_type * s) 00059 { 00060 CORBA::string_free(s); 00061 } 00062 00063 inline static char_type * allocate (CORBA::ULong len) 00064 { 00065 return CORBA::string_alloc (len); 00066 } 00067 }; 00068 00069 template<> 00070 struct string_traits_base<CORBA::WChar> 00071 { 00072 typedef CORBA::WChar char_type; 00073 typedef TAO::String_var <char_type> string_var; 00074 typedef TAO::String_out <char_type> string_out; 00075 typedef TAO::String_Manager_T <char_type> string_mgr; 00076 typedef ACE_InputCDR::to_wstring to_type; 00077 typedef ACE_OutputCDR::from_wstring from_type; 00078 00079 inline static char_type * default_initializer() 00080 { 00081 #if defined(ACE_HAS_WCHAR) || defined(ACE_HAS_XPG4_MULTIBYTE_CHAR) 00082 return CORBA::wstring_dup(L""); 00083 #else 00084 //#warning "platform not configured with native wchar_t support" 00085 // static CORBA::WChar empty[] = { 0 }; 00086 CORBA::WChar empty[] = { 0 }; 00087 return CORBA::wstring_dup(empty); 00088 #endif /* 0 */ 00089 } 00090 00091 inline static char_type * duplicate(char_type const * s) 00092 { 00093 return CORBA::wstring_dup(s); 00094 } 00095 00096 inline static void release(char_type * s) 00097 { 00098 CORBA::wstring_free(s); 00099 } 00100 00101 inline static char_type * allocate (CORBA::ULong len) 00102 { 00103 return CORBA::wstring_alloc (len); 00104 } 00105 }; 00106 00107 } // namespace details 00108 } // namespace TAO 00109 00110 TAO_END_VERSIONED_NAMESPACE_DECL 00111 00112 #endif // guard_string_traits_base_hpp