presage 0.9.1
profile.h
Go to the documentation of this file.
1
2/******************************************************
3 * Presage, an extensible predictive text entry system
4 * ---------------------------------------------------
5 *
6 * Copyright (C) 2008 Matteo Vescovi <matteo.vescovi@yahoo.co.uk>
7
8 This program 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 of the License, or
11 (at your option) any later version.
12
13 This program 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 along
19 with this program; if not, write to the Free Software Foundation, Inc.,
20 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 **********(*)*/
23
24
25#ifndef PRESAGE_PROFILE
26#define PRESAGE_PROFILE
27
28#include "config.h"
29
30#include <tinyxml.h>
31
32#include <vector>
33#include <string>
34#include <map>
35
36typedef std::string Value;
37#include "configuration.h"
38#include "presageException.h"
39
56class Profile {
57public:
62 Profile(const std::string& filename);
63
69 virtual ~Profile();
70
74 void read_into_configuration(Configuration* configuration);
75
76 /* Reads from configuration and writes to XML DOM document.
77 *
78 */
79 void read_from_configuration (Configuration* configuration);
80
81 bool file_read_ok () const;
82
83 bool write_to_file () const;
84
86 public:
87 ProfileException(presage_error_code_t code, const std::string& desc) throw() : PresageException(code, desc) { }
88 virtual ~ProfileException() throw() { }
89
90 private:
92
93 };
94
95protected:
96 void init_configuration(Configuration* config, TiXmlDocument* node);
97 void visit_node(Configuration* config, TiXmlNode* node, std::vector<std::string> variable);
98
99 TiXmlDocument* xmlProfileDoc;
100 std::string xml_filename;
102};
103
104#endif // PRESAGE_PROFILE
virtual const presage_error_code_t code() const
ProfileException(presage_error_code_t code, const std::string &desc)
Definition profile.h:87
virtual ~ProfileException()
Definition profile.h:88
void visit_node(Configuration *config, TiXmlNode *node, std::vector< std::string > variable)
Definition profile.cpp:62
std::string xml_filename
Definition profile.h:100
void read_from_configuration(Configuration *configuration)
Definition profile.cpp:102
virtual ~Profile()
Definition profile.cpp:40
void init_configuration(Configuration *config, TiXmlDocument *node)
Definition profile.cpp:55
void read_into_configuration(Configuration *configuration)
Definition profile.cpp:50
bool xml_profile_read_ok
Definition profile.h:101
bool write_to_file() const
Definition profile.cpp:96
TiXmlDocument * xmlProfileDoc
Definition profile.h:99
bool file_read_ok() const
Definition profile.cpp:45
std::string config
presage_error_code_t
@ PRESAGE_ERROR
std::string Value
Definition profile.h:36