String_Traits_T.h

Go to the documentation of this file.
00001 #ifndef guard_string_traits_hpp
00002 #define guard_string_traits_hpp
00003 /**
00004  * @file
00005  *
00006  * @brief Implement the element manipulation traits for string types.
00007  *
00008  * $Id: String_Traits_T.h 77683 2007-03-12 21:42:05Z ossama $
00009  *
00010  * @author Carlos O'Ryan
00011  */
00012 
00013 #include "String_Traits_Base_T.h"
00014 
00015 #include <algorithm>
00016 #include <functional>
00017 
00018 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00019 
00020 namespace TAO
00021 {
00022 namespace details
00023 {
00024 
00025 template<typename char_type, class derived>
00026 struct string_traits_decorator
00027 {
00028   typedef char_type * value_type;
00029   typedef char_type const * const_value_type;
00030 
00031   inline static void zero_range(
00032       char_type ** begin, char_type ** end)
00033   {
00034     std::fill(begin, end, static_cast<char_type*>(0));
00035   }
00036 
00037   inline static void initialize_range(
00038       char_type ** begin, char_type ** end)
00039   {
00040     std::generate(begin, end, &derived::default_initializer);
00041   }
00042 
00043 # ifndef ACE_LACKS_MEMBER_TEMPLATES
00044   // Allow MSVC++ >= 8 checked iterators to be used.
00045   template <typename iter>
00046   inline static void copy_range(
00047       char_type ** begin, char_type ** end, iter dst)
00048   {
00049     std::transform(begin, end, dst, &derived::duplicate);
00050   }
00051 # else 
00052   inline static void copy_range(
00053       char_type ** begin, char_type ** end, char_type ** dst)
00054   {
00055     std::transform(begin, end, dst, &derived::duplicate);
00056   }
00057 # endif  /* !ACE_LACKS_MEMBER_TEMPLATES */
00058 
00059   inline static void release_range(
00060       char_type ** begin, char_type ** end)
00061   {
00062     std::for_each(begin, end, &derived::release);
00063   }
00064 
00065   inline static char_type const * initialize_if_zero(char_type * & element)
00066   {
00067     if (element == 0)
00068     {
00069       element = derived::default_initializer();
00070     }
00071     return element;
00072   }
00073 };
00074 
00075 template<class charT, bool dummy>
00076 struct string_traits
00077   : public string_traits_base<charT>
00078   , public string_traits_decorator<charT,string_traits<charT,dummy> >
00079 {
00080 };
00081 
00082 } // namespace details
00083 } // namespace CORBA
00084 
00085 TAO_END_VERSIONED_NAMESPACE_DECL
00086 
00087 #endif // guard_string_traits_hpp

Generated on Tue Feb 2 17:37:52 2010 for TAO by  doxygen 1.4.7