STK++ 1.0
STK_ReadWritePages.h
Go to the documentation of this file.
00001 /*--------------------------------------------------------------------*/
00002 /*     Copyright (C) 2004-2010  Serge Iovleff
00003 
00004  This program is free software; you can redistribute it and/or modify
00005  it under the terms of the GNU Lesser General Public License as
00006  published by the Free Software Foundation; either version 2 of the
00007  License, or (at your option) any later version.
00008 
00009  This program is distributed in the hope that it will be useful,
00010  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  GNU Lesser General Public License for more details.
00013 
00014  You should have received a copy of the GNU Lesser General Public
00015  License along with this program; if not, write to the
00016  Free Software Foundation, Inc.,
00017  59 Temple Place,
00018  Suite 330,
00019  Boston, MA 02111-1307
00020  USA
00021 
00022  Contact : Serge.Iovleff@stkpp.org
00023  */
00024 
00025 /*
00026  * Project:  stkpp::DManager
00027  * created on: 27 sept. 2010
00028  * Purpose:  .
00029  * Author:   iovleff, serge.iovleff@stkpp.org
00030  *
00031  **/
00032 
00037 #ifndef STK_READWRITEPAGES_H
00038 #define STK_READWRITEPAGES_H
00039 
00040 #include "STK_IPage.h"
00041 
00042 namespace STK
00043 {
00044 
00077 class ReadWritePages
00078 {
00079   private:
00081     typedef std::vector<IPage*> ContPage;
00082 
00083   public:
00088     ReadWritePages( std::string const& file_name = std::string());
00089 
00091     virtual ~ReadWritePages();
00092 
00097     inline IPage const* p_page( Integer const& pos) const
00098     { return pages_.at(ContPage::size_type(pos));}
00099 
00104      inline IPage* p_page( Integer const& pos)
00105      { return pages_.at(ContPage::size_type(pos));}
00106 
00111      IPage const* p_page( String const& name) const;
00112 
00117      IPage* p_page( String const& name);
00118 
00123      inline IPage const* operator[]( Integer const& pos) const
00124      { return pages_.at(ContPage::size_type(pos));}
00125 
00130      inline IPage* operator[]( Integer const& pos)
00131      { return pages_.at(ContPage::size_type(pos));}
00132 
00136     void addPage( IPage const& page);
00142     bool write( std::string const& file_name = std::string()) const;
00143 
00149     bool write( ostream& os) const;
00150 
00155     bool read( std::string const& file_name = std::string());
00156 
00161     bool read( istream& is);
00162 
00166     bool validate();
00167 
00171     inline String const& error() const { return msg_error_;}
00172 
00173   protected:
00175     ContPage pages_;
00177     stringstream buffer_;
00179     mutable std::string  file_name_;
00181     mutable String msg_error_;
00182 };
00183 
00184 }
00185 
00186 #endif /* STK_READWRITEPAGE_H */