Go to the documentation of this file.00001 #ifndef guard_string_traits_hpp
00002 #define guard_string_traits_hpp
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "String_Traits_Base_T.h"
00014 #include "ace/OS_NS_string.h"
00015
00016 #include <algorithm>
00017 #include <functional>
00018
00019 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00020
00021 namespace TAO
00022 {
00023 namespace details
00024 {
00025
00026 template<typename char_type, class derived>
00027 struct string_traits_decorator
00028 {
00029 typedef char_type * value_type;
00030 typedef char_type const * const_value_type;
00031
00032 inline static void zero_range(
00033 char_type ** begin, char_type ** end)
00034 {
00035 ACE_OS::memset (begin, 0, (end - begin) * sizeof (char_type*));
00036 }
00037
00038 inline static void initialize_range(
00039 char_type ** begin, char_type ** end)
00040 {
00041 std::generate(begin, end, &derived::default_initializer);
00042 }
00043
00044 # if !defined (ACE_LACKS_MEMBER_TEMPLATES)
00045
00046 template <typename iter>
00047 inline static void copy_range(
00048 char_type ** begin, char_type ** end, iter dst)
00049 {
00050 std::transform(begin, end, dst, &derived::duplicate);
00051 }
00052 # else
00053 inline static void copy_range(
00054 char_type ** begin, char_type ** end, char_type ** dst)
00055 {
00056 std::transform(begin, end, dst, &derived::duplicate);
00057 }
00058 # endif
00059
00060 # if !defined (ACE_LACKS_MEMBER_TEMPLATES)
00061
00062 template <typename iter>
00063 inline static void copy_swap_range(
00064 char_type ** begin, char_type ** end, iter dst)
00065 {
00066 std::swap_ranges(begin, end, dst);
00067 }
00068 # else
00069 inline static void copy_swap_range(
00070 char_type ** begin, char_type ** end, char_type ** dst)
00071 {
00072 std::swap_ranges(begin, end, dst);
00073 }
00074 # endif
00075
00076 inline static void release_range(
00077 char_type ** begin, char_type ** end)
00078 {
00079 std::for_each(begin, end, &derived::release);
00080 }
00081
00082 inline static char_type const * initialize_if_zero(char_type * & element)
00083 {
00084 if (element == 0)
00085 {
00086 element = derived::default_initializer();
00087 }
00088 return element;
00089 }
00090 };
00091
00092 template<class charT, bool dummy>
00093 struct string_traits
00094 : public string_traits_base<charT>
00095 , public string_traits_decorator<charT,string_traits<charT,dummy> >
00096 {
00097 };
00098
00099 }
00100 }
00101
00102 TAO_END_VERSIONED_NAMESPACE_DECL
00103
00104 #endif // guard_string_traits_hpp