1 #ifndef guard_string_sequence_element_hpp
2 #define guard_string_sequence_element_hpp
6 * @brief Implement the type returned by operator[] in string
9 * @author Carlos O'Ryan
12 #include "tao/Basic_Types.h"
16 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
22 template<typename traits
>
23 class string_sequence_element
26 typedef typename
traits::char_type character_type
;
27 typedef character_type
* value_type
;
28 typedef character_type
const * const_value_type
;
29 typedef typename
traits::string_var string_var
;
30 typedef typename
traits::string_out string_out
;
31 typedef typename
traits::string_mgr string_mgr
;
34 inline string_sequence_element
<traits
> & pseudo_copy_swap(string_var
& rhs
)
38 traits::release(*element_
);
40 *element_
= rhs
._retn();
45 string_sequence_element(
46 value_type
& e
, CORBA::Boolean release
)
52 string_sequence_element(
53 string_sequence_element
const & rhs
)
54 : element_(rhs
.element_
)
55 , release_(rhs
.release_
)
59 ~string_sequence_element() = default;
61 string_sequence_element
& operator=(const_value_type rhs
)
64 return pseudo_copy_swap(tmp
);
67 string_sequence_element
& operator=(value_type rhs
)
70 return pseudo_copy_swap(tmp
);
73 string_sequence_element
& operator=(string_sequence_element
const & rhs
)
75 string_var
tmp(static_cast<const_value_type
>(rhs
));
76 return pseudo_copy_swap(tmp
);
79 string_sequence_element
& operator=(string_var
const & rhs
)
82 return pseudo_copy_swap(tmp
);
85 string_sequence_element
& operator=(string_mgr
const & rhs
)
87 string_var
tmp(rhs
.in());
88 return pseudo_copy_swap(tmp
);
91 inline operator const_value_type() const
93 return *this->element_
;
96 inline const character_type
*in () const {
97 return *this->element_
;
100 inline character_type
*&inout () const {
101 return *this->element_
;
104 inline string_out
out () const {
107 traits::release(*element_
);
110 return *this->element_
;
113 inline character_type
*_retn () {
114 character_type
* copy
= *this->element_
;
115 *this->element_
= traits::default_initializer();
119 void swap(string_sequence_element
& rhs
)
121 std::swap(element_
, rhs
.element_
);
122 std::swap(release_
, rhs
.release_
);
125 CORBA::Boolean
release() const
127 return this->release_
;
131 // This function is not implemented
132 string_sequence_element();
135 value_type
* element_
;
136 CORBA::Boolean release_
;
138 } // namespace details
141 TAO_END_VERSIONED_NAMESPACE_DECL
143 #endif // guard_string_sequence_element_hpp