C++ main module for emicrom Package  1.0
CORE_Integer.h
Go to the documentation of this file.
1 #ifndef CORE_INTEGER_H
2 #define CORE_INTEGER_H
3 
4 #include "CORE_Object.h"
5 
6 #include "CORE_Pointers.h"
7 
8 #include <bitset>
9 #include <boost/lexical_cast.hpp>
10 
25 class CORE_Integer : public CORE_Object {
26  // ATTRIBUTES
27 private:
28 
30 
31  // ASSOCIATIONS
32 
33 public:
34 
35  // CONSTRUCTORS
38  CORE_Integer(const tInteger& i);
39 
40 
41 
42  // DESTRUCTORS
45  ~CORE_Integer();
46 
47 
48 public:
49 
50  // NEW
51 
55  static inline SP::CORE_Integer New() {
56  SP::CORE_Integer p(new CORE_Integer(0),CORE_Integer::Delete());
57  return p;
58 
59  };
64  static inline SP::CORE_Integer New(const tInteger& i) {
65  SP::CORE_Integer p(new CORE_Integer(i),CORE_Integer::Delete());
66  return p;
67  }
68 
69  // SET Accessors
70 
74  inline void setInteger(const tInteger& i) {
75  mInteger=i;
76  };
80  inline void setInteger(const tString& i) {
81  setInteger(parseInt(i));
82  };
83 
84  // GET Accessors
89  static tBoolean isInteger(const tString& str);
90 
94  const tInteger& getInteger() const {return mInteger;};
95 
96 
97  // Methods
98 
99 
100 
101  // transform methods
102 
106  tString toString() const {return toString(mInteger);};
107 
112  static tString toString(const tChar& i);
113 
119  static tString toString(const tUChar& i);
120 
125  static tString toString(const tSInt& i);
126 
131  static tString toString(const tUSInt& i);
132 
137  static tString toString(const tInt& i);
142  static tString toString(const tUInt& i);
143 
148  static tString toString(const tLInt& i);
149 
154  static tString toString(const tULInt& i);
155 
160  static tString toString(const tLLInt& i);
161 
166  static tString toString(const tULLInt& i);
167 
168 
174  static tString toString(const tInteger& i,const tUIndex& nDigits);
175 
176 
182  static tString toHexString(const tUInt& i,const tUIndex& nDigits);
183 
188  static tString toHexString(const tUInt& i);
189 
190 
195  template<size_t N>
196  static tString toBinString(const tUInteger& i) {
197  return std::bitset<N>(i).to_string();
198  }
199 
204  static tLLInt parseInt(const tString& str);
209  static tULLInt parseHex(const tString& str);
214  static tULLInt parseUInt(const tString& str);
215 
220  inline static tBoolean parseBoolean(const tString& str) {
221  return (tBoolean) parseInt(str);
222  };
223 
232  static tInteger turnIntoPBase(const tString& str,const tInteger& p);
233 
236  inline void increment() {
237  mInteger++;
238  };
241  inline void decrement() {
242  mInteger--;
243  };
244 
245 
246 
247 };
248 
249 
250 #endif // end of ifndef
tInteger mInteger
Definition: CORE_Integer.h:29
static tLLInt parseInt(const tString &str)
return the integer associated to the string
Definition: CORE_Integer.cpp:102
void increment()
increment the value
Definition: CORE_Integer.h:236
CORE_Integer(const tInteger &i)
create an integer initialize to i
Definition: CORE_Integer.cpp:8
~CORE_Integer()
destriuctors
Definition: CORE_Integer.cpp:13
#define tUInteger
Definition: types.h:91
static tString toHexString(const tUInt &i, const tUIndex &nDigits)
return the hexadecimal string corresponding to the int integer
Definition: CORE_Integer.cpp:95
const tInteger & getInteger() const
get the integer
Definition: CORE_Integer.h:94
#define tUSInt
Definition: types.h:28
#define tBoolean
Definition: types.h:139
#define tLInt
Definition: types.h:42
tString toString() const
return the string associated to the integer
Definition: CORE_Integer.h:106
static tULLInt parseUInt(const tString &str)
return the integer associated to the string
Definition: CORE_Integer.cpp:113
static SP::CORE_Integer New()
build an integer object
Definition: CORE_Integer.h:55
this class describes an integer
Definition: CORE_Integer.h:25
DEFINE_SPTR(CORE_Integer)
void setInteger(const tString &i)
set the integer to i
Definition: CORE_Integer.h:80
#define tULInt
Definition: types.h:39
#define tLLInt
Definition: types.h:47
static tString toBinString(const tUInteger &i)
return the binary string corresponding to the int integer
Definition: CORE_Integer.h:196
#define tSInt
Definition: types.h:30
void decrement()
decrement the value
Definition: CORE_Integer.h:241
#define tUChar
Definition: types.h:20
#define tUInt
Definition: types.h:33
#define tUIndex
Definition: types.h:126
void setInteger(const tInteger &i)
set the integer to i
Definition: CORE_Integer.h:74
static SP::CORE_Integer New(const tInteger &i)
build an integer object
Definition: CORE_Integer.h:64
abstract base class for most classes.
Definition: CORE_Object.h:53
#define tString
Definition: types.h:135
#define tChar
Definition: types.h:23
static tULLInt parseHex(const tString &str)
return the integer associated to the hex string
Definition: CORE_Integer.cpp:126
static tInteger turnIntoPBase(const tString &str, const tInteger &p)
return the integer associated to str in base P
Definition: CORE_Integer.cpp:142
#define tULLInt
Definition: types.h:45
#define tInt
Definition: types.h:35
#define tInteger
Definition: types.h:90
static tBoolean parseBoolean(const tString &str)
return the integer associated to a boolean
Definition: CORE_Integer.h:220
static tBoolean isInteger(const tString &str)
return true if the str is an integer
Definition: CORE_Integer.cpp:132
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:141