1 #ifndef guard_string_traits_base_hpp
2 #define guard_string_traits_base_hpp
6 * @brief Isolate the string_traits from the accidental differences
7 * between wstring and string.
9 * @author Carlos O'Ryan
12 #include "tao/String_Alloc.h"
13 #include "ace/CDR_Stream.h"
15 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
19 template<typename charT
>
20 class String_Manager_T
;
22 template<typename charT
>
25 template<typename charT
>
30 template<typename charT
>
31 struct string_traits_base
36 struct string_traits_base
<char>
38 typedef char char_type
;
39 typedef TAO::String_var
<char_type
> string_var
;
40 typedef TAO::String_out
<char_type
> string_out
;
41 typedef TAO::String_Manager_T
<char_type
> string_mgr
;
42 typedef ACE_InputCDR::to_string to_type
;
43 typedef ACE_OutputCDR::from_string from_type
;
45 inline static char_type
* default_initializer()
47 return CORBA::string_dup("");
50 inline static char_type
* duplicate(char_type
const * s
)
52 return CORBA::string_dup(s
);
55 inline static void release(char_type
* s
)
57 CORBA::string_free(s
);
60 inline static char_type
* allocate (CORBA::ULong len
)
62 return CORBA::string_alloc (len
);
67 struct string_traits_base
<CORBA::WChar
>
69 typedef CORBA::WChar char_type
;
70 typedef TAO::String_var
<char_type
> string_var
;
71 typedef TAO::String_out
<char_type
> string_out
;
72 typedef TAO::String_Manager_T
<char_type
> string_mgr
;
73 typedef ACE_InputCDR::to_wstring to_type
;
74 typedef ACE_OutputCDR::from_wstring from_type
;
76 inline static char_type
* default_initializer()
78 #if defined(ACE_HAS_WCHAR) || defined(ACE_HAS_XPG4_MULTIBYTE_CHAR)
79 return CORBA::wstring_dup(L
"");
81 //#warning "platform not configured with native wchar_t support"
82 // static CORBA::WChar empty[] = { 0 };
83 CORBA::WChar empty
[] = { 0 };
84 return CORBA::wstring_dup(empty
);
88 inline static char_type
* duplicate(char_type
const * s
)
90 return CORBA::wstring_dup(s
);
93 inline static void release(char_type
* s
)
95 CORBA::wstring_free(s
);
98 inline static char_type
* allocate (CORBA::ULong len
)
100 return CORBA::wstring_alloc (len
);
103 } // namespace details
106 TAO_END_VERSIONED_NAMESPACE_DECL
108 #endif // guard_string_traits_base_hpp