presage  0.9.2~beta
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 
36 typedef std::string Value;
37 #include "configuration.h"
38 #include "presageException.h"
39 
56 class Profile {
57 public:
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 
95 protected:
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
presage_error_code_t
bool xml_profile_read_ok
Definition: profile.h:101
PresageException(presage_error_code_t code, const std::string &msg)
std::string Value
Definition: profile.h:36
virtual ~ProfileException()
Definition: profile.h:88
std::string config
Definition: presageDemo.cpp:70
bool file_read_ok() const
Definition: profile.cpp:45
bool write_to_file() const
Definition: profile.cpp:96
void read_from_configuration(Configuration *configuration)
Definition: profile.cpp:102
TiXmlDocument * xmlProfileDoc
Definition: profile.h:99
std::string xml_filename
Definition: profile.h:100
void visit_node(Configuration *config, TiXmlNode *node, std::vector< std::string > variable)
Definition: profile.cpp:62
virtual const presage_error_code_t code() const
void read_into_configuration(Configuration *configuration)
Definition: profile.cpp:50
void init_configuration(Configuration *config, TiXmlDocument *node)
Definition: profile.cpp:55
virtual ~Profile()
Definition: profile.cpp:40
ProfileException(presage_error_code_t code, const std::string &desc)
Definition: profile.h:87
Profile(const std::string &filename)
Definition: profile.cpp:30