Sync with 5.4.0
[deliverable/titan.core.git] / core / RInt.hh
1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2000-2015 Ericsson Telecom AB
3 // All rights reserved. This program and the accompanying materials
4 // are made available under the terms of the Eclipse Public License v1.0
5 // which accompanies this distribution, and is available at
6 // http://www.eclipse.org/legal/epl-v10.html
7 ///////////////////////////////////////////////////////////////////////////////
8 #ifndef RInt_HH
9 #define RInt_HH
10
11 struct bignum_st;
12 typedef bignum_st BIGNUM;
13
14 typedef int RInt;
15
16 class int_val_t
17 {
18 private:
19 friend class INTEGER;
20 friend class INTEGER_template;
21
22 bool native_flag;
23 union {
24 RInt native;
25 BIGNUM *openssl;
26 } val;
27
28 public:
29 int_val_t();
30 int_val_t(const int_val_t& v);
31 explicit int_val_t(const char *s);
32 explicit int_val_t(RInt v) : native_flag(true) { val.native = v; }
33 explicit int_val_t(BIGNUM *v) : native_flag(false) { val.openssl = v; }
34 ~int_val_t();
35 /** Returns a newly allocated string. Caller must call Free() */
36 char *as_string() const;
37 const RInt& get_val() const;
38 BIGNUM *get_val_openssl() const;
39 double to_real() const;
40 int_val_t operator&(RInt right) const;
41 bool operator==(const int_val_t& right) const;
42 bool operator<(const int_val_t& right) const;
43
44 inline bool operator!=(const int_val_t& right) const { return !(*this == right); }
45 inline bool operator>(const int_val_t& right) const { return *this != right && !(*this < right); }
46 inline bool operator>=(const int_val_t& right) const { return *this == right || *this > right; }
47 inline bool operator<=(const int_val_t& right) const { return *this == right || *this < right; }
48 inline bool operator==(RInt right) const { return *this == int_val_t(right); }
49 inline bool operator!=(RInt right) const { return !(*this == right); }
50 inline bool operator>(RInt right) const { return *this != right && !(*this < right); }
51 inline bool operator<(RInt right) const { return *this != right && *this < int_val_t(right); }
52 inline bool operator<=(RInt right) const { return *this == right || *this < right; }
53 inline bool operator>=(RInt right) const { return *this == right || *this > right; }
54
55 int_val_t& operator=(const int_val_t& right);
56 int_val_t& operator=(RInt right);
57 int_val_t& operator+=(RInt right);
58 int_val_t& operator<<=(RInt right);
59 int_val_t& operator>>=(RInt right);
60 inline bool is_native() const { return native_flag; }
61 bool is_negative() const;
62 };
63
64 BIGNUM *to_openssl(RInt other_value);
65 RInt string2RInt(const char *s);
66
67 #endif // RInt_HH
This page took 0.044093 seconds and 6 git commands to generate.