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 inline size_t pipe_input_2_vector( std::vector< std::basic_string< unsigned char > >& vect_input_, std::basic_string< unsigned char > filter_ = std::basic_string< unsigned char >() )
00042 {
00043 std::basic_string< unsigned char > inp_text;
00044 char buffer[ CTTL_STD_CIN_BUFFER_SIZE ];
00045 while ( std::cin >> buffer ) {
00046 inp_text = reinterpret_cast< unsigned char* >( buffer );
00047
00048 if ( filter_.length() ) {
00049 if ( inp_text.find( filter_ ) != std::basic_string< unsigned char >::npos ) {
00050 vect_input_.push_back( inp_text );
00051 } else {
00052 }
00053 } else {
00054
00055 vect_input_.push_back( inp_text );
00056 }
00057 }
00058 return vect_input_.size();
00059 }
00060
00062 inline size_t pipe_input_2_vector( std::vector< std::basic_string< char > >& vect_input_, std::basic_string< char > filter_ = std::basic_string< char >() )
00063 {
00064 std::basic_string< char > inp_text;
00065 while ( std::cin >> inp_text ) {
00066
00067 if ( filter_.length() ) {
00068 if ( inp_text.find( filter_ ) != std::basic_string< char >::npos ) {
00069 vect_input_.push_back( inp_text );
00070 } else {
00071 }
00072 } else {
00073
00074 vect_input_.push_back( inp_text );
00075 }
00076 }
00077 return vect_input_.size();
00078 }
00079
00081 inline size_t pipe_input_2_string( std::basic_string< unsigned char >& str_output_, unsigned char delimiter_ = ( unsigned char )( '\t' ) )
00082 {
00083 std::basic_string< unsigned char > inp_text;
00084 char buffer[ CTTL_STD_CIN_BUFFER_SIZE ];
00085 while ( std::cin >> buffer ) {
00086 inp_text = reinterpret_cast< unsigned char* >( buffer );
00087
00088 str_output_ += inp_text;
00089 str_output_ += delimiter_;
00090 }
00091
00092 return str_output_.length();
00093 }
00094
00096 inline size_t pipe_input_2_string( std::basic_string< char >& str_output_, char delimiter_ = char( '\t' ) )
00097 {
00098 std::basic_string< char > inp_text;
00099 while ( std::cin >> inp_text ) {
00100
00101 str_output_ += inp_text;
00102 str_output_ += delimiter_;
00103 }
00104
00105 return str_output_.length();
00106 }
00107
00108 }
00109
00110 #endif //_CTTL_PIPE_INPUT_H_INCLUDED_