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_PIPE_INPUT_H_INCLUDED_
00032 #define _CTTL_PIPE_INPUT_H_INCLUDED_
00033
00034 #include <iostream>
00035 #include <string>
00036 #include <vector>
00037
00038 namespace cttl {
00039
00041 template <typename CharT>
00042 inline size_t pipe_input_2_vector( std::vector< std::basic_string< CharT > >& vect_input_, std::basic_string< CharT > filter_ )
00043 {
00044 std::basic_string< CharT > inp_text;
00045 while ( std::cin >> inp_text ) {
00046
00047 if ( filter_.length() ) {
00048 if ( inp_text.find( filter_ ) != std::basic_string< CharT >::npos ) {
00049 vect_input_.push_back( inp_text );
00050 } else {
00051 }
00052 } else {
00053
00054 vect_input_.push_back( inp_text );
00055 }
00056 }
00057 return vect_input_.size();
00058 }
00059
00061 template <typename CharT>
00062 inline size_t pipe_input_2_vector( std::vector< std::basic_string< CharT > >& vect_input_, CharT const* filter_ )
00063 {
00064 return pipe_input_2_vector( vect_input_, std::basic_string< CharT >( filter_ ) );
00065 }
00066
00068 template <typename CharT>
00069 inline size_t pipe_input_2_vector( std::vector< std::basic_string< CharT > >& vect_input_ )
00070 {
00071 std::basic_string< CharT > inp_text;
00072 while ( std::cin >> inp_text ) {
00073 vect_input_.push_back( inp_text );
00074 }
00075 return vect_input_.size();
00076 }
00077
00079 template <typename CharT>
00080 inline size_t pipe_input_2_string( std::basic_string< CharT >& str_output_, CharT delimiter_ )
00081 {
00082 std::basic_string< char > inp_text;
00083 while ( std::cin >> inp_text ) {
00084
00085 str_output_ += inp_text;
00086 str_output_ += delimiter_;
00087 }
00088
00089 return str_output_.length();
00090 }
00091
00093 template <typename CharT>
00094 inline size_t pipe_input_2_string( std::basic_string< CharT >& str_output_ )
00095 {
00096 return pipe_input_2_string( str_output_, CharT( '\t' ) );
00097 }
00098
00099 }
00100
00101 #endif //_CTTL_PIPE_INPUT_H_INCLUDED_