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  * String_Traits_T.h,v 1.2 2006/04/19 08:21:45 jwillemsen Exp
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   inline static void copy_range(
00044       char_type ** begin, char_type ** end, char_type ** dst)
00045   {
00046     std::transform(begin, end, dst, &derived::duplicate);
00047   }
00048 
00049   inline static void release_range(
00050       char_type ** begin, char_type ** end)
00051   {
00052     std::for_each(begin, end, &derived::release);
00053   }
00054 
00055   inline static char_type const * initialize_if_zero(char_type * & element)
00056   {
00057     if (element == 0)
00058     {
00059       element = derived::default_initializer();
00060     }
00061     return element;
00062   }
00063 };
00064 
00065 template<class charT, bool dummy>
00066 struct string_traits
00067   : public string_traits_base<charT>
00068   , public string_traits_decorator<charT,string_traits<charT,dummy> >
00069 {
00070 };
00071 
00072 } // namespace details
00073 } // namespace CORBA
00074 
00075 TAO_END_VERSIONED_NAMESPACE_DECL
00076 
00077 #endif // guard_string_traits_hpp

Generated on Thu Nov 9 11:54:22 2006 for TAO by doxygen 1.3.6