Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tao / Bounded_Basic_String_Sequence_T.h
blobd048cc0edc02fd805224142ed9f8e82efaf773b6
1 #ifndef guard_bounded_basic_string_sequence_hpp
2 #define guard_bounded_basic_string_sequence_hpp
3 /**
4 * @file
6 * @brief Implement bounded sequences for strings and wide-strings.
8 * @author Carlos O'Ryan
9 */
10 #include "tao/Bounded_Reference_Allocation_Traits_T.h"
11 #include "tao/String_Traits_T.h"
12 #include "tao/Generic_Sequence_T.h"
13 #include "tao/String_Sequence_Element_T.h"
14 #include "tao/String_Const_Sequence_Element_T.h"
16 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
18 namespace TAO
20 template<typename charT, CORBA::ULong MAX>
21 class bounded_basic_string_sequence
23 public:
24 typedef charT character_type;
25 typedef charT * value_type;
26 typedef charT const * const_value_type;
27 typedef ::CORBA::ULong size_type;
29 typedef details::string_traits<charT,true> element_traits;
30 typedef details::bounded_reference_allocation_traits<value_type,element_traits,MAX,true> allocation_traits;
32 typedef details::string_sequence_element<element_traits> element_type;
33 typedef details::string_const_sequence_element<element_traits> const_element_type;
34 typedef element_type subscript_type;
35 typedef const_value_type const_subscript_type;
37 typedef details::generic_sequence<value_type, allocation_traits, element_traits> implementation_type;
39 // @copydoc TAO::details::generic_sequence::generic_sequence()
40 inline bounded_basic_string_sequence()
41 : impl_()
43 // @copydoc TAO::details::generic_sequence::generic_sequence()
44 inline bounded_basic_string_sequence(
45 CORBA::ULong length,
46 value_type * data,
47 CORBA::Boolean release)
48 : impl_(MAX, length, data, release)
50 // @copydoc TAO::details::generic_sequence::maximum()
51 inline CORBA::ULong maximum() const {
52 return impl_.maximum();
54 // @copydoc TAO::details::generic_sequence::release()
55 inline CORBA::Boolean release() const {
56 return impl_.release();
58 // @copydoc TAO::details::generic_sequence::length()
59 inline CORBA::ULong length() const {
60 return impl_.length();
63 // @copydoc TAO::details::generic_sequence::length()
64 inline void length(CORBA::ULong length) {
65 implementation_type::range::check_length(length, MAX);
66 impl_.length(length);
68 // @copydoc TAO::details::generic_sequence::operator[]
69 inline const_element_type operator[](CORBA::ULong i) const {
70 return const_element_type (impl_[i], release());
72 // @copydoc TAO::details::generic_sequence::operator[]
73 inline element_type operator[](CORBA::ULong i) {
74 return element_type(impl_[i], release());
76 // @copydoc TAO::details::generic_sequence::get_buffer()
77 inline const_value_type const * get_buffer() const {
78 return impl_.get_buffer();
80 // @copydoc TAO::details::generic_sequence::replace()
81 inline void replace(
82 CORBA::ULong length,
83 value_type * data,
84 CORBA::Boolean release = false) {
85 impl_.replace(MAX, length, data, release);
87 // @copydoc TAO::details::generic_sequence::get_buffer(CORBA::Boolean)
88 inline value_type * get_buffer(CORBA::Boolean orphan = false) {
89 return impl_.get_buffer(orphan);
91 inline void swap(bounded_basic_string_sequence & rhs) noexcept {
92 impl_.swap(rhs.impl_);
95 static value_type * allocbuf(CORBA::ULong maximum)
97 return implementation_type::allocbuf(maximum);
99 static value_type * allocbuf() {
100 return implementation_type::allocbuf(MAX);
102 static void freebuf(value_type * buffer)
104 implementation_type::freebuf(buffer);
107 private:
108 implementation_type impl_;
110 } // namespace TAO
112 TAO_END_VERSIONED_NAMESPACE_DECL
114 #endif // guard_bounded_basic_string_sequence_hpp