Joshua
open source statistical hierarchical phrase-based machine translation system
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
util::FilePiece Class Reference

#include <file_piece.hh>

Collaboration diagram for util::FilePiece:
[legend]

List of all members.

Public Member Functions

 FilePiece (const char *file, std::ostream *show_progress=NULL, off_t min_buffer=33554432)
 FilePiece (int fd, const char *name, std::ostream *show_progress=NULL, off_t min_buffer=33554432)
 ~FilePiece ()
char get ()
StringPiece ReadDelimited (const bool *delim=kSpaces)
StringPiece ReadLine (char delim= '\n')
float ReadFloat ()
double ReadDouble ()
long int ReadLong ()
unsigned long int ReadULong ()
void SkipSpaces (const bool *delim=kSpaces)
off_t Offset () const
const std::string & FileName () const

Private Member Functions

void Initialize (const char *name, std::ostream *show_progress, off_t min_buffer)
template<class T >
ReadNumber ()
StringPiece Consume (const char *to)
const char * FindDelimiterOrEOF (const bool *delim=kSpaces)
void Shift ()
void MMapShift (off_t desired_begin)
void TransitionToRead ()
void ReadShift ()

Private Attributes

const char * position_
const char * last_space_
const char * position_end_
scoped_fd file_
const off_t total_size_
const off_t page_
size_t default_map_size_
off_t mapped_offset_
scoped_memory data_
bool at_end_
bool fallback_to_read_
ErsatzProgress progress_
std::string file_name_

Constructor & Destructor Documentation

util::FilePiece::FilePiece ( const char *  file,
std::ostream *  show_progress = NULL,
off_t  min_buffer = 33554432 
) [explicit]

Here is the call graph for this function:

util::FilePiece::FilePiece ( int  fd,
const char *  name,
std::ostream *  show_progress = NULL,
off_t  min_buffer = 33554432 
) [explicit]

Here is the call graph for this function:

Here is the call graph for this function:


Member Function Documentation

StringPiece util::FilePiece::Consume ( const char *  to) [private]

Here is the caller graph for this function:

const std::string& util::FilePiece::FileName ( ) const

Here is the caller graph for this function:

const char * util::FilePiece::FindDelimiterOrEOF ( const bool *  delim = kSpaces) [private]

Here is the call graph for this function:

Here is the caller graph for this function:

Here is the call graph for this function:

Here is the caller graph for this function:

void util::FilePiece::Initialize ( const char *  name,
std::ostream *  show_progress,
off_t  min_buffer 
) [private]

Here is the call graph for this function:

Here is the caller graph for this function:

void util::FilePiece::MMapShift ( off_t  desired_begin) [private]

Here is the call graph for this function:

Here is the caller graph for this function:

off_t util::FilePiece::Offset ( ) const

Here is the call graph for this function:

Here is the caller graph for this function:

Here is the call graph for this function:

Here is the caller graph for this function:

Here is the caller graph for this function:

StringPiece util::FilePiece::ReadLine ( char  delim = '\n')

Here is the call graph for this function:

Here is the caller graph for this function:

template<class T >
T util::FilePiece::ReadNumber ( ) [private]

Here is the call graph for this function:

void util::FilePiece::ReadShift ( ) [private]

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned long int util::FilePiece::ReadULong ( )
void util::FilePiece::Shift ( ) [private]

Here is the call graph for this function:

Here is the caller graph for this function:

void util::FilePiece::SkipSpaces ( const bool *  delim = kSpaces)

Here is the call graph for this function:

Here is the caller graph for this function:

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

bool util::FilePiece::at_end_ [private]
std::string util::FilePiece::file_name_ [private]
const char * util::FilePiece::last_space_ [private]
const off_t util::FilePiece::page_ [private]
const char* util::FilePiece::position_ [private]
const char * util::FilePiece::position_end_ [private]
const off_t util::FilePiece::total_size_ [private]