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 529 of file rtree.h.

Constructor & Destructor Documentation

RTFileStream::RTFileStream ( )
inline

Definition at line 535 of file rtree.h.

536  {
537  m_file = NULL;
538  }
FILE * m_file
Definition: rtree.h:531
RTFileStream::~RTFileStream ( )
inline

Definition at line 540 of file rtree.h.

References Close().

541  {
542  Close();
543  }
void Close()
Definition: rtree.h:569

Member Function Documentation

void RTFileStream::Close ( )
inline

Definition at line 569 of file rtree.h.

Referenced by ~RTFileStream().

570  {
571  if( m_file )
572  {
573  fclose( m_file );
574  m_file = NULL;
575  }
576  }
FILE * m_file
Definition: rtree.h:531
bool RTFileStream::OpenRead ( const char *  a_fileName)
inline

Definition at line 545 of file rtree.h.

546  {
547  m_file = fopen( a_fileName, "rb" );
548 
549  if( !m_file )
550  {
551  return false;
552  }
553 
554  return true;
555  }
FILE * m_file
Definition: rtree.h:531
bool RTFileStream::OpenWrite ( const char *  a_fileName)
inline

Definition at line 557 of file rtree.h.

558  {
559  m_file = fopen( a_fileName, "wb" );
560 
561  if( !m_file )
562  {
563  return false;
564  }
565 
566  return true;
567  }
FILE * m_file
Definition: rtree.h:531
template<typename TYPE >
size_t RTFileStream::Read ( TYPE &  a_value)
inline

Definition at line 593 of file rtree.h.

References ASSERT.

594  {
595  ASSERT( m_file );
596  return fread( (void*) &a_value, sizeof(a_value), 1, m_file );
597  }
FILE * m_file
Definition: rtree.h:531
#define ASSERT
Definition: rtree.h:33
template<typename TYPE >
size_t RTFileStream::ReadArray ( TYPE *  a_array,
int  a_count 
)
inline

Definition at line 600 of file rtree.h.

References ASSERT.

601  {
602  ASSERT( m_file );
603  return fread( (void*) a_array, sizeof(TYPE) * a_count, 1, m_file );
604  }
FILE * m_file
Definition: rtree.h:531
#define ASSERT
Definition: rtree.h:33
template<typename TYPE >
size_t RTFileStream::Write ( const TYPE &  a_value)
inline

Definition at line 579 of file rtree.h.

References ASSERT.

580  {
581  ASSERT( m_file );
582  return fwrite( (void*) &a_value, sizeof(a_value), 1, m_file );
583  }
FILE * m_file
Definition: rtree.h:531
#define ASSERT
Definition: rtree.h:33
template<typename TYPE >
size_t RTFileStream::WriteArray ( const TYPE *  a_array,
int  a_count 
)
inline

Definition at line 586 of file rtree.h.

References ASSERT.

587  {
588  ASSERT( m_file );
589  return fwrite( (void*) a_array, sizeof(TYPE) * a_count, 1, m_file );
590  }
FILE * m_file
Definition: rtree.h:531
#define ASSERT
Definition: rtree.h:33

Member Data Documentation

FILE* RTFileStream::m_file
private

Definition at line 531 of file rtree.h.


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