File: pgsVariable.cpp

package info (click to toggle)
pgadmin3 1.14.2-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 69,368 kB
  • sloc: cpp: 163,662; sh: 4,339; ansic: 1,636; pascal: 1,120; yacc: 927; makefile: 733; lex: 421; perl: 40
file content (128 lines) | stat: -rw-r--r-- 2,430 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//////////////////////////////////////////////////////////////////////////
//
// pgScript - PostgreSQL Tools
//
// Copyright (C) 2002 - 2012, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
//////////////////////////////////////////////////////////////////////////


#include "pgAdmin3.h"
#include "pgscript/objects/pgsVariable.h"

pgsVariable::pgsVariable(const pgsTypes &type) :
	pgsExpression(), m_type(type)
{

}

pgsVariable::~pgsVariable()
{

}

MAPM pgsVariable::num(const pgsOperand &var)
{
	return pgsMapm::pgs_str_mapm(var->value());
}

MAPM pgsVariable::num(const wxString &var)
{
	return pgsMapm::pgs_str_mapm(var);
}

bool pgsVariable::is_number() const
{
	return is_integer() || is_real();
}

bool pgsVariable::is_integer() const
{
	return m_type == pgsTInt;
}

bool pgsVariable::is_real() const
{
	return m_type == pgsTReal;
}

bool pgsVariable::is_string() const
{
	return m_type == pgsTString;
}

bool pgsVariable::is_record() const
{
	return m_type == pgsTRecord;
}

const pgsVariable::pgsTypes &pgsVariable::type() const
{
	return m_type;
}

pgsOperand operator+(const pgsVariable &lhs, const pgsVariable &rhs)
{
	return lhs.pgs_plus(rhs);
}

pgsOperand operator-(const pgsVariable &lhs, const pgsVariable &rhs)
{
	return lhs.pgs_minus(rhs);
}

pgsOperand operator*(const pgsVariable &lhs, const pgsVariable &rhs)
{
	return lhs.pgs_times(rhs);
}

pgsOperand operator/(const pgsVariable &lhs, const pgsVariable &rhs)
{
	return lhs.pgs_over(rhs);
}

pgsOperand operator%(const pgsVariable &lhs, const pgsVariable &rhs)
{
	return lhs.pgs_modulo(rhs);
}

pgsOperand operator==(const pgsVariable &lhs, const pgsVariable &rhs)
{
	return lhs.pgs_equal(rhs);
}

pgsOperand operator!=(const pgsVariable &lhs, const pgsVariable &rhs)
{
	return lhs.pgs_different(rhs);
}

pgsOperand operator<(const pgsVariable &lhs, const pgsVariable &rhs)
{
	return lhs.pgs_lower(rhs);
}

pgsOperand operator>(const pgsVariable &lhs, const pgsVariable &rhs)
{
	return lhs.pgs_greater(rhs);
}

pgsOperand operator<=(const pgsVariable &lhs, const pgsVariable &rhs)
{
	return lhs.pgs_lower_equal(rhs);
}

pgsOperand operator>=(const pgsVariable &lhs, const pgsVariable &rhs)
{
	return lhs.pgs_greater_equal(rhs);
}

pgsOperand operator!(const pgsVariable &lhs)
{
	return lhs.pgs_not();
}

pgsOperand operator&=(const pgsVariable &lhs, const pgsVariable &rhs)
{
	return lhs.pgs_almost_equal(rhs);
}