presage  0.8.7
profile.h
Go to the documentation of this file.
00001 
00002 /******************************************************
00003  *  Presage, an extensible predictive text entry system
00004  *  ---------------------------------------------------
00005  *
00006  *  Copyright (C) 2008  Matteo Vescovi <matteo.vescovi@yahoo.co.uk>
00007 
00008     This program is free software; you can redistribute it and/or modify
00009     it under the terms of the GNU General Public License as published by
00010     the Free Software Foundation; either version 2 of the License, or
00011     (at your option) any later version.
00012 
00013     This program is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016     GNU General Public License for more details.
00017 
00018     You should have received a copy of the GNU General Public License along
00019     with this program; if not, write to the Free Software Foundation, Inc.,
00020     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00021                                                                              *
00022                                                                 **********(*)*/
00023 
00024 
00025 #ifndef PRESAGE_PROFILE
00026 #define PRESAGE_PROFILE
00027 
00028 #include "config.h"
00029 
00030 #include <tinyxml.h>
00031 
00032 #include <vector>
00033 #include <string>
00034 #include <map>
00035 
00036 typedef std::string Value;
00037 #include "configuration.h"
00038 #include "presageException.h"
00039 
00056 class Profile {
00057 public:
00062     Profile(const std::string& filename);
00063 
00069     virtual ~Profile();
00070 
00074     void read_into_configuration(Configuration* configuration);
00075 
00076     /* Reads from configuration and writes to XML DOM document.
00077      *
00078      */
00079     void read_from_configuration (Configuration* configuration);
00080 
00081     bool file_read_ok () const;
00082 
00083     bool write_to_file () const;
00084 
00085     class ProfileException : public PresageException {
00086     public:
00087         ProfileException(presage_error_code_t code, const std::string& desc) throw() : PresageException(code, desc) { }
00088         virtual ~ProfileException() throw() { }
00089         
00090     private:
00091         ProfileException() throw() : PresageException(PRESAGE_ERROR, "") { }
00092 
00093     };
00094 
00095 protected:
00096     void init_configuration(Configuration* config, TiXmlDocument* node);
00097     void visit_node(Configuration* config, TiXmlNode* node, std::vector<std::string> variable);
00098 
00099     TiXmlDocument* xmlProfileDoc;
00100     std::string xml_filename;
00101     bool xml_profile_read_ok;
00102 };
00103 
00104 #endif // PRESAGE_PROFILE