00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef TAO_STRING_MANAGER_T
00014 #define TAO_STRING_MANAGER_T
00015
00016 #include "ace/pre.h"
00017
00018 #include "tao/TAO_Export.h"
00019
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif
00023
00024 #include "tao/Basic_Types.h"
00025 #include "tao/String_Traits_Base_T.h"
00026
00027 #include <algorithm>
00028
00029
00030
00031 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00032
00033 namespace TAO
00034 {
00035 template <typename charT>
00036 class String_Manager_T
00037 {
00038 public:
00039 typedef charT character_type;
00040 typedef TAO::details::string_traits_base <charT> s_traits;
00041
00042
00043 inline String_Manager_T (void) : ptr_ (s_traits::default_initializer())
00044 {
00045 }
00046
00047
00048 inline String_Manager_T (const String_Manager_T<charT> &rhs) :
00049 ptr_ (s_traits::duplicate (rhs.ptr_))
00050 {
00051 }
00052
00053
00054 inline String_Manager_T (const character_type *s) :
00055 ptr_ (s_traits::duplicate (s))
00056 {
00057 }
00058
00059
00060 inline ~String_Manager_T (void) {
00061 s_traits::release (this->ptr_);
00062 }
00063
00064
00065 inline String_Manager_T &operator= (const String_Manager_T<charT> &rhs) {
00066
00067
00068 String_Manager_T <character_type> tmp (rhs);
00069 std::swap (this->ptr_, tmp.ptr_);
00070 return *this;
00071 }
00072
00073
00074 inline String_Manager_T &operator= (const typename s_traits::string_var& value) {
00075
00076
00077 String_Manager_T <character_type> tmp (value.in ());
00078 std::swap (this->ptr_, tmp.ptr_);
00079 return *this;
00080 }
00081
00082
00083 inline String_Manager_T &operator= (const character_type *p) {
00084
00085
00086 String_Manager_T <character_type> tmp (p);
00087 std::swap (this->ptr_, tmp.ptr_);
00088 return *this;
00089 }
00090
00091
00092
00093 inline String_Manager_T &operator= (character_type *p) {
00094 s_traits::release (this->ptr_);
00095 this->ptr_ = p;
00096 return *this;
00097 }
00098
00099
00100 inline operator const character_type*() const {
00101 return this->ptr_;
00102 }
00103
00104
00105 inline const character_type *in (void) const {
00106 return this->ptr_;
00107 }
00108
00109
00110 inline character_type *&inout (void) {
00111 return this->ptr_;
00112 }
00113
00114
00115 inline character_type *&out (void) {
00116 s_traits::release (this->ptr_);
00117 this->ptr_ = 0;
00118 return this->ptr_;
00119 }
00120
00121
00122 inline character_type *_retn (void) {
00123 character_type *temp = this->ptr_;
00124 this->ptr_ = 0;
00125 return temp;
00126 }
00127
00128 private:
00129
00130 character_type *ptr_;
00131 };
00132
00133 typedef TAO::String_Manager_T<CORBA::Char> String_Manager;
00134 typedef TAO::String_Manager_T<CORBA::WChar> WString_Manager;
00135 }
00136
00137 TAO_END_VERSIONED_NAMESPACE_DECL
00138
00139 #include "ace/post.h"
00140 #endif