예제 #1
0
 To operator ()(From &arr) const
 {
     typename remove_const<To>::type res(arr.size());
     for(std::size_t i = 0, size = arr.size(); i != size; ++i)
     {
         res[i] = numeric::promote<typename To::value_type>(arr[i]);
     }
     return res;
 }
예제 #2
0
파일: iconv++.hpp 프로젝트: Fadis/iconvpp
 std::vector< char > get_block(
     std::vector<char>::const_iterator prefix_begin, std::vector<char>::const_iterator prefix_end,
     const From &from_string, typename From::size_type head_pos ) {
     typename From::size_type block_size = std::min( from_string.size() * sizeof( typename From::value_type ) - head_pos, block_size );
     std::vector< char > block( prefix_begin, prefix_end );
     block.resize( block.size() + block_size );
     std::vector< char >::iterator output_head = block.begin();
     std::advance( output_head, std::distance( prefix_begin, prefix_end ) );
     std::copy( reinterpret_cast<const char*>( from_string.c_str() ) + head_pos, reinterpret_cast<const char*>( from_string.c_str() ) + head_pos + block_size, output_head );
     return block;
 }
예제 #3
0
파일: iconv++.hpp 프로젝트: Fadis/iconvpp
    To operator()( const From &from_string ) {
        To to_string;
        typename From::size_type head_pos = 0;
        std::vector< char > partial_sequence;
        while( 1 ) {
            const std::vector< char > input_block = get_block( partial_sequence.begin(), partial_sequence.end(), from_string, head_pos );
            head_pos += input_block.size() - partial_sequence.size();
            const std::pair< std::vector< char >, std::vector< char > > output_block = convert_block< block_size >( cd, input_block );
            const To temp = set_block( output_block.first );
            partial_sequence = output_block.second;
            to_string += temp;
            if( head_pos == from_string.size() * sizeof( typename From::value_type ) )
                break;

        }
        return to_string;
    }