presage 0.9.1
variable.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_VARIABLE
26#define PRESAGE_VARIABLE
27
28#include <string>
29#include <vector>
30
31#include "observable.h"
32
33class Variable : public Observable {
34public:
35 Variable(const char* variable);
36 Variable(const std::string& variable);
37 Variable(const std::vector<std::string>& variable);
38 ~Variable();
39
40 std::string get_name () const;
41 std::vector<std::string> get_name_vector () const;
42
43 std::string get_value () const;
44 void set_value (std::string value);
45
46 size_t size() const { return m_name_vector.size(); }
47
48 bool operator<(const Variable& other) const { return (get_name () < other.get_name ()); }
49
50 static std::vector<std::string> string_to_vector(const std::string& str);
51 static std::string vector_to_string(const std::vector<std::string>& var);
52
53private:
54
55 std::string m_name;
56 std::vector<std::string> m_name_vector;
57 std::string m_value;
58
59};
60
61#endif // PRESAGE_VARIABLE
std::string get_value() const
Definition: variable.cpp:62
static std::vector< std::string > string_to_vector(const std::string &str)
Definition: variable.cpp:82
std::string get_name() const
Definition: variable.cpp:52
static std::string vector_to_string(const std::vector< std::string > &var)
Definition: variable.cpp:107
std::string m_name
Definition: variable.h:55
size_t size() const
Definition: variable.h:46
std::string m_value
Definition: variable.h:57
~Variable()
Definition: variable.cpp:47
std::vector< std::string > m_name_vector
Definition: variable.h:56
bool operator<(const Variable &other) const
Definition: variable.h:48
std::vector< std::string > get_name_vector() const
Definition: variable.cpp:57
void set_value(std::string value)
Definition: variable.cpp:67