Kashub's Code Barn - "ioformat "

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

Twoja wyszukiwarka
T-Mobile
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 | | Opony motocyklowe | | Opony zimowe | | Kamery IP sklep | | karma dla psa - sklep | | Blogi za darmo | | Wklejacz kodów | | Skróć link | | Opisy GG |