diff options
author | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2011-04-08 20:51:59 +0000 |
---|---|---|
committer | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2011-04-08 20:51:59 +0000 |
commit | 3a451e9d58e8f6a91a580ba8cd722efaa58825ad (patch) | |
tree | a29cd1a1ec66926b87fb98f197cd045a6d0fa659 | |
parent | 23299fd8c77cdc7ddbf3937bb433c630d94e9d9b (diff) | |
download | ATCD-3a451e9d58e8f6a91a580ba8cd722efaa58825ad.tar.gz |
Fri Apr 8 20:49:40 UTC 2011 Jeff Parsons <j.parsons@vanderbilt.edu>
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | tao/String_Manager_T.h | 254 | ||||
-rw-r--r-- | tests/Alt_Mapping/options.cpp | 4 |
3 files changed, 168 insertions, 100 deletions
diff --git a/ChangeLog b/ChangeLog index 004cce93d83..b717a391a5b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Fri Apr 8 20:49:40 UTC 2011 Jeff Parsons <j.parsons@vanderbilt.edu> + + * tests/Alt_Mapping/Options.cpp: + + Removed ACE_RCSID macro. + + * tao/String_Manager_T.h: + + Debugging changes and comments. + Tue Apr 5 17:46:38 UTC 2011 Jeff Parsons <j.parsons@vanderbilt.edu> * tao/BiDir_GIOP/*.cpp: diff --git a/tao/String_Manager_T.h b/tao/String_Manager_T.h index 523aa24469f..ad2cfe74de3 100644 --- a/tao/String_Manager_T.h +++ b/tao/String_Manager_T.h @@ -21,6 +21,8 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +#include <string> + #include "ace/OS_NS_string.h" #include "tao/Basic_Types.h" #include "tao/String_Traits_Base_T.h" @@ -33,103 +35,163 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL namespace TAO { -template <typename charT> -class String_Manager_T -{ -public: - typedef charT character_type; - typedef TAO::details::string_traits_base <charT> s_traits; - - /// Default CTOR will initialize the underlying ptr_ to empty string. - inline String_Manager_T (void) : ptr_ (s_traits::default_initializer()) - { - } - - /// Copy constructor - inline String_Manager_T (const String_Manager_T<charT> &rhs) : - ptr_ (s_traits::duplicate (rhs.ptr_)) - { - } - - /// Constructor from const char* makes a copy. - inline String_Manager_T (const character_type *s) : - ptr_ (s_traits::duplicate (s)) + template <typename charT> + class String_Manager_T { - } - - /// Destructor - inline ~String_Manager_T (void) { - s_traits::release (this->ptr_); - } - - /// Assignment from another managed type - inline String_Manager_T &operator= (const String_Manager_T<charT> &rhs) { - // Strongly exception safe by means of copy and non-throwing swap - // technique. - String_Manager_T <character_type> tmp (rhs); - std::swap (this->ptr_, tmp.ptr_); - return *this; - } - - /// Assignment from var type will make a copy - inline String_Manager_T &operator= (const typename s_traits::string_var& value) { - // Strongly exception safe by means of copy and non-throwing swap - // technique. - String_Manager_T <character_type> tmp (value.in ()); - std::swap (this->ptr_, tmp.ptr_); - return *this; - } - - /// Assignment from a constant * will make a copy - inline String_Manager_T &operator= (const character_type *p) { - // Strongly exception safe by means of copy and non-throwing swap - // technique. - String_Manager_T <character_type> tmp (p); - std::swap (this->ptr_, tmp.ptr_); - return *this; - } - - /// Assignment from char* will not make a copy. The String_Manager_T will now - /// own the string. - inline String_Manager_T &operator= (character_type *p) { - s_traits::release (this->ptr_); - this->ptr_ = p; - return *this; - } - - /// Cast (read-only) - inline operator const character_type*() const { - return this->ptr_; - } - - /// For in parameter. - inline const character_type *in (void) const { - return this->ptr_; - } - - /// For inout parameter. - inline character_type *&inout (void) { - return this->ptr_; - } - - /// for out parameter. - inline character_type *&out (void) { - s_traits::release (this->ptr_); - this->ptr_ = 0; - return this->ptr_; - } - - /// For string of return type. - inline character_type *_retn (void) { - character_type *temp = this->ptr_; - this->ptr_ = 0; - return temp; - } - -private: - /// The underlying string - character_type *ptr_; -}; + public: + typedef charT character_type; + typedef TAO::details::string_traits_base <charT> s_traits; + + /// Default CTOR will initialize the underlying ptr_ to empty string. + inline + String_Manager_T (void) + : ptr_ (s_traits::default_initializer ()), + release_ (true) + { + } + + /// Copy constructor + inline + String_Manager_T (const String_Manager_T<charT> &rhs) + : ptr_ (s_traits::duplicate (rhs.ptr_)), + release_ (true) + { + } + + /// Constructor from const char* makes a copy. + inline + String_Manager_T (const character_type *s) + : ptr_ (s_traits::duplicate (s)), + release_ (true) + { + } + + /// Destructor + inline + ~String_Manager_T (void) + { + if (this->release_) + { + s_traits::release (this->ptr_); + } + } + + /// Assignment from another managed type + inline + String_Manager_T &operator= (const String_Manager_T<charT> &rhs) { + // Strongly exception safe by means of copy and non-throwing swap + // technique. + String_Manager_T <character_type> tmp (rhs); + std::swap (this->ptr_, tmp.ptr_); + tmp.release_ = this->release_; + this->release_ = true; + return *this; + } + + /// Assignment from var type will make a copy + inline + String_Manager_T &operator= (const typename s_traits::string_var& value) { + // Strongly exception safe by means of copy and non-throwing swap + // technique. + String_Manager_T <character_type> tmp (value.in ()); + std::swap (this->ptr_, tmp.ptr_); + tmp.release_ = this->release_; + this->release_ = true; + return *this; + } + + /// Assignment from a constant * will make a copy + inline + String_Manager_T &operator= (const character_type *p) { + // Strongly exception safe by means of copy and non-throwing swap + // technique. + String_Manager_T <character_type> tmp (p); + std::swap (this->ptr_, tmp.ptr_); + tmp.release_ = this->release_; + this->release_ = true; + return *this; + } + + /// Assignment from char* will not make a copy. The String_Manager_T will now + /// own the string. + inline + String_Manager_T &operator= (character_type *p) + { + if (this->release_) + { + s_traits::release (this->ptr_); + } + + this->ptr_ = p; + this->release_ = true; + return *this; + } + + /// Assignment from std::string will not make a copy. The string retains + /// ownership. + inline + String_Manager_T &operator= (const std::string &p) + { + if (this->release_) + { + s_traits::release (this->ptr_); + } + + this->ptr_ = const_cast<character_type *> (p.c_str ()); + this->release_ = false; + return *this; + } + + /// Cast (read-only) + inline + operator const character_type*() const + { + return this->ptr_; + } + + /// For in parameter. + inline + const character_type *in (void) const + { + return this->ptr_; + } + + /// For inout parameter. + inline + character_type *&inout (void) + { + this->release_ = true; + return this->ptr_; + } + + /// for out parameter. + inline + character_type *&out (void) + { + if (this->release_) + { + s_traits::release (this->ptr_); + } + + this->ptr_ = 0; + this->release_ = true; + return this->ptr_; + } + + /// For string of return type. + inline + character_type *_retn (void) + { + character_type *temp = this->ptr_; + this->ptr_ = 0; + return (this->release_ ? temp : 0); + } + + private: + /// The underlying string + character_type *ptr_; + bool release_; + }; typedef TAO::String_Manager_T<CORBA::Char> String_Manager; typedef TAO::String_Manager_T<CORBA::WChar> WString_Manager; diff --git a/tests/Alt_Mapping/options.cpp b/tests/Alt_Mapping/options.cpp index 0828f65e4f3..4708d6003f2 100644 --- a/tests/Alt_Mapping/options.cpp +++ b/tests/Alt_Mapping/options.cpp @@ -24,10 +24,6 @@ #include "ace/OS_NS_fcntl.h" #include "ace/Log_Msg.h" -ACE_RCSID (Param_Test, - options, - "$Id$") - // Constructor.p Options::Options (void) : ior_ (CORBA::string_dup ("file://test.ior")), |