APRONXX 0.9.15
/home/mine/apron/apronxx/apxx_var_inline.hh
Go to the documentation of this file.
1/* -*- C++ -*-
2 * apxx_var_inline.hh
3 *
4 * APRON Library / C++ inline functions
5 *
6 * DO NOT INCLUDE THIS FILE DIRECTLY
7 *
8 * Copyright (C) Antoine Mine' 2007
9 *
10 */
11/* This file is part of the APRON Library, released under LGPL license
12 with an exception allowing the redistribution of statically linked
13 executables.
14
15 Please read the COPYING file packaged in the distribution.
16*/
17
18
19/* ================================= */
20/* var */
21/* ================================= */
22
23
24/* constructors */
25/* ============ */
26
27inline var::var(const void* x)
28{
29 v = ap_var_operations->copy(const_cast<void*>(x));
30}
31
32inline var::var(const std::string& x)
33{
34 v = ap_var_operations->copy(const_cast<char*>(x.c_str()));
35}
36
37inline var::var(const var& x)
38{
39 v = ap_var_operations->copy(x.v);
40}
41
42
43/* destructor */
44/* ========== */
45
46inline var::~var()
47{
48 ap_var_operations->free(v);
49}
50
51
52/* assignments */
53/* =========== */
54
55inline var& var::operator=(const var& x)
56{
57 if (x.v!=v) {
58 ap_var_t vv = ap_var_operations->copy(x.v);
59 ap_var_operations->free(v);
60 v = vv;
61 }
62 return *this;
63}
64
65inline var& var::operator=(const void* x)
66{
67 ap_var_operations->free(v);
68 v = ap_var_operations->copy(const_cast<void*>(x));
69 return *this;
70}
71
72inline var& var::operator=(const std::string& x)
73{
74 ap_var_operations->free(v);
75 v = ap_var_operations->copy(const_cast<char*>(x.c_str()));
76 return *this;
77}
78
79
80/* conversions */
81/* =========== */
82
83inline var::operator char*() const
84{
85 return ap_var_operations->to_string(v);
86}
87
88inline var::operator std::string() const
89{
90 char* c = ap_var_operations->to_string(v);
91 std::string s = c;
92 free(c);
93 return s;
94}
95
96
97/* comparisons */
98/* =========== */
99
100inline int compare(const var& x, const var& y)
101{
102 return ap_var_operations->compare(x.v,y.v);
103}
104
105inline bool operator==(const var& x, const var& y)
106{
107 return ap_var_operations->compare(x.v,y.v)==0;
108}
109
110inline bool operator!=(const var& x, const var& y)
111{
112 return ap_var_operations->compare(x.v,y.v)!=0;
113}
114
115inline bool operator>=(const var& x, const var& y)
116{
117 return ap_var_operations->compare(x.v,y.v)>=0;
118}
119
120inline bool operator<=(const var& x, const var& y)
121{
122 return ap_var_operations->compare(x.v,y.v)<=0;
123}
124
125inline bool operator>(const var& x, const var& y)
126{
127 return ap_var_operations->compare(x.v,y.v)>0;
128}
129
130inline bool operator<(const var& x, const var& y)
131{
132 return ap_var_operations->compare(x.v,y.v)<0;
133}
134
135/* print */
136/* ===== */
137
138inline std::ostream& operator<< (std::ostream& os, const var& s)
139{
140 std::string ss = s;
141 return os << ss;
142}
143
144inline void var::print(FILE* stream) const
145{
146 char* x = ap_var_operations->to_string(const_cast<void*>(v));
147 fprintf(stream,"%s",x);
148 free(x);
149}
150
151
152
153/* C-level compatibility */
154/* ===================== */
155
156inline const ap_var_t& var::get_ap_var_t() const
157{
158 return v;
159}
160
161inline ap_var_t& var::get_ap_var_t()
162{
163 return v;
164}
165
166
bool operator>(const var &x, const var &y)
Definition apxx_var_inline.hh:125
bool operator>=(const var &x, const var &y)
Definition apxx_var_inline.hh:115
bool operator==(const var &x, const var &y)
Definition apxx_var_inline.hh:105
bool operator<(const var &x, const var &y)
Definition apxx_var_inline.hh:130
bool operator<=(const var &x, const var &y)
Definition apxx_var_inline.hh:120
std::ostream & operator<<(std::ostream &os, const var &s)
Definition apxx_var_inline.hh:138
int compare(const var &x, const var &y)
Definition apxx_var_inline.hh:100
bool operator!=(const var &x, const var &y)
Definition apxx_var_inline.hh:110