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