Public Member Functions | Private Member Functions | Private Attributes

blk_StdIOReader Class Reference
[IVD Data format.]

#include <df.h>

Inheritance diagram for blk_StdIOReader:
Inheritance graph
[legend]
Collaboration diagram for blk_StdIOReader:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 blk_StdIOReader (df_BlockManager &a_mgr, const string &a_fName)
virtual ~blk_StdIOReader ()

Private Member Functions

virtual UInt32_t Read (UInt8_t *a_data, const UInt32_t a_size)

Private Attributes

 log_CLASSID_m
int m_fHandle

Detailed Description

Definition at line 552 of file df.h.


Constructor & Destructor Documentation

blk_StdIOReader::blk_StdIOReader ( df_BlockManager a_mgr,
const string &  a_fName 
)

Definition at line 58 of file blk_stdioreader.cpp.

References dbg_NORM, errno, log_DBG_m, log_FUNC_A_m, m_fHandle, and O_BINARY.

    : blk_BufferReader(a_mgr) {

    log_FUNC_A_m(blk_StdIOReader, "fName=" << a_fName);

    if (a_fName.empty()) {
        log_DBG_m(dbg_NORM, "Using stdin for DF input");
        m_fHandle = dup(fileno(stdin));
        if (m_fHandle == -1) {
            throw ivd_SysError(errno, "dup()", true);
        }
#if TGT_OS_windows
        setmode(m_fHandle, O_BINARY);
#endif
    }
    else {
        m_fHandle = open(a_fName.c_str(), O_RDONLY | O_BINARY);
        if (m_fHandle == -1) {
           throw ivd_SysError(errno, "open()", true);
        }
    }
}

blk_StdIOReader::~blk_StdIOReader (  )  [virtual]

Definition at line 83 of file blk_stdioreader.cpp.

References errno, log_ERR_m, log_FUNC_m, and m_fHandle.

                                  {
    log_FUNC_m(~blk_StdIOReader);

    /* if (m_fHandle != stdin) */ {
        if (close(m_fHandle) != 0) {
           log_ERR_m(
                "close() failed. Ignored. Error: " << errno);
        }
    }
}


Member Function Documentation

UInt32_t blk_StdIOReader::Read ( UInt8_t a_data,
const UInt32_t  a_size 
) [private, virtual]

Implements blk_BufferReader.

Definition at line 94 of file blk_stdioreader.cpp.

References errno, log_FUNC_m, and m_fHandle.

                                                                     {
    log_FUNC_m(Read);

    Int32_t bytesRead = read(m_fHandle, a_data, a_size);
    if (bytesRead == -1) {
        throw ivd_SysError(errno, "read()", true);
    }
    return bytesRead;
}


Member Data Documentation

Reimplemented from blk_BufferReader.

Definition at line 563 of file df.h.

Definition at line 565 of file df.h.

Referenced by blk_StdIOReader(), Read(), and ~blk_StdIOReader().


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