Skip to content

Commit 8ba236f

Browse files
Florent Lamirauxflorent-lamiraux
authored andcommitted
[Value] Use int64_t, int32_t, uint64_t, uint32_t instead of
int, long int, unsigned int, unsigned long int.
1 parent 9b21dae commit 8ba236f

File tree

2 files changed

+40
-36
lines changed

2 files changed

+40
-36
lines changed

include/dynamic-graph/value.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ class DYNAMIC_GRAPH_DLLAPI EitherType {
2626
EitherType(const Value &value);
2727
~EitherType();
2828
operator bool() const;
29-
operator unsigned() const;
30-
operator unsigned long int() const;
31-
operator int() const;
32-
operator long int() const;
29+
operator uint32_t() const;
30+
operator uint64_t() const;
31+
operator int32_t() const;
32+
operator int64_t() const;
3333
operator float() const;
3434
operator double() const;
3535
operator std::string() const;
@@ -68,10 +68,10 @@ class DYNAMIC_GRAPH_DLLAPI Value {
6868
~Value();
6969
void deleteValue();
7070
explicit Value(const bool &value);
71-
explicit Value(const unsigned &value);
72-
explicit Value(const unsigned long int &value);
73-
explicit Value(const int &value);
74-
explicit Value(const long int &value);
71+
explicit Value(const uint32_t &value);
72+
explicit Value(const uint64_t &value);
73+
explicit Value(const int32_t &value);
74+
explicit Value(const int64_t &value);
7575
explicit Value(const float &value);
7676
explicit Value(const double &value);
7777
explicit Value(const std::string &value);
@@ -112,10 +112,10 @@ class DYNAMIC_GRAPH_DLLAPI Value {
112112
public:
113113
friend class EitherType;
114114
bool boolValue() const;
115-
unsigned unsignedValue() const;
116-
unsigned long int unsignedlongintValue() const;
117-
int intValue() const;
118-
long int longintValue() const;
115+
uint32_t unsignedValue() const;
116+
uint64_t unsignedlongintValue() const;
117+
int32_t intValue() const;
118+
int64_t longintValue() const;
119119
float floatValue() const;
120120
double doubleValue() const;
121121
std::string stringValue() const;

src/command/value.cpp

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ EitherType::~EitherType() {
2121
}
2222

2323
EitherType::operator bool() const { return value_->boolValue(); }
24-
EitherType::operator unsigned() const { return value_->unsignedValue(); }
25-
EitherType::operator unsigned long int() const {
24+
EitherType::operator uint32_t() const { return value_->unsignedValue(); }
25+
EitherType::operator uint64_t() const {
2626
return value_->unsignedlongintValue();
2727
}
28-
EitherType::operator int() const { return value_->intValue(); }
29-
EitherType::operator long int() const { return value_->longintValue(); }
28+
EitherType::operator int32_t() const { return value_->intValue(); }
29+
EitherType::operator int64_t() const { return value_->longintValue(); }
3030
EitherType::operator float() const { return value_->floatValue(); }
3131
EitherType::operator double() const { return value_->doubleValue(); }
3232
EitherType::operator std::string() const { return value_->stringValue(); }
@@ -42,16 +42,16 @@ void Value::deleteValue() {
4242
delete (const bool *)value_;
4343
break;
4444
case UNSIGNED:
45-
delete (const unsigned *)value_;
45+
delete (const uint32_t *)value_;
4646
break;
4747
case UNSIGNEDLONGINT:
48-
delete (const unsigned long int *)value_;
48+
delete (const uint64_t *)value_;
4949
break;
5050
case INT:
51-
delete (const int *)value_;
51+
delete (const int32_t *)value_;
5252
break;
5353
case LONGINT:
54-
delete (const long int *)value_;
54+
delete (const int64_t *)value_;
5555
break;
5656
case FLOAT:
5757
delete (const float *)value_;
@@ -85,11 +85,13 @@ void Value::deleteValue() {
8585
Value::~Value() { deleteValue(); }
8686

8787
Value::Value(const bool &value) : type_(BOOL), value_(new bool(value)) {}
88-
Value::Value(const unsigned &value)
89-
: type_(UNSIGNED), value_(new unsigned(value)) {}
90-
Value::Value(const unsigned long int &value)
91-
: type_(UNSIGNEDLONGINT), value_(new unsigned long int(value)) {}
92-
Value::Value(const int &value) : type_(INT), value_(new int(value)) {}
88+
Value::Value(const uint32_t &value)
89+
: type_(UNSIGNED), value_(new uint32_t(value)) {}
90+
Value::Value(const uint64_t &value)
91+
: type_(UNSIGNEDLONGINT), value_(new uint64_t(value)) {}
92+
Value::Value(const int32_t &value) : type_(INT), value_(new int32_t(value)) {}
93+
Value::Value(const int64_t &value) : type_(LONGINT), value_(new int64_t(value))
94+
{}
9395
Value::Value(const float &value) : type_(FLOAT), value_(new float(value)) {}
9496
Value::Value(const double &value) : type_(DOUBLE), value_(new double(value)) {}
9597
Value::Value(const std::string &value)
@@ -206,25 +208,25 @@ bool Value::boolValue() const {
206208
throw ExceptionAbstract(ExceptionAbstract::TOOLS, "value is not an bool");
207209
}
208210

209-
unsigned Value::unsignedValue() const {
210-
if (type_ == UNSIGNED) return *((const unsigned *)value_);
211+
uint32_t Value::unsignedValue() const {
212+
if (type_ == UNSIGNED) return *((const uint32_t *)value_);
211213
throw ExceptionAbstract(ExceptionAbstract::TOOLS,
212214
"value is not an unsigned int");
213215
}
214216

215-
unsigned long int Value::unsignedlongintValue() const {
216-
if (type_ == UNSIGNEDLONGINT) return *((const unsigned long int *)value_);
217+
uint64_t Value::unsignedlongintValue() const {
218+
if (type_ == UNSIGNEDLONGINT) return *((const uint64_t *)value_);
217219
throw ExceptionAbstract(ExceptionAbstract::TOOLS,
218220
"value is not an unsigned long int");
219221
}
220222

221-
long int Value::longintValue() const {
222-
if (type_ == LONGINT) return *((const long int *)value_);
223+
int64_t Value::longintValue() const {
224+
if (type_ == LONGINT) return *((const int64_t *)value_);
223225
throw ExceptionAbstract(ExceptionAbstract::TOOLS, "value is not an long int");
224226
}
225227

226-
int Value::intValue() const {
227-
if (type_ == INT) return *((const int *)value_);
228+
int32_t Value::intValue() const {
229+
if (type_ == INT) return *((const int32_t *)value_);
228230
throw ExceptionAbstract(ExceptionAbstract::TOOLS, "value is not an int");
229231
}
230232

@@ -356,12 +358,14 @@ std::ostream &operator<<(std::ostream &os, const Value &value) {
356358
template <>
357359
const Value::Type ValueHelper<bool>::TypeID = Value::BOOL;
358360
template <>
359-
const Value::Type ValueHelper<unsigned>::TypeID = Value::UNSIGNED;
361+
const Value::Type ValueHelper<uint32_t>::TypeID = Value::UNSIGNED;
360362
template <>
361-
const Value::Type ValueHelper<unsigned long int>::TypeID =
363+
const Value::Type ValueHelper<uint64_t>::TypeID =
362364
Value::UNSIGNEDLONGINT;
363365
template <>
364-
const Value::Type ValueHelper<int>::TypeID = Value::INT;
366+
const Value::Type ValueHelper<int32_t>::TypeID = Value::INT;
367+
template <>
368+
const Value::Type ValueHelper<int64_t>::TypeID = Value::LONGINT;
365369
template <>
366370
const Value::Type ValueHelper<float>::TypeID = Value::FLOAT;
367371
template <>

0 commit comments

Comments
 (0)