profile.h
Go to the documentation of this file.
/******************************************************
* Presage, an extensible predictive text entry system
* ---------------------------------------------------
*
* Copyright (C) 2008 Matteo Vescovi <matteo.vescovi@yahoo.co.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
**********(*)*/
#ifndef PRESAGE_PROFILE
#define PRESAGE_PROFILE
#include "config.h"
#include <tinyxml.h>
#include <vector>
#include <string>
#include <map>
typedef std::string Value;
#include "configuration.h"
#include "presageException.h"
class Profile {
public:
Profile(const std::string& filename);
virtual ~Profile();
void read_into_configuration(Configuration* configuration);
/* Reads from configuration and writes to XML DOM document.
*
*/
void read_from_configuration (Configuration* configuration);
bool file_read_ok () const;
bool write_to_file () const;
class ProfileException : public PresageException {
public:
ProfileException(presage_error_code_t code, const std::string& desc) throw() : PresageException(code, desc) { }
virtual ~ProfileException() throw() { }
private:
ProfileException() throw() : PresageException(PRESAGE_ERROR, "") { }
};
protected:
void init_configuration(Configuration* config, TiXmlDocument* node);
void visit_node(Configuration* config, TiXmlNode* node, std::vector<std::string> variable);
TiXmlDocument* xmlProfileDoc;
std::string xml_filename;
bool xml_profile_read_ok;
};
#endif // PRESAGE_PROFILE
Profile::Profile
Profile(const std::string &filename)
Definition: profile.cpp:29
Profile::~Profile
virtual ~Profile()
Definition: profile.cpp:39
Profile::visit_node
void visit_node(Configuration *config, TiXmlNode *node, std::vector< std::string > variable)
Definition: profile.cpp:61
Profile::xmlProfileDoc
TiXmlDocument * xmlProfileDoc
Definition: profile.h:98
presage_error_code_t
presage_error_code_t
Definition: presageException.h:31
Value
std::string Value
Definition: profile.h:35
PRESAGE_ERROR
Definition: presageException.h:53
Profile
Definition: profile.h:55
PresageException::code
virtual const presage_error_code_t code() const
Definition: presageException.h:85
config
std::string config
Definition: presageDemo.cpp:69
PresageException::PresageException
PresageException(presage_error_code_t code, const std::string &msg)
Definition: presageException.h:68
Profile::file_read_ok
bool file_read_ok() const
Definition: profile.cpp:44
Profile::ProfileException::~ProfileException
virtual ~ProfileException()
Definition: profile.h:87
Profile::read_into_configuration
void read_into_configuration(Configuration *configuration)
Definition: profile.cpp:49
Profile::ProfileException::ProfileException
ProfileException()
Definition: profile.h:90
Profile::write_to_file
bool write_to_file() const
Definition: profile.cpp:95
Profile::read_from_configuration
void read_from_configuration(Configuration *configuration)
Definition: profile.cpp:101
presageException.h
PresageException
Definition: presageException.h:66
Profile::xml_filename
std::string xml_filename
Definition: profile.h:99
Configuration
Definition: configuration.h:35
Profile::ProfileException
Definition: profile.h:84
configuration.h
Profile::init_configuration
void init_configuration(Configuration *config, TiXmlDocument *node)
Definition: profile.cpp:54
Profile::xml_profile_read_ok
bool xml_profile_read_ok
Definition: profile.h:100