本文整理汇总了C++中comma::csv::options类的典型用法代码示例。如果您正苦于以下问题:C++ options类的具体用法?C++ options怎么用?C++ options使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了options类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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() );
}
}
开发者ID:acfr,项目名称:comma,代码行数:28,代码来源:csv-interval.cpp
示例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 ) );
}
}
开发者ID:akas9185,项目名称:snark,代码行数:17,代码来源:stereo.cpp
示例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; }
}
开发者ID:sheenzhaox,项目名称:comma,代码行数:18,代码来源:csv-interval.cpp
示例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() )
{
}
开发者ID:ahmmedshakil,项目名称:snark,代码行数:9,代码来源:disparity.cpp
示例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
}
开发者ID:Soumya-Saha,项目名称:snark,代码行数:18,代码来源:Reader.cpp
示例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;
}
开发者ID:Soumya-Saha,项目名称:snark,代码行数:19,代码来源:frame.cpp
示例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 )
//.........这里部分代码省略.........
开发者ID:acfr,项目名称:comma,代码行数:101,代码来源:csv-time-join.cpp
示例8: sort
int sort( const comma::command_line_options& options )
{
input_t::map sorted_map;
input_t default_input;
std::vector< std::string > v = comma::split( stdin_csv.fields, ',' );
std::vector< std::string > order = options.exists("--order") ? comma::split( options.value< std::string >( "--order" ), ',' ) : v;
std::vector< std::string > w (v.size());
bool unique = options.exists("--unique,-u");
std::string first_line;
comma::csv::format f;
if( stdin_csv.binary() ) { f = stdin_csv.format(); }
else if( options.exists( "--format" ) ) { f = comma::csv::format( options.value< std::string >( "--format" ) ); }
else
{
while( std::cin.good() && first_line.empty() ) { std::getline( std::cin, first_line ); }
if( first_line.empty() ) { return 0; }
f = comma::csv::impl::unstructured::guess_format( first_line, stdin_csv.delimiter );
if( verbose ) { std::cerr << "csv-sort: guessed format: " << f.string() << std::endl; }
}
for( std::size_t i = 0; i < order.size(); ++i ) // quick and dirty, wasteful, but who cares
{
if (order[i].empty()) continue;
for( std::size_t k = 0; k < v.size(); ++k )
{
if( v[k].empty() || v[k] != order[i] )
{
if ( k + 1 == v.size())
{
std::cerr << "csv-sort: order field name \"" << order[i] << "\" not found in input fields \"" << stdin_csv.fields << "\"" << std::endl;
return 1;
}
continue;
}
std::string type = default_input.keys.append( f.offset( k ).type );
w[k] = "keys/" + type;
ordering_t o;
if ( type[0] == 's' ) { o.type = ordering_t::str_type; o.index = default_input.keys.strings.size() - 1; }
else if ( type[0] == 'l' ) { o.type = ordering_t::long_type; o.index = default_input.keys.longs.size() - 1; }
else if ( type[0] == 'd' ) { o.type = ordering_t::double_type; o.index = default_input.keys.doubles.size() - 1; }
else if ( type[0] == 't' ) { o.type = ordering_t::time_type; o.index = default_input.keys.time.size() - 1; }
else { std::cerr << "csv-sort: cannot sort on field " << v[k] << " of type \"" << type << "\"" << std::endl; return 1; }
ordering.push_back(o);
break;
}
}
stdin_csv.fields = comma::join( w, ',' );
if ( verbose ) { std::cerr << "csv-sort: fields: " << stdin_csv.fields << std::endl; }
comma::csv::input_stream< input_t > stdin_stream( std::cin, stdin_csv, default_input );
#ifdef WIN32
if( stdin_stream.is_binary() ) { _setmode( _fileno( stdout ), _O_BINARY ); }
#endif
if (!first_line.empty())
{
input_t::map::mapped_type& d = sorted_map[ comma::csv::ascii< input_t >(stdin_csv,default_input).get(first_line) ];
d.push_back( first_line + "\n" );
}
while( stdin_stream.ready() || ( std::cin.good() && !std::cin.eof() ) )
{
const input_t* p = stdin_stream.read();
if( !p ) { break; }
if( stdin_stream.is_binary() )
{
input_t::map::mapped_type& d = sorted_map[ *p ];
if (unique && !d.empty()) continue;
d.push_back( std::string() );
d.back().resize( stdin_csv.format().size() );
::memcpy( &d.back()[0], stdin_stream.binary().last(), stdin_csv.format().size() );
}
else
{
input_t::map::mapped_type& d = sorted_map[ *p ];
if (unique && !d.empty()) continue;
d.push_back( comma::join( stdin_stream.ascii().last(), stdin_csv.delimiter ) + "\n" );
}
}
if( options.exists( "--reverse,-r" ) ) { output_( sorted_map.rbegin(), sorted_map.rend() ); }
else { output_( sorted_map.begin(), sorted_map.end() ); }
return 0;
}
开发者ID:sheenzhaox,项目名称:comma,代码行数:87,代码来源:csv-sort.cpp
示例9: main
int main( int ac, char** av )
{
try
{
comma::command_line_options options( ac, av );
if( options.exists( "--help,-h" ) ) { usage(); }
verbose = options.exists( "--verbose,-v" );
bool is_or = options.exists( "--or" );
csv = comma::csv::options( options );
fields = comma::split( csv.fields, ',' );
if( fields.size() == 1 && fields[0].empty() ) { fields.clear(); }
std::vector< std::string > unnamed = options.unnamed( "--first-matching,--or,--sorted,--input-sorted,--not-matching,--output-all,--all,--strict,--verbose,-v", "-.*" );
//for( unsigned int i = 0; i < unnamed.size(); constraints_map.insert( std::make_pair( comma::split( unnamed[i], ';' )[0], unnamed[i] ) ), ++i );
bool strict = options.exists( "--strict" );
bool first_matching = options.exists( "--first-matching" );
bool not_matching = options.exists( "--not-matching" );
bool all = options.exists( "--output-all,--all" );
for( unsigned int i = 0; i < unnamed.size(); ++i )
{
std::string field = comma::split( unnamed[i], ';' )[0];
bool found = false;
for( unsigned int j = 0; j < fields.size() && !found; found = field == fields[j], ++j );
if( !found )
{
if( strict ) { std::cerr << "csv-select: on constraint: \"" << unnamed[i] << "\" field \"" << field << "\" not found in fields: " << csv.fields << std::endl; return 1; }
std::cerr << "csv-select: warning: on constraint: \"" << unnamed[i] << "\" field \"" << field << "\" not found in fields: " << csv.fields << std::endl;
continue;
}
constraints_map.insert( std::make_pair( field, unnamed[i] ) );
}
comma::signal_flag is_shutdown;
if( csv.binary() )
{
#ifdef WIN32
_setmode( _fileno( stdout ), _O_BINARY );
#endif
init_input( csv.format(), options );
comma::csv::binary_input_stream< input_t > istream( std::cin, csv, input );
while( !is_shutdown && ( istream.ready() || ( std::cin.good() && !std::cin.eof() ) ) )
{
const input_t* p = istream.read();
if( !p || p->done( is_or ) ) { break; }
char match = ( p->is_a_match( is_or ) == !not_matching ) ? 1 : 0;
if( match || all )
{
std::cout.write( istream.last(), csv.format().size() );
if( all ) { std::cout.write( &match, 1 ); }
if( csv.flush ) { std::cout.flush(); }
if( first_matching ) { break; }
}
}
}
else
{
std::string line;
while( !is_shutdown && std::cin.good() && !std::cin.eof() )
{
std::getline( std::cin, line );
line = comma::strip( line, '\r' ); // windows, sigh...
if( !line.empty() ) { break; }
}
if( line.empty() ) { return 0; }
comma::csv::format format = options.exists( "--format" )
? comma::csv::format( options.value< std::string >( "--format" ) )
: guess_format( line );
init_input( format, options );
comma::csv::ascii_input_stream< input_t > istream( std::cin, csv, input );
// todo: quick and dirty: no time to debug why the commented section does not work (but that's the right way)
std::istringstream iss( line );
comma::csv::ascii_input_stream< input_t > isstream( iss, csv, input );
const input_t* p = isstream.read();
if( !p || p->done( is_or ) ) { return 0; }
bool match = p->is_a_match( is_or ) == !not_matching;
if( match || all )
{
std::cout << line;
if( all ) { std::cout << csv.delimiter << match; }
std::cout << std::endl;
if( first_matching ) { return 0; }
}
while( !is_shutdown && ( istream.ready() || ( std::cin.good() && !std::cin.eof() ) ) )
{
const input_t* p = istream.read();
if( !p || p->done( is_or ) ) { break; }
bool match = p->is_a_match( is_or ) == !not_matching;
if( match || all )
{
std::cout << comma::join( istream.last(), csv.delimiter );
if( all ) { std::cout << csv.delimiter << match; }
std::cout << std::endl;
if( first_matching ) { return 0; }
}
}
}
return 0;
}
catch( std::exception& ex ) { std::cerr << "csv-select: caught: " << ex.what() << std::endl; }
catch( ... ) { std::cerr << "csv-select: unknown exception" << std::endl; }
return 1;
}
开发者ID:sheenzhaox,项目名称:comma,代码行数:100,代码来源:csv-select.cpp
示例10: options
CameraReader::CameraReader( comma::csv::options& options )
: options( options )
, m_shutdown( false )
, m_istream( options.filename, options.binary() ? comma::io::mode::binary : comma::io::mode::ascii )
{
}
开发者ID:acfr,项目名称:snark,代码行数:6,代码来源:camera_reader.cpp
示例11: main
int main( int ac, char** av )
{
int result = 0;
try
{
comma::command_line_options options( ac, av );
if( options.exists( "--help,-h" ) ) { usage(); }
verbose = options.exists( "--verbose,-v" );
csv = comma::csv::options( options, "values" );
csv.full_xpath = true;
row_number_offset = options.value( "--row-number-offset,--offset", 0 );
polar = options.exists( "--polar" );
as_radians = !options.exists( "--degrees" );
clockwise = options.exists( "--clockwise" );
offset_from_center = options.value( "--offset-from-center", 0 ); // quick and dirty
z_up = options.value< std::string >( "--z", "up" ) == "up";
sign = ( z_up && !clockwise ) || ( !z_up && clockwise ) ? 1 : -1;
if( options.exists( "--fps" ) ) { dial_size = options.value( "--dial-size,--dial", 0 ); }
std::string s = options.value< std::string >( "--size" );
std::vector< std::string > v = comma::split( s, ',' );
if( v.size() != 2 && v.size() != 3 ) { std::cerr << "image-accumulate: expected --size=<value>; got \"" << s << "\"" << std::endl; return 1; }
block_size = boost::lexical_cast< unsigned int >( v[0] );
row_size = boost::lexical_cast< unsigned int >( v[1] );
scale = comma::csv::ascii< std::pair< double, double > >().get( options.value< std::string >( "--scale", "0,255" ) );
scaled< unsigned char > scaled( scale );
fps = options.optional< double >( "--fps" );
sin_cos = precomputed_sin_cos_();
channel::options default_channel_options( options );
std::vector< channel::options > channel_options;
if( csv.has_field( "id" ) )
{
const std::vector< std::string >& v = options.values< std::string >( "--id" );
if( v.empty() ) { std::cerr << "image-accumulate: 'id' field given, please specify at least one --id" << std::endl; return 1; }
for( unsigned int i = 0; i < v.size(); ++i )
{
channel_options.push_back( comma::name_value::parser( ';', '=' ).get< channel::options >( v[i], default_channel_options ) );
ids[ boost::lexical_cast< unsigned int >( comma::split( v[i], ';' )[0] ) ] = i;
}
}
else
{
ids[0] = 0;
channel_options.push_back( default_channel_options );
}
in.values.resize( row_size );
has_block = csv.has_field( "block" );
has_row = csv.has_field( "row" );
has_angle = csv.has_field( "angle" );
if( has_row && has_angle ) { std::cerr << "image-accumulate: in input fields, expected either 'row' or 'angle'; got both" << std::endl; return 1; }
comma::csv::input_stream< input > istream( std::cin, csv, in ); // todo: watch performance!
std::string default_output_options = "no-header;rows=" + boost::lexical_cast< std::string >( polar ? row_size * 2 + 1 : block_size ) + ";cols=" + boost::lexical_cast< std::string >( polar ? ( row_size * 2 + 1 ) * ids.size() : row_size * ids.size() ) + ";type=3ub";
std::string output_options_string = options.value( "--output", default_output_options );
output_options = comma::name_value::parser( ';', '=' ).get< snark::cv_mat::serialization::options >( output_options_string );
if( options.exists( "--output-options" ) ) { std::cout << comma::name_value::parser( ';', '=' ).put< snark::cv_mat::serialization::options >( output_options ) << std::endl; return 0; }
serialization.reset( new snark::cv_mat::serialization( output_options ) );
image = cv::Mat::zeros( block_size, row_size * ids.size(), output_options.get_header().type );
pixel_size = output_options.get_header().type == CV_8UC3 ? 3 : 1; // quick and dirty
boost::ptr_vector< channel > channels;
for( unsigned int i = 0; i < ids.size(); ++i ) { channels.push_back( new channel( i, channel_options[i] ) ); }
if( fps ) { output_thread.reset( new boost::thread( &output_ ) ); }
while( !is_shutdown && std::cin.good() && !std::cin.eof() )
{
const input* p = istream.read();
if( p )
{
Ids::const_iterator it = ids.find( p->id );
if( it == ids.end() ) { continue; }
if( !channels[ it->second ].draw( p ) ) { break; }
}
else
{
for( Ids::const_iterator it = ids.begin(); it != ids.end(); ++it )
{
channels[ it->second ].draw( p );
}
break;
}
}
}
catch( std::exception& ex )
{
std::cerr << "image-accumulate: " << ex.what() << std::endl;
result = 1;
}
catch( ... )
{
std::cerr << "image-accumulate: unknown exception" << std::endl;
result = 1;
}
done = true;
if( fps ) { output_thread->join(); }
return result;
}
开发者ID:acfr,项目名称:snark,代码行数:93,代码来源:image-accumulate.cpp
示例12: 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; }
}
}
开发者ID:bigjun,项目名称:snark,代码行数:25,代码来源:points-calc.cpp
示例13:
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(); }
}
}
}
开发者ID:sheenzhaox,项目名称:comma,代码行数:11,代码来源:csv-sort.cpp
示例14: 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];
}
}
}
开发者ID:acfr,项目名称:snark,代码行数:50,代码来源:points-foreground-partitions.cpp
示例15: 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;
}
}
开发者ID:bigjun,项目名称:snark,代码行数:25,代码来源:points-calc.cpp
示例16: 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; }
}
}
}
开发者ID:acfr,项目名称:comma,代码行数:26,代码来源:csv-time-join.cpp
示例17: 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;
}
}
开发者ID:bigjun,项目名称:snark,代码行数:13,代码来源:points-calc.cpp
示例18: 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();
}
开发者ID:sheenzhaox,项目名称:comma,代码行数:51,代码来源:csv-interval.cpp
示例19: 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;
}
}
}
开发者ID:bigjun,项目名称:snark,代码行数:19,代码来源:points-calc.cpp
-
六六分期app的软件客服如何联系?不知道吗?加qq群【895510560】即可!标题:六六分期
阅读:18213|2023-10-27
-
今天小编告诉大家如何处理win10系统火狐flash插件总是崩溃的问题,可能很多用户都不知
阅读:9656|2022-11-06
-
今天小编告诉大家如何对win10系统删除桌面回收站图标进行设置,可能很多用户都不知道
阅读:8168|2022-11-06
-
今天小编告诉大家如何对win10系统电脑设置节能降温的设置方法,想必大家都遇到过需要
阅读:8543|2022-11-06
-
我们在使用xp系统的过程中,经常需要对xp系统无线网络安装向导设置进行设置,可能很多
阅读:8449|2022-11-06
-
今天小编告诉大家如何处理win7系统玩cf老是与主机连接不稳定的问题,可能很多用户都不
阅读:9375|2022-11-06
-
电脑对日常生活的重要性小编就不多说了,可是一旦碰到win7系统设置cf烟雾头的问题,很
阅读:8418|2022-11-06
-
我们在日常使用电脑的时候,有的小伙伴们可能在打开应用的时候会遇见提示应用程序无法
阅读:7855|2022-11-06
-
今天小编告诉大家如何对win7系统打开vcf文件进行设置,可能很多用户都不知道怎么对win
阅读:8403|2022-11-06
-
今天小编告诉大家如何对win10系统s4开启USB调试模式进行设置,可能很多用户都不知道怎
阅读:7391|2022-11-06
|
请发表评论