inline static void init( comma::csv::options& csv_options, const comma::command_line_options& options, const std::string& defaultFields ) { csv_options.full_xpath = options.exists( "--full-xpath" ); csv_options.fields = options.value( "--fields", defaultFields ); if( options.exists( "--binary" ) ) { boost::optional< std::string > format = options.optional< std::string >( "--binary" ); if( format ) { csv_options.format( options.value< std::string >( "--binary" ) ); } } csv_options.precision = options.value< unsigned int >( "--precision", 12 ); csv_options.delimiter = options.exists( "--delimiter" ) ? options.value( "--delimiter", ',' ) : options.value( "-d", ',' ); boost::optional< std::string > quote_character = options.optional< std::string >( "--quote" ); if( quote_character ) { switch( quote_character->size() ) { case 0: csv_options.quote.reset(); break; case 1: csv_options.quote = ( *quote_character )[0]; break; case 2: COMMA_THROW( comma::exception, "expected a quote character, got \"" << *quote_character << "\"" ); } } csv_options.flush = options.exists( "--flush" ); }
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() ); } }