本文整理汇总了C++中comma::csv::options::binary方法的典型用法代码示例。如果您正苦于以下问题:C++ options::binary方法的具体用法?C++ options::binary怎么用?C++ options::binary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类comma::csv::options
的用法示例。
在下文中一共展示了options::binary方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calculate_distance_next
static void calculate_distance_next()
{
comma::csv::input_stream< Eigen::Vector3d > istream( std::cin, csv );
boost::optional< Eigen::Vector3d > last;
while( istream.ready() || ( std::cin.good() && !std::cin.eof() ) )
{
const Eigen::Vector3d* p = istream.read();
if( !p ) { break; }
if( last )
{
double distance = ( *p - *last ).norm();
if( csv.binary() ) { std::cout.write( reinterpret_cast< const char* >( &distance ), sizeof( double ) ); }
else { std::cout << csv.delimiter << distance << std::endl; }
}
if( csv.binary() ) { std::cout.write( istream.binary().last(), istream.binary().binary().format().size() ); }
else { std::cout << comma::join( istream.ascii().last(), csv.delimiter ); }
last = *p;
}
if( last )
{
double fake_final_distance = 0;
if( csv.binary() ) { std::cout.write( reinterpret_cast< const char* >( &fake_final_distance ), sizeof( double ) ); }
else { std::cout << csv.delimiter << fake_final_distance << std::endl; }
}
}
示例2: thin
static void thin( double resolution )
{
comma::csv::input_stream< Eigen::Vector3d > istream( std::cin, csv );
boost::optional< Eigen::Vector3d > last;
double distance = 0;
while( istream.ready() || ( std::cin.good() && !std::cin.eof() ) )
{
const Eigen::Vector3d* p = istream.read();
if( !p ) { break; }
distance += last ? ( *p - *last ).norm() : 0;
if( !last || distance >= resolution )
{
distance = 0;
if( csv.binary() )
{
std::cout.write( istream.binary().last(), istream.binary().binary().format().size() );
}
else
{
std::cout << comma::join( istream.ascii().last(), csv.delimiter ) << std::endl;
}
}
last = *p;
}
}
示例3: output_bounding
static void output_bounding( std::ostream& os, const timestring_t& bounding, bool stdin_first )
{
if( !select_only )
{
if( stdin_csv.binary() )
{
if( timestamp_only )
{
static const unsigned int time_size = comma::csv::format::traits< boost::posix_time::ptime, comma::csv::format::time >::size;
static char timestamp[ time_size ];
comma::csv::format::traits< boost::posix_time::ptime, comma::csv::format::time >::to_bin( bounding.first, timestamp );
os.write( (char*)×tamp, time_size );
}
else
{
os.write( &bounding.second[0], bounding.second.size() );
}
}
else
{
if( stdin_first ) { os << stdin_csv.delimiter; }
os << ( timestamp_only ? boost::posix_time::to_iso_string( bounding.first ) : bounding.second );
if( !stdin_first ) { os << stdin_csv.delimiter; }
}
}
}
示例4: intervals
intervals( const comma::command_line_options& options ) : options( options )
, csv( options )
, ocsv( options )
, ascii_csv( options )
, empty( traits< bound_type >::cast( options.optional< std::string >( "--empty" ) ) )
, intervals_only( options.exists( "--intervals-only" ) )
, use_limits( options.exists( "--limits,-l" ) )
{
if( csv.fields.empty() ) { csv.fields = comma::join( comma::csv::names< interval_t< From, To > >(), ',' ); }
if( ocsv.fields.empty() || intervals_only )
{
ocsv.fields = comma::join( comma::csv::names< interval_t< From, To > >(), ',' );
if( ocsv.binary() && ( intervals_only || append ) ) { ocsv.format( comma::csv::format::value< interval_t< From, To > >() ); }
}
ascii_csv.fields = ocsv.fields;
ascii_csv.quote = boost::none;
if( verbose ) { std::cerr << app_name << ": empty: "; empty ? std::cerr << *empty : std::cerr << "<none>"; std::cerr << std::endl; }
options.assert_mutually_exclusive( "overlap-count-min,overlap-count-max", "overlap-count" );
if( options.exists( "--overlap-count" ) )
{
min_overlap_count = max_overlap_count = options.value< unsigned int >( "--overlap-count" );
}
else
{
min_overlap_count = options.value( "--overlap-count-min", 0 );
max_overlap_count = options.value( "--overlap-count-max", std::numeric_limits< unsigned int >::max() );
}
}
示例5:
template < typename It > static void output_( It it, It end )
{
for( ; it != end; ++it )
{
for( std::size_t i = 0; i < it->second.size() ; ++i )
{
std::cout.write( &( it->second[i][0] ), stdin_csv.binary() ? stdin_csv.format().size() : it->second[i].length() );
if( stdin_csv.flush ) { std::cout.flush(); }
}
}
}
示例6: output_points
void output_points(const Eigen::Vector3d& p1, const Eigen::Vector3d& p2)
{
if( csv.binary() )
{
std::cout.write( reinterpret_cast< const char* >( &p1 ), sizeof( double ) * 3 );
std::cout.write( reinterpret_cast< const char* >( &p2 ), sizeof( double ) * 3 );
std::cout.flush();
}
else
{
std::cout << ascii.put( p1 ) << csv.delimiter << ascii.put( p2 ) << std::endl;
}
}
示例7: run
void run()
{
comma::csv::input_stream< interval_t< From, To > > istream( std::cin, csv );
comma::csv::ascii< interval_t< std::string > > ascii( csv.fields );
if( !first_line.empty() )
{
interval_t< From, To > interval = comma::csv::ascii< interval_t< From, To > >( csv.fields ).get( first_line );
bound_t< bound_type > from( LOWER );
bound_t< bound_type > to( UPPER );
std::string payload;
interval_t< std::string > first;
ascii.get( first, first_line );
if( !first.from.value.empty() && ( !empty || interval.from.value != *empty ) ) { from.value = interval.from.value; }
if( !first.to.value.empty() && ( !empty || interval.to.value != *empty ) ) { to.value = interval.to.value; }
payload = first_line;
if( !intervals_only ) { ascii.put( interval_t< std::string >(), payload ); } // blank out interval from payload
if( verbose ) { std::cerr << app_name << ": from: " << from << " to: " << to << " payload: " << payload << std::endl; }
add( from, to, payload );
}
while( istream.ready() || std::cin.good() )
{
const interval_t< From, To >* interval = istream.read();
if( !interval ) { break; }
bound_t< bound_type > from( LOWER );
bound_t< bound_type > to( UPPER );
std::string payload;
if( csv.binary() )
{
if( !empty || interval->from.value != *empty ) { from.value = interval->from.value; }
if( !empty || interval->to.value != *empty ) { to.value = interval->to.value; }
std::vector< char > buf( istream.binary().last(), istream.binary().last() + istream.binary().size() );
if( !intervals_only ) { istream.binary().binary().put( interval_t< From, To >(), &buf[0] ); } // blank out interval from payload
payload = std::string( buf.begin(), buf.end() );
}
else
{
interval_t< std::string > last;
ascii.get( last, istream.ascii().last() );
if( !last.from.value.empty() && ( !empty || interval->from.value != *empty ) ) { from.value = interval->from.value; }
if( !last.to.value.empty() && ( !empty || interval->to.value != *empty ) ) { to.value = interval->to.value; }
std::vector< std::string > buf( istream.ascii().last() );
if( !intervals_only ) { ascii.put( interval_t< std::string >(), buf ); } // blank out interval from payload
payload = comma::join( buf, csv.delimiter );
}
if( verbose ) { std::cerr << app_name << ": from: " << from << " to: " << to << " payload: " << ( csv.binary() ? "<binary>" : payload ) << std::endl; }
add( from, to, payload );
}
write();
}
示例8: read_block_impl_
static block_t* read_block_impl_( ::tbb::flow_control* flow = NULL )
{
static boost::array< block_t, 3 > blocks;
static boost::optional< block_t::pair_t > last;
static comma::uint32 block_id = 0;
block_t::pairs_t* points = new block_t::pairs_t;
while( true ) // quick and dirty, only if --discard
{
static comma::csv::input_stream< input_t > istream( std::cin, csv );
points->clear();
while( true )
{
if( last )
{
block_id = last->first.block;
points->push_back( *last );
last.reset();
}
if( is_shutdown || std::cout.bad() || std::cin.bad() || std::cin.eof() )
{
if( bursty_reader ) { bursty_reader->stop(); } // quick and dirty, it sucks...
if( flow ) { flow->stop(); }
break;
}
const input_t* p = istream.read();
if( !p ) { break; }
std::string line;
if( csv.binary() )
{
line.resize( csv.format().size() );
::memcpy( &line[0], istream.binary().last(), csv.format().size() );
}
else
{
line = comma::join( istream.ascii().last(), csv.delimiter );
}
last = std::make_pair( *p, line );
if( p->block != block_id ) { break; }
}
for( unsigned int i = 0; i < blocks.size(); ++i )
{
if( !blocks[i].empty ) { continue; }
blocks[i].clear();
blocks[i].id = block_id;
blocks[i].points.reset( points );
blocks[i].empty = false;
return &blocks[i];
}
}
}
示例9:
stereo::stereo ( const snark::imaging::camera_parser& left, const snark::imaging::camera_parser& right, unsigned int width, unsigned int height, const comma::csv::options& csv, bool input_rectified ):
m_rotation( right.rotation() * left.rotation().transpose() ),
m_translation( right.translation() - left.translation() ),
m_rectify( left.camera(), left.distortion(), right.camera(), right.distortion(), width, height, m_rotation, m_translation, input_rectified ),
m_input_rectified( input_rectified ),
m_frame_counter( 0 )
{
if( csv.binary() )
{
m_binary.reset( new comma::csv::binary< colored_point >( csv ) );
m_output.resize( csv.format().size() );
}
else
{
m_ascii.reset( new comma::csv::ascii< colored_point >( csv ) );
}
}
示例10: size
Reader::Reader( QGLView& viewer, comma::csv::options& options, std::size_t size, coloured* c, unsigned int pointSize, const std::string& label, const QVector3D& offset )
: size( size )
, pointSize( pointSize )
, options( options )
, m_viewer( viewer )
, m_num_points( 0 )
, m_colored( c )
, m_shutdown( false )
, m_isStdIn( options.filename == "-" )
, m_show( true )
, m_istream( options.filename, options.binary() ? comma::io::mode::binary : comma::io::mode::ascii, comma::io::mode::non_blocking )
, updated_( false )
, id_( 0 )
, m_label( label )
, m_offset( offset )
{
std::vector< std::string > v = comma::split( options.fields, ',' ); // quick and dirty
}
示例11: intervals
intervals( const comma::command_line_options& options ) : options( options )
, csv( options )
, ocsv( options )
, ascii_csv( options )
, empty( traits< bound_type >::cast( options.optional< std::string >( "--empty" ) ) )
, intervals_only( options.exists( "--intervals-only" ) )
, use_limits( options.exists( "--limits,-l" ) )
{
if( csv.fields.empty() ) { csv.fields = comma::join( comma::csv::names< interval_t< From, To > >(), ',' ); }
if( ocsv.fields.empty() || intervals_only )
{
ocsv.fields = comma::join( comma::csv::names< interval_t< From, To > >(), ',' );
if( ocsv.binary() && intervals_only ) { ocsv.format( comma::csv::format::value< interval_t< From, To > >() ); }
}
ascii_csv.fields = ocsv.fields;
ascii_csv.quote = boost::none;
if( verbose ) { std::cerr << app_name << ": empty: "; empty ? std::cerr << *empty : std::cerr << "<none>"; std::cerr << std::endl; }
}
示例12: calculate_distance_for_pairs
static void calculate_distance_for_pairs()
{
comma::csv::input_stream< point_pair_t > istream( std::cin, csv );
while( istream.ready() || ( std::cin.good() && !std::cin.eof() ) )
{
const point_pair_t* p = istream.read();
if( !p ) { break; }
double norm = ( p->first - p->second ).norm();
if( csv.binary() )
{
std::cout.write( istream.binary().last(), istream.binary().binary().format().size() );
std::cout.write( reinterpret_cast< const char* >( &norm ), sizeof( double ) );
}
else
{
std::cout << comma::join( istream.ascii().last(), csv.delimiter ) << csv.delimiter << norm << std::endl;
}
}
}
示例13: outputframe
frame::frame( const comma::csv::options& options, bool discardOutOfOrder, boost::optional< boost::posix_time::time_duration > maxGap, bool outputframe, bool to, bool interpolate, bool rotation_present )
: outputframe( outputframe )
, m_to( to )
, m_interpolate( interpolate )
, m_rotation( ::Eigen::Matrix3d::Identity() )
, m_istream( new comma::io::istream( options.filename, options.binary() ? comma::io::mode::binary : comma::io::mode::ascii, comma::io::mode::blocking ) )
, m_discardOutOfOrder( discardOutOfOrder )
, m_maxGap( maxGap )
, rotation_present_( rotation_present )
{
m_is.reset( new comma::csv::input_stream< position_type >( *( *m_istream )(), options ) );
const position_type* p = m_is->read(); // todo: maybe not very good, move to value()
if( p == NULL ) { COMMA_THROW( comma::exception, "failed to read from " << options.filename ); }
m_pair.first = *p;
set_position( p->value );
p = m_is->read(); // todo: maybe not very good, move to value()
if( p == NULL ) { COMMA_THROW( comma::exception, "failed to read from " << options.filename ); }
m_pair.second = *p;
}
示例14: output
static void output( const timestring_t& input, const timestring_t& bounding, bool stdin_first )
{
if( bounding.first.is_infinity() ) { return; }
if( bound && ( input.first - bounding.first > bound || bounding.first - input.first > bound )) { return; }
if( stdin_first )
{
output_input( std::cout, input );
output_bounding( std::cout, bounding, stdin_first );
}
else
{
output_bounding( std::cout, bounding, stdin_first );
output_input( std::cout, input );
}
if( !stdin_csv.binary() ) { std::cout << '\n'; }
std::cout.flush();
}
示例15: write
void write()
{
static comma::csv::output_stream< interval_t< From, To > > ostream( std::cout, ocsv );
static comma::csv::ascii< from_t< std::string > > from_ascii( ascii_csv );
static comma::csv::ascii< to_t< std::string > > to_ascii( ascii_csv );
for( typename map_t::iterator it = map.begin(); it != map.end(); ++it )
{
bound_t< bound_type > from = it->first.lower();
bound_t< bound_type > to = it->first.upper();
interval_t< From, To > interval;
bool from_has_value = true;
bool to_has_value = true;
if( from.value ) { interval.from.value = *from.value; }
else if( use_limits ) { interval.from.value = limits< From >::lowest(); }
else if( empty ) { interval.from.value = static_cast< From >( *empty ); }
else { from_has_value = false; }
if( to.value ) { interval.to.value = *to.value; }
else if( use_limits ) { interval.to.value = limits< To >::max(); }
else if( empty ) { interval.to.value = static_cast< To >( *empty ); }
else { to_has_value = false; }
const set_t& s = it->second;
if( csv.binary() )
{
if( intervals_only ) { ostream.write( interval ); ostream.flush(); continue; }
for( typename set_t::const_iterator v = s.begin(); v != s.end(); ++v ) { ostream.write( interval, *v ); }
ostream.flush();
}
else
{
for( typename set_t::const_iterator v = s.begin(); v != s.end(); ++v )
{
std::string payload( intervals_only ? "" : *v );
ostream.ascii().ascii().put( interval, payload );
if( !from_has_value ) { from_ascii.put( from_t< std::string >(), payload ); }
if( !to_has_value ) { to_ascii.put( to_t< std::string >(), payload); }
std::cout << payload << std::endl;
if( intervals_only ) { break; }
}
}
}
}