1 // File.h
2 //
3 // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood
4 // See file AUTHORS for contact information
5 //
6 // This file is part of RudeConfig.
7 //
8 // RudeConfig is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2, or (at your option)
11 // any later version.
12 //
13 // RudeConfig is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with RudeConfig; (see COPYING) if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 // 02111-1307, USA.
22 //------------------------------------------------------------------------
23 
24 
25 #ifndef INCLUDED_File_H
26 #define INCLUDED_File_H
27 
28 #ifndef INCLUDED_AbstractData_H
29 #include "AbstractData.h"
30 #endif
31 
32 #ifndef INCLUDED_VECTOR
33 #include <vector>
34 #define INCLUDED_VECTOR
35 #endif
36 
37 #ifndef INCLUDED_MAP
38 #include <map>
39 #define INCLUDED_MAP
40 #endif
41 
42 #ifndef INCLUDED_STRING
43 #include <string>
44 #define INCLUDED_STRING
45 #endif
46 
47 using namespace rude::config;
48 
49 namespace rude{
50 namespace config{
51 
52 class Section;
53 
54 class File: public AbstractData{
55 
56 private:
57 	Section *d_currentSection;
58 	mutable std::vector<Section*> d_sections;
59 	mutable std::map<std::string, Section*> d_sectionmap;
60 
61 public:
62 
63 	File();
64 	~File();
65 	void acceptWriter(AbstractWriter& writer) const;
66 	void clear();
67 	const char * getStringValue(const char *name) const;
68 	bool deleteData(const char *name);
69 	void setStringValue(const char *name, const char *value);
70 	int getNumDataMembers() const;
71 	const char *getDataNameAt(int index) const;
72 	const char *getDataValueAt(int index) const;
73 	bool exists(const char *name) const;
74 	int getNumSections() const;
75 	const char *getSectionNameAt(int index) const;
76 	bool setSection(const char *sectionname, bool shouldCreate);
77 	bool deleteSection(const char *sectionname);
78 
79 	Section *getSection(const char *sectionname);
80 
81 };
82 
83 }} // end namespace rude::config
84 
85 #endif
86 
87