]> Shamusworld >> Repos - architektonas/blob - src/base/rs_variable.cpp
06648d911506fee6fbd76f538f2cfe2ff15b33c2
[architektonas] / src / base / rs_variable.cpp
1 // rs_variable.cpp
2 //
3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // (C) 2010 Underground Software
7 //
8 // JLH = James L. Hammons <jlhamm@acm.org>
9 //
10 // Who  When        What
11 // ---  ----------  -----------------------------------------------------------
12 // JLH  05/07/2010  Moved implementation from header to this file. :-)
13 //
14
15 // We probably could replace all this crap with QVariant...
16 #include "rs_variable.h"
17
18 RS_Variable::RS_Variable()
19 {
20         type = RS2::VariableVoid;
21         code = 0;
22 }
23
24 RS_Variable::RS_Variable(const Vector & v, int c)
25 {
26         setVector(v);
27         code = c;
28 }
29
30 RS_Variable::RS_Variable(const QString & v, int c)
31 {
32         setString(v);
33         code = c;
34 }
35
36 RS_Variable::RS_Variable(int v, int c)
37 {
38         setInt(v);
39         code = c;
40 }
41
42 RS_Variable::RS_Variable(double v, int c)
43 {
44         setDouble(v);
45         code = c;
46 }
47
48 /*virtual*/ RS_Variable::~RS_Variable()
49 {
50 }
51
52 void RS_Variable::setString(const QString & str)
53 {
54         contents.s = str;
55         type = RS2::VariableString;
56 }
57
58 void RS_Variable::setInt(int i)
59 {
60         contents.i = i;
61         type = RS2::VariableInt;
62 }
63
64 void RS_Variable::setDouble(double d)
65 {
66         contents.d = d;
67         type = RS2::VariableDouble;
68 }
69
70 void RS_Variable::setVector(const Vector & v)
71 {
72         contents.v = v;
73         type = RS2::VariableVector;
74 }
75
76 QString RS_Variable::getString()
77 {
78         return contents.s;
79 }
80
81 int RS_Variable::getInt()
82 {
83         return contents.i;
84 }
85
86 double RS_Variable::getDouble()
87 {
88         return contents.d;
89 }
90
91 Vector RS_Variable::getVector()
92 {
93         return contents.v;
94 }
95
96 RS2::VariableType RS_Variable::getType()
97 {
98         return type;
99 }
100
101 int RS_Variable::getCode()
102 {
103         return code;
104 }