00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00023
00029
00030
00031 #ifndef _CTTL_INPUT_H_INCLUDED_
00032 #define _CTTL_INPUT_H_INCLUDED_
00033
00034 #include "xtl_container.h"
00035
00041 namespace cttl {
00042
00043 using namespace cttl_impl;
00044
00063 template< typename StringT = CTTL_STD_STRING >
00064 class input
00065 {
00066 private:
00067
00069 xtl_text_container< StringT > m_container;
00070
00071 public:
00073 typedef StringT string_T;
00074
00076 typedef typename string_T::value_type char_T;
00077
00079
00081
00089 input( size_t vector_size_ = xtl_identity_vector_default_size )
00090 :
00091 m_container( xtl_flag_default, vector_size_ )
00092 {
00093 }
00094
00105 input(
00106 char_T const* pchar_,
00107 size_t vector_size_ = xtl_identity_vector_default_size
00108 )
00109 :
00110 m_container( pchar_, xtl_flag_default, vector_size_ )
00111 {
00112 }
00113
00131 input(
00132 char_T* array_[],
00133 char_T delimiter_ = char_T( '\n' ),
00134 size_t vector_size_ = xtl_identity_vector_default_size
00135 )
00136 :
00137 m_container( xtl_flag_default, vector_size_ )
00138 {
00139 string_array2string( m_container.text(), array_, delimiter_ );
00140 }
00141
00152 input(
00153 string_T const& str_,
00154 size_t vector_size_ = xtl_identity_vector_default_size
00155 )
00156 : m_container( str_, xtl_flag_default, vector_size_ )
00157 {
00158 }
00159
00161 ~input()
00162 {
00163 assert( !m_container.stack_size() );
00164 }
00165
00166 private:
00167
00168 explicit input( input const& )
00169 {
00170 }
00171
00172
00173 input const& operator=( input const& )
00174 {
00175 return *this;
00176 }
00177
00178 public:
00180
00182
00183 xtl_text_container< StringT >& container()
00184 {
00185 return m_container;
00186 }
00187
00189 xtl_text_container< StringT > const& container() const
00190 {
00191 return m_container;
00192 }
00193
00207 size_t vector_size( size_t new_size_ )
00208 {
00209 return m_container.identity_vector_size( new_size_ );
00210 }
00211
00213 size_t vector_size()
00214 {
00215 return m_container.identity_vector_size();
00216 }
00217
00219
00221
00223 void text( char_T const* pchar_ )
00224 {
00225 m_container.text( pchar_ );
00226 }
00227
00229 void text( string_T const& str_ )
00230 {
00231 m_container.text( str_ );
00232 }
00233
00235 string_T const& text() const
00236 {
00237 return m_container.text();
00238 }
00239
00241 string_T& text()
00242 {
00243 return container().text();
00244 }
00245
00247 size_t length() const
00248 {
00249 return text().length();
00250 }
00251
00252 };
00253
00254
00255 }
00256
00257 #endif // _CTTL_INPUT_H_INCLUDED_