Kashub's Code Barn - "ioformat "

podświetlone jako sql (dodał(a) xmoon @ 2009-09-28 17:02:07)

Twoja wyszukiwarka
Podświetl ten kod w:
Ostatnio dodane:
Losowe wpisy:
#ifndef IOFORMAT_H
#define IOFORMAT_H
 
#include <fstream>
 
namespace seelib{
  // classes USING strategy pattern
  // strategy
 
  USING std::ofstream;
  USING std::ifstream;
 
  class format_io{
    public:
      format_io(ofstream * ofs):fout(ofs){}
      format_io(ifstream * ifs):fin(ifs){}
      void set_out(ofstream * ofs){
        fout = ofs; // SET NEW output stream
      }
      void set_in(ifstream * ifs){
        fin = ifs; // SET NEW INPUT stream
      }
      // TODO: correct this declarations
      // method templates cannot be virtual...
      // WRITE FIELD 
      template <class T>
      virtual format_io & operator<<(T & VALUE) = 0;
      // READ FIELD
      template <class T>
      virtual format_io & operator>>(T & VALUE) = 0;
    private:
 
      ofstream * fout;
      ifstream * fin;
  };
 
  // concrete strategy
  class text_format: public format_io{
    public:
      template <class T>
      virtual format_io & operator<<(T & VALUE);
      template <class T>
      virtual format_io & operator>>(T & VALUE);
  };
 
  // concrete strategy
  class xml_format: public format_io{
    public:
      template <class T>
      virtual format_io & operator<<(T & VALUE);
      template <class T>
      virtual format_io & operator>>(T & VALUE);
    private:
      bool _created;
  };
 
  // concrete strategy
  class bin_format: public format_io{
    public:
      template <class T>
      virtual format_io & operator<<(T & VALUE);
      template <class T>
      virtual format_io & operator>>(T & VALUE);
  };
 
}
#endif
 
| Katalog Sklepów internetowych | | Sklep z artykułami dla dzieci | | Sklep z oponami | | Opony motocyklowe | | Blogi za darmo | | Załóż za darmo bloga | | Kody programów | | Skróć link | | Gnieżdżewo | | Opisy na Facebooka |