presage  0.8.7
variable.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_VARIABLE
00026 #define PRESAGE_VARIABLE
00027 
00028 #include <string>
00029 #include <vector>
00030 
00031 #include "observable.h"
00032 
00033 class Variable : public Observable {
00034 public:
00035     Variable(const char* variable);
00036     Variable(const std::string& variable);
00037     Variable(const std::vector<std::string>& variable);
00038     ~Variable();
00039 
00040     std::string              get_name () const;
00041     std::vector<std::string> get_name_vector () const;
00042 
00043     std::string get_value () const;
00044     void        set_value (std::string value);
00045     
00046     size_t size() const { return m_name_vector.size(); }
00047 
00048     bool operator<(const Variable& other) const { return (get_name () < other.get_name ()); }
00049 
00050     static std::vector<std::string> string_to_vector(const std::string& str);
00051     static std::string vector_to_string(const std::vector<std::string>& var);
00052 
00053 private:
00054     
00055     std::string              m_name;
00056     std::vector<std::string> m_name_vector;
00057     std::string              m_value;
00058 
00059 };
00060 
00061 #endif // PRESAGE_VARIABLE