unrar_err_t unrar_extract_custom( unrar_t* p, unrar_write_func user_write, void* user_data ) { assert( !unrar_done( p ) ); RETURN_ERR( NONLOCAL_ERROR( p ) ); if ( solid_file( p ) ) { unrar_pos_t pos = p->Arc.CurBlockPos; if ( p->solid_pos != pos ) { // Next file to solid extract isn't current one if ( p->solid_pos > pos ) RETURN_ERR( reopen( p ) ); else p->Arc.NextBlockPos = p->solid_pos; RETURN_ERR( next_( p, true ) ); // Keep extracting until solid position is at desired file while ( !p->done && p->solid_pos < pos ) { RETURN_ERR( skip_solid( p ) ); RETURN_ERR( next_( p, true ) ); } // Be sure we're at right file if ( p->solid_pos != pos || p->Arc.CurBlockPos != pos ) return unrar_err_corrupt; } } return extract_( p, user_write, user_data ); }
void operator() (mapbox::geometry::line_string<std::int64_t> & geom) { if (geom.size() <= 2) { next_(geom); } else { mapbox::geometry::line_string<std::int64_t> simplified; douglas_peucker(geom, std::back_inserter(simplified), simplify_distance_); next_(simplified); } }
unrar_err_t unrar_next( unrar_t* p ) { assert( !unrar_done( p ) ); RETURN_ERR( NONLOCAL_ERROR( p ) ); return next_( p, false ); }
// Called from each_neighbor_cyclic_loops in object_container.hpp. // Arguments are: // + i=iterator // + p=position_offset. inline result_type operator()(first_argument_type i, second_argument_type p) const { typename first_argument_type::reference item(*i); typename Toc_::mapped_type object = item.second; /* Todo. This doesn't work anymore if mapped_type is a cylinder. if (cmp_ == object) { // In case cmp_, the 'virtual' sphere', is actually an object in // our matrix (i.e the matrix also contains a sphere at the same // position and with the same radius as cmp), don't include it. return; } */ // Calculate distance from position of sphere to the shell of the ith // item. const double dist( // FIXME: something's wrong //const_cast<position<double>& >(cmp_.position) (object).calculateDistanceToSelfWithOffset(cmp_.origin, p)); if (dist < cmp_.size) { // If distance is within the radius of the sphere, add i to // collector. next_(i, dist); } // Else: object i is not within the radius of sphere cmp_. }
SegmentSeeker::cluster_map_t::iterator SegmentSeeker::add_cluster( KaxCluster * const p_cluster ) { Cluster cinfo = { /* fpos */ p_cluster->GetElementPosition(), /* pts */ mtime_t( p_cluster->GlobalTimecode() / INT64_C( 1000 ) ), /* duration */ mtime_t( -1 ), /* size */ p_cluster->GetEndPosition() - p_cluster->GetElementPosition() }; add_cluster_position( cinfo.fpos ); cluster_map_t::iterator it = _clusters.lower_bound( cinfo.pts ); if( it != _clusters.end() && it->second.pts == cinfo.pts ) { // cluster already known } else { it = _clusters.insert( cluster_map_t::value_type( cinfo.pts, cinfo ) ).first; } // ------------------------------------------------------------------ // IF we have two adjecent clusters, update duration where applicable // ------------------------------------------------------------------ struct Duration { static void fix( Cluster& prev, Cluster& next ) { if( ( prev.fpos + prev.size) == next.fpos ) prev.duration = next.pts - prev.pts; } }; if( it != _clusters.begin() ) { Duration::fix( prev_( it )->second, it->second ); } if( it != _clusters.end() && next_( it ) != _clusters.end() ) { Duration::fix( it->second, next_( it )->second ); } return it; }
PepIterator& FastaIterator::operator++() { if (last_header_ == "") { throw Exception::InvalidIterator(__FILE__, __LINE__, __PRETTY_FUNCTION__); } actual_seq_ = next_(); return *this; }
infinite& operator-=(const T& n) { if (n < 0) { next_(n); } if (n > 0) { prev_(-n); } return *this; }
void operator() (mapbox::geometry::polygon<std::int64_t> & geom) { mapbox::geometry::polygon<std::int64_t> simplified; for (auto const & g : geom) { if (g.size() <= 4) { simplified.push_back(g); } else { mapbox::geometry::linear_ring<std::int64_t> simplified_ring; douglas_peucker(g, std::back_inserter(simplified_ring), simplify_distance_); simplified.push_back(simplified_ring); } } next_(simplified); }
std::string FastaIterator::next_() { if (input_file_.eof()) { is_at_end_ = true; input_file_.close(); return ""; } is_at_end_ = false; std::string line; std::getline(input_file_, line); if (line[0] == '>' || input_file_.eof()) { last_header_ = header_; header_ = line; return ""; } return std::string(line) + next_(); }
unrar_err_t unrar_open_custom( unrar_t** impl_out, unrar_read_func read, void* user_data ) { *impl_out = NULL; unrar_ptr ptr; ptr.p = new unrar_t; if ( !ptr.p ) return unrar_err_memory; RETURN_ERR( NONLOCAL_ERROR( ptr.p ) ); RETURN_ERR( open_( ptr.p, read, user_data ) ); RETURN_ERR( next_( ptr.p, false ) ); *impl_out = ptr.p; ptr.p = NULL; //delete ptr.p; // done automatically at end of function return unrar_ok; }
bool FastaIterator::begin() { if (fasta_file_ == "") { throw Exception::InvalidIterator(__FILE__, __LINE__, __PRETTY_FUNCTION__); } input_file_.open(fasta_file_.c_str(), std::fstream::in); if (input_file_) { std::string line; std::getline(input_file_, line); header_ = line; last_header_ = line; actual_seq_ = next_(); return true; } return false; }
inline result_type operator()(argument_type i) const { typename argument_type::reference item(*i); /* Todo. This doesn't work anymore if mapped_type is a cylinder. if (cmp_ == item.second) { return; } */ typename Toc_::mapped_type object = item.second; const double dist( // FIXME: something's wrong //const_cast<position<double>& > (object).calculateDistanceToSelf(cmp_.origin)); if (dist < cmp_.size) { next_(i, dist); } }
blargg_err_t File_Extractor::seek_arc_v( fex_pos_t pos ) { // >= because seeking to current file should always reset read pointer etc. if ( tell_ >= pos ) RETURN_ERR( rewind() ); while ( tell_ < pos ) { RETURN_ERR( next_() ); if ( done() ) { assert( false ); return blargg_err_caller; } } assert( tell_ == pos ); return blargg_ok; }
SegmentSeeker::seekpoint_pair_t SegmentSeeker::get_seekpoints_around( mtime_t pts, seekpoints_t const& seekpoints, int trust_level ) { if( seekpoints.empty() ) { return seekpoint_pair_t(); } typedef seekpoints_t::const_iterator iterator; Seekpoint const needle ( Seekpoint::DISABLED, -1, pts ); iterator const it_begin = seekpoints.begin(); iterator const it_end = seekpoints.end(); iterator const it_middle = greatest_lower_bound( it_begin, it_end, needle ); iterator it_before; iterator it_after; // rewrind to _previous_ seekpoint with appropriate trust for( it_before = it_middle; it_before != it_begin; --it_before ) { if( it_before->trust_level >= trust_level ) break; } // forward to following seekpoint with appropriate trust for( it_after = next_( it_middle ); it_after != it_end; ++it_after ) { if( it_after->trust_level >= trust_level ) break; } return seekpoint_pair_t( *it_before, it_after == it_end ? Seekpoint() : *it_after ); }
blargg_err_t File_Extractor::next() { assert( !done() ); return next_(); }
infinite& operator+=(std::size_t n) { next_(n); return *this; }
void operator() (mapbox::geometry::multi_point<std::int64_t> & geom) { next_(geom); }