string_vectorio.hpp

    1: #ifndef STRING_VECTORIO_HPP
    2: #define STRING_VECTORIO_HPP
    3: /*------------------------------------------------------------------------------
    4: 
    5:   Author:    Andy Rushton
    6:   Copyright: (c) Southampton University 1999-2004
    7:              (c) Andy Rushton           2004-2008
    8:   License:   BSD License, see ../docs/license.html
    9: 
   10:   Classes for redirecting I/O to/from a vector of strings
   11: 
   12:   ------------------------------------------------------------------------------*/
   13: #include "os_fixes.hpp"
   14: #include "textio.hpp"
   15: #include <string>
   16: #include <vector>
   17: 
   18: ////////////////////////////////////////////////////////////////////////////////
   19: // string-vector Output
   20: 
   21: class osvtext : public otext
   22: {
   23: public:
   24:   osvtext(void);
   25:   std::vector<std::string>& get_vector(void);
   26:   const std::vector<std::string>& get_vector(void) const;
   27: };
   28: 
   29: ////////////////////////////////////////////////////////////////////////////////
   30: // string-vector Input
   31: 
   32: class isvtext : public itext
   33: {
   34: public:
   35:   isvtext(const std::vector<std::string>& data);
   36:   std::vector<std::string>& get_vector(void);
   37:   const std::vector<std::string>& get_vector(void) const;
   38: };
   39: 
   40: ////////////////////////////////////////////////////////////////////////////////
   41: // Internal buffers
   42: 
   43: class osvbuff : public obuff
   44: {
   45: public:
   46:   osvbuff(void);
   47:   virtual unsigned put (unsigned char);
   48: 
   49: private:
   50:   friend class osvtext;
   51:   std::vector<std::string> m_data;
   52:   bool m_eoln;
   53: 
   54:   // make this class uncopyable
   55:   osvbuff(const osvbuff&);
   56:   osvbuff& operator = (const osvbuff&);
   57: };
   58: 
   59: class isvbuff : public ibuff
   60: {
   61: public:
   62:   isvbuff(const std::vector<std::string>& data);
   63:   virtual int peek (void);
   64:   virtual int get (void);
   65: 
   66: private:
   67:   friend class isvtext;
   68:   std::vector<std::string> m_data;
   69:   unsigned m_row, m_column;
   70: 
   71:   // make this class uncopyable
   72:   isvbuff(const isvbuff&);
   73:   isvbuff& operator = (const isvbuff&);
   74: };
   75: 
   76: ////////////////////////////////////////////////////////////////////////////////
   77: 
   78: #endif