00001 #ifndef guard_bounded_basic_string_sequence_hpp
00002 #define guard_bounded_basic_string_sequence_hpp
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 #include "tao/Bounded_Reference_Allocation_Traits_T.h"
00013 #include "tao/String_Traits_T.h"
00014 #include "tao/Generic_Sequence_T.h"
00015 #include "tao/String_Sequence_Element_T.h"
00016 
00017 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00018 
00019 namespace TAO
00020 {
00021 namespace details
00022 {
00023 
00024 template<typename charT, CORBA::ULong MAX>
00025 class bounded_basic_string_sequence
00026 {
00027 public:
00028   typedef charT character_type;
00029   typedef charT * value_type;
00030   typedef charT const * const_value_type;
00031 
00032   typedef details::string_traits<charT,true> element_traits;
00033   typedef details::bounded_reference_allocation_traits<value_type,element_traits,MAX,true> allocation_traits;
00034 
00035   typedef details::string_sequence_element<element_traits> element_type;
00036   typedef element_type subscript_type;
00037   typedef const_value_type const_subscript_type;
00038 
00039   typedef details::generic_sequence<value_type, allocation_traits, element_traits> implementation_type;
00040 
00041 
00042   inline bounded_basic_string_sequence()
00043     : impl_()
00044   {}
00045 
00046   inline bounded_basic_string_sequence(
00047       CORBA::ULong length,
00048       value_type * data,
00049       CORBA::Boolean release)
00050     : impl_(MAX, length, data, release)
00051   {}
00052 
00053   inline CORBA::ULong maximum() const {
00054     return impl_.maximum();
00055   }
00056 
00057   inline CORBA::Boolean release() const {
00058     return impl_.release();
00059   }
00060 
00061   inline CORBA::ULong length() const {
00062     return impl_.length();
00063   }
00064 
00065 
00066   inline void length(CORBA::ULong length) {
00067     implementation_type::range::check_length(length, MAX);
00068     impl_.length(length);
00069   }
00070 
00071   inline const_value_type operator[](CORBA::ULong i) const {
00072     return impl_[i];
00073   }
00074 
00075   inline element_type operator[](CORBA::ULong i) {
00076     return element_type(impl_[i], release());
00077   }
00078 
00079   inline const_value_type const * get_buffer() const {
00080     return impl_.get_buffer();
00081   }
00082 
00083   inline void replace(
00084       CORBA::ULong length,
00085       value_type * data,
00086       CORBA::Boolean release = false) {
00087     impl_.replace(MAX, length, data, release);
00088   }
00089 
00090   inline value_type * get_buffer(CORBA::Boolean orphan = false) {
00091     return impl_.get_buffer(orphan);
00092   }
00093   inline void swap(bounded_basic_string_sequence & rhs) throw() {
00094     impl_.swap(rhs.impl_);
00095   }
00096 
00097   static value_type * allocbuf(CORBA::ULong maximum)
00098   {
00099     return implementation_type::allocbuf(maximum);
00100   }
00101   static value_type * allocbuf() {
00102     return implementation_type::allocbuf(MAX);
00103   }
00104   static void freebuf(value_type * buffer)
00105   {
00106     implementation_type::freebuf(buffer);
00107   }
00108 
00109 private:
00110   implementation_type impl_;
00111 };
00112 
00113 } 
00114 } 
00115 
00116 TAO_END_VERSIONED_NAMESPACE_DECL
00117 
00118 #endif // guard_bounded_basic_string_sequence_hpp