g4tools  5.4.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tools::FILE_reader Class Reference
Inheritance diagram for tools::FILE_reader:
Inheritance graph
[legend]
Collaboration diagram for tools::FILE_reader:
Collaboration graph
[legend]

Public Member Functions

virtual bool open (const std::string &a_file)
 
virtual void close ()
 
virtual bool is_open () const
 
virtual bool read (char *a_buff, unsigned int a_lbuf, size_t &a_length)
 
virtual bool get_line (char *a_buff, unsigned int a_lbuf)
 
virtual bool eof () const
 
 FILE_reader ()
 
virtual ~FILE_reader ()
 
- Public Member Functions inherited from tools::file::reader
virtual ~reader ()
 

Protected Member Functions

 FILE_reader (const FILE_reader &a_from)
 
FILE_readeroperator= (const FILE_reader &)
 

Protected Attributes

FILE * m_FILE
 

Detailed Description

Definition at line 594 of file file.

Constructor & Destructor Documentation

◆ FILE_reader() [1/2]

tools::FILE_reader::FILE_reader ( )
inline

Definition at line 623 of file file.

623 :m_FILE(0){}

◆ ~FILE_reader()

virtual tools::FILE_reader::~FILE_reader ( )
inlinevirtual

Definition at line 624 of file file.

624 {if(m_FILE) ::fclose(m_FILE);}

◆ FILE_reader() [2/2]

tools::FILE_reader::FILE_reader ( const FILE_reader a_from)
inlineprotected

Definition at line 626 of file file.

627  :file::reader(a_from)
628  ,m_FILE(0)
629  {}

Member Function Documentation

◆ close()

virtual void tools::FILE_reader::close ( )
inlinevirtual

Implements tools::file::reader.

Definition at line 602 of file file.

602  {
603  if(!m_FILE) return;
604  ::fclose(m_FILE);
605  m_FILE = 0;
606  }

◆ eof()

virtual bool tools::FILE_reader::eof ( ) const
inlinevirtual

Implements tools::file::reader.

Definition at line 615 of file file.

615  {
616 #if defined(_MSC_VER) && _MSC_VER <= 1400
617  return feof(m_FILE)?true:false;
618 #else
619  return ::feof(m_FILE)?true:false;
620 #endif
621  }

◆ get_line()

virtual bool tools::FILE_reader::get_line ( char *  a_buff,
unsigned int  a_lbuf 
)
inlinevirtual

Implements tools::file::reader.

Definition at line 612 of file file.

612  {
613  return ::fgets(a_buff,a_lbuf,m_FILE)==NULL?false:true;
614  }

◆ is_open()

virtual bool tools::FILE_reader::is_open ( ) const
inlinevirtual

Implements tools::file::reader.

Definition at line 607 of file file.

607 {return m_FILE?true:false;}

◆ open()

virtual bool tools::FILE_reader::open ( const std::string &  a_file)
inlinevirtual

Implements tools::file::reader.

Definition at line 596 of file file.

596  {
597  if(m_FILE) return false;
598  m_FILE = ::fopen(a_file.c_str(),"rb");
599  if(!m_FILE) return false;
600  return true;
601  }

◆ operator=()

FILE_reader& tools::FILE_reader::operator= ( const FILE_reader )
inlineprotected

Definition at line 630 of file file.

630 {return *this;}

◆ read()

virtual bool tools::FILE_reader::read ( char *  a_buff,
unsigned int  a_lbuf,
size_t &  a_length 
)
inlinevirtual

Implements tools::file::reader.

Definition at line 608 of file file.

608  {
609  a_length = ::fread(a_buff,1,a_lbuf,m_FILE);
610  return true;
611  }

Member Data Documentation

◆ m_FILE

FILE* tools::FILE_reader::m_FILE
protected

Definition at line 632 of file file.


The documentation for this class was generated from the following file:
tools::image::reader
unsigned char *(* reader)(FILE *, unsigned int &, unsigned int &)
Definition: image:200
tools::FILE_reader::m_FILE
FILE * m_FILE
Definition: file:632