STK++ 0.9.13
STK_ReadWritePages.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------*/
2/* Copyright (C) 2004-2010 Serge Iovleff
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this program; if not, write to the
16 Free Software Foundation, Inc.,
17 59 Temple Place,
18 Suite 330,
19 Boston, MA 02111-1307
20 USA
21
22 Contact : S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
23 */
24
25/*
26 * Project: stkpp::DManager
27 * created on: 27 sept. 2010
28 * Purpose: .
29 * Author: iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
30 *
31 **/
32
37#ifndef STK_READWRITEPAGES_H
38#define STK_READWRITEPAGES_H
39
40#include "STK_IPage.h"
41
42namespace STK
43{
44
78{
79 private:
81 typedef std::vector<IPage*> ContPage;
82
83 public:
88 ReadWritePages( std::string const& file_name = std::string());
89
91 virtual ~ReadWritePages();
92
97 inline IPage const* p_page( int const& pos) const
98 { return pages_.at(ContPage::size_type(pos));}
99
104 inline IPage* p_page( int const& pos)
105 { return pages_.at(ContPage::size_type(pos));}
106
111 IPage const* p_page( String const& name) const;
112
117 IPage* p_page( String const& name);
118
123 inline IPage const* operator[]( int const& pos) const
124 { return pages_.at(ContPage::size_type(pos));}
125
130 inline IPage* operator[]( int const& pos)
131 { return pages_.at(ContPage::size_type(pos));}
132
136 void addPage( IPage const& page);
142 bool write( std::string const& file_name = std::string()) const;
143
149 bool write( ostream& os) const;
150
155 bool read( std::string const& file_name = std::string());
156
161 bool read( istream& is);
162
166 bool validate();
167
171 inline String const& error() const { return msg_error_;}
172
173 protected:
179 mutable std::string file_name_;
182};
183
184} // namespace STK
185
186#endif /* STK_READWRITEPAGE_H */
In this file we define the Interface base class IPage.
A IPage is an interface base class for reading and/or writing a page of option in a file.
Definition STK_IPage.h:94
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
The ReadWritePages class allow to handle a file of option containing pages.
IPage * p_page(int const &pos)
get a page of option.
IPage const * operator[](int const &pos) const
get a constant page of option.
ContPage pages_
The list of page to read and/or write.
std::vector< IPage * > ContPage
type of the container for the pages.
bool write(std::string const &file_name=std::string()) const
Attempts to write the ReadWritePage to the location specified by file_name.
String const & error() const
give the last error message encountered
stringstream buffer_
the string buffer containing the file with all the options.
IPage * operator[](int const &pos)
get a page of option.
void addPage(IPage const &page)
Add a page of option to read and/or write.
virtual ~ReadWritePages()
Destructor.
bool read(std::string const &file_name=std::string())
Attempts to read the specified file.
String msg_error_
The last error message.
bool validate()
validate all the pages.
std::string file_name_
Name of the Current file to read/write.
IPage const * p_page(int const &pos) const
get a constant page of option.
std::basic_string< Char > String
STK fundamental type of a String.
std::basic_ostream< Char > ostream
ostream for Char
Definition STK_Stream.h:57
std::basic_stringstream< Char > stringstream
stringstream for Char
Definition STK_Stream.h:67
std::basic_istream< Char > istream
istream for Char
Definition STK_Stream.h:55
The namespace STK is the main domain space of the Statistical ToolKit project.