本文整理汇总了C++中comma::csv::options类的典型用法代码示例。如果您正苦于以下问题:C++ options类的具体用法?C++ options怎么用?C++ options使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了options类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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() );
}
}
示例2:
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 ) );
}
}
示例3: 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; }
}
示例4:
disparity::disparity ( 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_serialization( csv.fields, csv.format() )
{
}
示例5: 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
}
示例6: 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;
}
示例7: main
int main( int ac, char** av )
{
try
{
comma::signal_flag is_shutdown(comma::signal_flag::hard);
comma::command_line_options options( ac, av, usage );
if( options.exists( "--bash-completion" )) bash_completion( ac, av );
options.assert_mutually_exclusive( "--by-lower,--by-upper,--nearest,--realtime" );
if( options.exists( "--by-upper" )) { method = how::by_upper; }
if( options.exists( "--nearest" )) { method = how::nearest; }
if( options.exists( "--realtime" )) { method = how::realtime; }
timestamp_only = options.exists( "--timestamp-only,--time-only" );
select_only = options.exists( "--do-not-append,--select" );
if( select_only && timestamp_only ) { std::cerr << "csv-time-join: --timestamp-only specified with --select, ignoring --timestamp-only" << std::endl; }
bool discard_bounding = options.exists( "--discard-bounding" );
boost::optional< unsigned int > buffer_size = options.optional< unsigned int >( "--buffer" );
if( options.exists( "--bound" ) ) { bound = boost::posix_time::microseconds( static_cast<unsigned int>(options.value< double >( "--bound" ) * 1000000 )); }
stdin_csv = comma::csv::options( options, "t" );
std::vector< std::string > unnamed = options.unnamed(
"--by-lower,--by-upper,--nearest,--realtime,--select,--do-not-append,--timestamp-only,--time-only,--discard-bounding",
"--binary,-b,--delimiter,-d,--fields,-f,--bound,--buffer,--verbose,-v" );
std::string properties;
bool stdin_first = true;
switch( unnamed.size() )
{
case 0:
std::cerr << "csv-time-join: please specify bounding source" << std::endl;
return 1;
case 1:
properties = unnamed[0];
break;
case 2:
if( unnamed[0] == "-" ) { properties = unnamed[1]; }
else if( unnamed[1] == "-" ) { properties = unnamed[0]; stdin_first = false; }
else { std::cerr << "csv-time-join: expected either '- <bounding>' or '<bounding> -'; got : " << comma::join( unnamed, ' ' ) << std::endl; return 1; }
break;
default:
std::cerr << "csv-time-join: expected either '- <bounding>' or '<bounding> -'; got : " << comma::join( unnamed, ' ' ) << std::endl;
return 1;
}
comma::name_value::parser parser( "filename" );
bounding_csv = parser.get< comma::csv::options >( properties );
if( bounding_csv.fields.empty() ) { bounding_csv.fields = "t"; }
comma::csv::input_stream< Point > stdin_stream( std::cin, stdin_csv );
#ifdef WIN32
if( stdin_csv.binary() ) { _setmode( _fileno( stdout ), _O_BINARY ); }
#endif // #ifdef WIN32
comma::io::istream bounding_istream( comma::split( properties, ';' )[0]
, bounding_csv.binary() ? comma::io::mode::binary : comma::io::mode::ascii );
comma::csv::input_stream< Point > bounding_stream( *bounding_istream, bounding_csv );
#ifndef WIN32
comma::io::select select;
comma::io::select bounding_stream_select;
select.read().add( 0 );
select.read().add( bounding_istream.fd() );
bounding_stream_select.read().add( bounding_istream.fd() );
#endif // #ifndef WIN32
const Point* p = NULL;
if( method == how::realtime )
{
#ifndef WIN32
bool end_of_input = false;
bool end_of_bounds = false;
boost::optional<timestring_t> joined_line;
while (!is_shutdown && !end_of_input)
{
if ( !bounding_stream.ready() && !stdin_stream.ready() )
{
select.wait(boost::posix_time::milliseconds(1));
}
if ( !is_shutdown && !end_of_input && ( stdin_stream.ready() || ( select.check() && select.read().ready( comma::io::stdin_fd ) ) ) )
{
p = stdin_stream.read();
if( p )
{
timestring_t input_line = std::make_pair( get_time( *p ), stdin_stream.last() );
if( joined_line ) { output( input_line, *joined_line, stdin_first ); }
}
else
{
comma::verbose << "end of input stream" << std::endl;
end_of_input = true;
}
}
if ( !is_shutdown && !end_of_bounds &&
( bounding_stream.ready() || ( select.check() && select.read().ready( bounding_istream.fd() ))))
{
p = bounding_stream.read();
if( p )
//.........这里部分代码省略.........
示例8: 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; }
}
}
示例9:
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(); }
}
}
}
示例10: 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];
}
}
}
示例11: 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;
}
}
示例12: 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; }
}
}
}
示例13: 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;
}
}
示例14: 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();
}
示例15: 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;
}
}
}