diff options
author | William R. Otte <wotte@dre.vanderbilt.edu> | 2006-07-24 15:50:21 +0000 |
---|---|---|
committer | William R. Otte <wotte@dre.vanderbilt.edu> | 2006-07-24 15:50:21 +0000 |
commit | 3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c (patch) | |
tree | 197c810e5f5bce17b1233a7cb8d7b50c0bcd25e2 /TAO/tao/String_Traits_Base_T.h | |
parent | 6b846cf03c0bcbd8c276cb0af61a181e5f98eaae (diff) | |
download | ATCD-3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c.tar.gz |
Repo restructuring
Diffstat (limited to 'TAO/tao/String_Traits_Base_T.h')
-rw-r--r-- | TAO/tao/String_Traits_Base_T.h | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/TAO/tao/String_Traits_Base_T.h b/TAO/tao/String_Traits_Base_T.h new file mode 100644 index 00000000000..0ab07b3a539 --- /dev/null +++ b/TAO/tao/String_Traits_Base_T.h @@ -0,0 +1,112 @@ +#ifndef guard_string_traits_base_hpp +#define guard_string_traits_base_hpp +/** + * @file + * + * @brief Isolate the string_traits from the accidental differences + * between wstring and string. + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "tao/String_Alloc.h" +#include "ace/CDR_Stream.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ +template<typename charT> +class String_Manager_T; + +template<typename charT> +class String_var; + +template<typename charT> +class String_out; + +namespace details +{ + +template<typename charT> +struct string_traits_base +{ +}; + +template<> +struct string_traits_base<char> +{ + typedef char char_type; + typedef TAO::String_var <char_type> string_var; + typedef TAO::String_out <char_type> string_out; + typedef TAO::String_Manager_T <char_type> string_mgr; + typedef ACE_InputCDR::to_string to_type; + typedef ACE_OutputCDR::from_string from_type; + + inline static char_type * default_initializer() + { + return CORBA::string_dup(""); + } + + inline static char_type * duplicate(char_type const * s) + { + return CORBA::string_dup(s); + } + + inline static void release(char_type * s) + { + CORBA::string_free(s); + } + + inline static char_type * allocate (CORBA::ULong len) + { + return CORBA::string_alloc (len); + } +}; + +template<> +struct string_traits_base<CORBA::WChar> +{ + typedef CORBA::WChar char_type; + typedef TAO::String_var <char_type> string_var; + typedef TAO::String_out <char_type> string_out; + typedef TAO::String_Manager_T <char_type> string_mgr; + typedef ACE_InputCDR::to_wstring to_type; + typedef ACE_OutputCDR::from_wstring from_type; + + inline static char_type * default_initializer() + { +#if defined(ACE_HAS_WCHAR) || defined(ACE_HAS_XPG4_MULTIBYTE_CHAR) + return CORBA::wstring_dup(L""); +#else +//#warning "platform not configured with native wchar_t support" +// static CORBA::WChar empty[] = { 0 }; + CORBA::WChar empty[] = { 0 }; + return CORBA::wstring_dup(empty); +#endif /* 0 */ + } + + inline static char_type * duplicate(char_type const * s) + { + return CORBA::wstring_dup(s); + } + + inline static void release(char_type * s) + { + CORBA::wstring_free(s); + } + + inline static char_type * allocate (CORBA::ULong len) + { + return CORBA::wstring_alloc (len); + } +}; + +} // namespace details +} // namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif // guard_string_traits_base_hpp |