Moses::FileHandler Class Reference

#include <FileHandler.h>

Collaboration diagram for Moses::FileHandler:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 FileHandler (const std::string &path, std::ios_base::openmode flags=std::ios::in, bool checkExists=true)
 ~FileHandler ()
std::string getPath ()
std::ios_base::openmode getFlags ()
bool isStdIn ()
bool isStdOut ()
bool reset ()

Static Public Member Functions

static bool getCompressionCmds (const std::string &filepath, std::string &compressionCmd, std::string &decompressionCmd, std::string &compressionSuffix)

Static Public Attributes

static const std::string kStdInDescriptor = "___stdin___"
static const std::string kStdOutDescriptor = "___stdout___"
static const std::string kCatCommand = "cat"
static const std::string kGzipCommand = "gzip -f"
static const std::string kGunzipCommand = "gunzip -f"
static const std::string kBzip2Command = "bzip2 -f"
static const std::string kBunzip2Command = "bunzip2 -f"

Protected Member Functions

bool fileExists ()
bool setStreamBuffer (bool checkExists)
bool isCompressedFile (std::string &cmd)
fdstreambufopenCompressedFile (const char *cmd)

Protected Attributes

std::string path_
std::ios_base::openmode flags_
std::streambuf * buffer_
std::FILE * fp_

Static Protected Attributes

static const FileExtension kGzipped = ".gz"
static const FileExtension kBzipped2 = ".bz2"


Detailed Description

Todo:
ask abby2

Definition at line 19 of file FileHandler.h.


Constructor & Destructor Documentation

Moses::FileHandler::FileHandler ( const std::string &  path,
std::ios_base::openmode  flags = std::ios::in,
bool  checkExists = true 
)

Definition at line 25 of file FileHandler.cpp.

References CHECK, path_, and setStreamBuffer().

Here is the call graph for this function:

Moses::FileHandler::~FileHandler (  ) 

Definition at line 38 of file FileHandler.cpp.

References buffer_, fp_, kStdInDescriptor, kStdOutDescriptor, path_, and pclose().

Here is the call graph for this function:


Member Function Documentation

bool Moses::FileHandler::fileExists (  )  [protected]

Definition at line 131 of file FileHandler.cpp.

References path_.

Referenced by setStreamBuffer().

Here is the caller graph for this function:

bool Moses::FileHandler::getCompressionCmds ( const std::string &  filepath,
std::string &  compressionCmd,
std::string &  decompressionCmd,
std::string &  compressionSuffix 
) [static]

std::ios_base::openmode Moses::FileHandler::getFlags (  )  [inline]

Definition at line 47 of file FileHandler.h.

References flags_.

std::string Moses::FileHandler::getPath (  )  [inline]

Definition at line 44 of file FileHandler.h.

References path_.

bool Moses::FileHandler::isCompressedFile ( std::string &  cmd  )  [protected]

Definition at line 109 of file FileHandler.cpp.

References flags_, kBunzip2Command, kBzip2Command, kBzipped2, kGunzipCommand, kGzipCommand, kGzipped, and path_.

Referenced by reset(), and setStreamBuffer().

Here is the caller graph for this function:

bool Moses::FileHandler::isStdIn (  )  [inline]

Definition at line 50 of file FileHandler.h.

References kStdInDescriptor, and path_.

bool Moses::FileHandler::isStdOut (  )  [inline]

Definition at line 53 of file FileHandler.h.

References kStdOutDescriptor, and path_.

fdstreambuf * Moses::FileHandler::openCompressedFile ( const char *  cmd  )  [protected]

Definition at line 51 of file FileHandler.cpp.

References flags_, fp_, NULL, and popen().

Referenced by reset(), and setStreamBuffer().

Here is the call graph for this function:

Here is the caller graph for this function:

bool Moses::FileHandler::reset (  ) 

Definition at line 165 of file FileHandler.cpp.

References buffer_, fp_, init(), isCompressedFile(), openCompressedFile(), and pclose().

Here is the call graph for this function:

bool Moses::FileHandler::setStreamBuffer ( bool  checkExists  )  [protected]

Definition at line 70 of file FileHandler.cpp.

References buffer_, CHECK, fileExists(), flags_, init(), isCompressedFile(), kStdInDescriptor, kStdOutDescriptor, openCompressedFile(), and path_.

Referenced by FileHandler().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

std::streambuf* Moses::FileHandler::buffer_ [protected]

Definition at line 66 of file FileHandler.h.

Referenced by reset(), setStreamBuffer(), and ~FileHandler().

std::ios_base::openmode Moses::FileHandler::flags_ [protected]

Definition at line 65 of file FileHandler.h.

Referenced by getFlags(), isCompressedFile(), openCompressedFile(), and setStreamBuffer().

std::FILE* Moses::FileHandler::fp_ [protected]

Definition at line 67 of file FileHandler.h.

Referenced by openCompressedFile(), reset(), and ~FileHandler().

const std::string Moses::FileHandler::kBunzip2Command = "bunzip2 -f" [static]

Definition at line 30 of file FileHandler.h.

Referenced by getCompressionCmds(), and isCompressedFile().

const std::string Moses::FileHandler::kBzip2Command = "bzip2 -f" [static]

Definition at line 29 of file FileHandler.h.

Referenced by getCompressionCmds(), and isCompressedFile().

const FileExtension Moses::FileHandler::kBzipped2 = ".bz2" [static, protected]

Definition at line 59 of file FileHandler.h.

Referenced by getCompressionCmds(), and isCompressedFile().

const std::string Moses::FileHandler::kCatCommand = "cat" [static]

Definition at line 26 of file FileHandler.h.

Referenced by getCompressionCmds().

const std::string Moses::FileHandler::kGunzipCommand = "gunzip -f" [static]

Definition at line 28 of file FileHandler.h.

Referenced by getCompressionCmds(), and isCompressedFile().

const std::string Moses::FileHandler::kGzipCommand = "gzip -f" [static]

Definition at line 27 of file FileHandler.h.

Referenced by getCompressionCmds(), and isCompressedFile().

const FileExtension Moses::FileHandler::kGzipped = ".gz" [static, protected]

Definition at line 58 of file FileHandler.h.

Referenced by getCompressionCmds(), and isCompressedFile().

const std::string Moses::FileHandler::kStdInDescriptor = "___stdin___" [static]

Definition at line 23 of file FileHandler.h.

Referenced by isStdIn(), setStreamBuffer(), and ~FileHandler().

const std::string Moses::FileHandler::kStdOutDescriptor = "___stdout___" [static]

Definition at line 24 of file FileHandler.h.

Referenced by isStdOut(), setStreamBuffer(), and ~FileHandler().

std::string Moses::FileHandler::path_ [protected]


The documentation for this class was generated from the following files:

Generated on Fri Oct 31 00:31:52 2014 for Moses by  doxygen 1.5.9