KiCad PCB EDA Suite
RTFileStream Class Reference

#include <rtree.h>

Public Member Functions

 RTFileStream ()
 
 ~RTFileStream ()
 
bool OpenRead (const char *a_fileName)
 
bool OpenWrite (const char *a_fileName)
 
void Close ()
 
template<typename TYPE >
size_t Write (const TYPE &a_value)
 
template<typename TYPE >
size_t WriteArray (const TYPE *a_array, int a_count)
 
template<typename TYPE >
size_t Read (TYPE &a_value)
 
template<typename TYPE >
size_t ReadArray (TYPE *a_array, int a_count)
 

Private Attributes

FILE * m_file
 

Detailed Description

Definition at line 524 of file rtree.h.

Constructor & Destructor Documentation

◆ RTFileStream()

RTFileStream::RTFileStream ( )
inline

Definition at line 530 of file rtree.h.

531  {
532  m_file = NULL;
533  }
FILE * m_file
Definition: rtree.h:526

References m_file.

◆ ~RTFileStream()

RTFileStream::~RTFileStream ( )
inline

Definition at line 535 of file rtree.h.

536  {
537  Close();
538  }
void Close()
Definition: rtree.h:564

References Close().

Member Function Documentation

◆ Close()

void RTFileStream::Close ( )
inline

Definition at line 564 of file rtree.h.

565  {
566  if( m_file )
567  {
568  fclose( m_file );
569  m_file = NULL;
570  }
571  }
FILE * m_file
Definition: rtree.h:526

References m_file.

Referenced by ~RTFileStream().

◆ OpenRead()

bool RTFileStream::OpenRead ( const char *  a_fileName)
inline

Definition at line 540 of file rtree.h.

541  {
542  m_file = fopen( a_fileName, "rb" );
543 
544  if( !m_file )
545  {
546  return false;
547  }
548 
549  return true;
550  }
FILE * m_file
Definition: rtree.h:526

References m_file.

◆ OpenWrite()

bool RTFileStream::OpenWrite ( const char *  a_fileName)
inline

Definition at line 552 of file rtree.h.

553  {
554  m_file = fopen( a_fileName, "wb" );
555 
556  if( !m_file )
557  {
558  return false;
559  }
560 
561  return true;
562  }
FILE * m_file
Definition: rtree.h:526

References m_file.

◆ Read()

template<typename TYPE >
size_t RTFileStream::Read ( TYPE &  a_value)
inline

Definition at line 588 of file rtree.h.

589  {
590  ASSERT( m_file );
591  return fread( (void*) &a_value, sizeof(a_value), 1, m_file );
592  }
FILE * m_file
Definition: rtree.h:526
#define ASSERT
Definition: rtree.h:36

References ASSERT, and m_file.

◆ ReadArray()

template<typename TYPE >
size_t RTFileStream::ReadArray ( TYPE *  a_array,
int  a_count 
)
inline

Definition at line 595 of file rtree.h.

596  {
597  ASSERT( m_file );
598  return fread( (void*) a_array, sizeof(TYPE) * a_count, 1, m_file );
599  }
FILE * m_file
Definition: rtree.h:526
#define ASSERT
Definition: rtree.h:36

References ASSERT, and m_file.

◆ Write()

template<typename TYPE >
size_t RTFileStream::Write ( const TYPE &  a_value)
inline

Definition at line 574 of file rtree.h.

575  {
576  ASSERT( m_file );
577  return fwrite( (void*) &a_value, sizeof(a_value), 1, m_file );
578  }
FILE * m_file
Definition: rtree.h:526
#define ASSERT
Definition: rtree.h:36

References ASSERT, and m_file.

◆ WriteArray()

template<typename TYPE >
size_t RTFileStream::WriteArray ( const TYPE *  a_array,
int  a_count 
)
inline

Definition at line 581 of file rtree.h.

582  {
583  ASSERT( m_file );
584  return fwrite( (void*) a_array, sizeof(TYPE) * a_count, 1, m_file );
585  }
FILE * m_file
Definition: rtree.h:526
#define ASSERT
Definition: rtree.h:36

References ASSERT, and m_file.

Member Data Documentation

◆ m_file

FILE* RTFileStream::m_file
private

Definition at line 526 of file rtree.h.

Referenced by Close(), OpenRead(), OpenWrite(), Read(), ReadArray(), RTFileStream(), Write(), and WriteArray().


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