Skip to content

Commit b566c9f

Browse files
Use properly cstdint and add std:: to types.
1 parent a15cfa8 commit b566c9f

File tree

3 files changed

+49
-48
lines changed

3 files changed

+49
-48
lines changed

include/dynamic-graph/command-setter.t.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ Value Setter<E, unsigned>::doExecute() {
9090
// Template specialization: unsigned long
9191
//
9292
template <class E>
93-
class Setter<E, uint64_t> : public Command {
93+
class Setter<E, std::uint64_t> : public Command {
9494
public:
9595
/// Pointer to method that sets parameter of type unsigned long
96-
typedef void (E::*SetterMethod)(const uint64_t &);
96+
typedef void (E::*SetterMethod)(const std::uint64_t &);
9797
/// Constructor
9898
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
9999

@@ -105,17 +105,17 @@ class Setter<E, uint64_t> : public Command {
105105
}; // Class Setter
106106

107107
template <class E>
108-
Setter<E, uint64_t>::Setter(E &entity, SetterMethod setterMethod,
108+
Setter<E, std::uint64_t>::Setter(E &entity, SetterMethod setterMethod,
109109
const std::string &docString)
110110
: Command(entity, boost::assign::list_of(Value::UNSIGNEDLONGINT),
111111
docString),
112112
setterMethod_(setterMethod) {}
113113

114114
template <class E>
115-
Value Setter<E, uint64_t>::doExecute() {
115+
Value Setter<E, std::uint64_t>::doExecute() {
116116
const std::vector<Value> &values = getParameterValues();
117117
// Get parameter
118-
uint64_t value = values[0].value();
118+
std::uint64_t value = values[0].value();
119119
E &entity = static_cast<E &>(owner());
120120
(entity.*setterMethod_)(value);
121121
return Value();
@@ -159,10 +159,10 @@ Value Setter<E, int>::doExecute() {
159159
// Template specialization: int64_t
160160
//
161161
template <class E>
162-
class Setter<E, int64_t> : public Command {
162+
class Setter<E, std::int64_t> : public Command {
163163
public:
164164
/// Pointer to method that sets parameter of type int64_t
165-
typedef void (E::*SetterMethod)(const int64_t &);
165+
typedef void (E::*SetterMethod)(const std::int64_t &);
166166
/// Constructor
167167
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
168168

@@ -174,16 +174,16 @@ class Setter<E, int64_t> : public Command {
174174
}; // Class Setter
175175

176176
template <class E>
177-
Setter<E, int64_t>::Setter(E &entity, SetterMethod setterMethod,
177+
Setter<E, std::int64_t>::Setter(E &entity, SetterMethod setterMethod,
178178
const std::string &docString)
179179
: Command(entity, boost::assign::list_of(Value::LONGINT), docString),
180180
setterMethod_(setterMethod) {}
181181

182182
template <class E>
183-
Value Setter<E, int64_t>::doExecute() {
183+
Value Setter<E, std::int64_t>::doExecute() {
184184
const std::vector<Value> &values = getParameterValues();
185185
// Get parameter
186-
int64_t value = values[0].value();
186+
std::int64_t value = values[0].value();
187187
E &entity = static_cast<E &>(owner());
188188
(entity.*setterMethod_)(value);
189189
return Value();

include/dynamic-graph/value.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <dynamic-graph/linear-algebra.h>
1111

12+
#include <cstdint>
1213
#include <cassert>
1314
#include <string>
1415
#include <typeinfo>
@@ -26,10 +27,10 @@ class DYNAMIC_GRAPH_DLLAPI EitherType {
2627
EitherType(const Value &value);
2728
~EitherType();
2829
operator bool() const;
29-
operator uint32_t() const;
30-
operator uint64_t() const;
31-
operator int32_t() const;
32-
operator int64_t() const;
30+
operator std::uint32_t() const;
31+
operator std::uint64_t() const;
32+
operator std::int32_t() const;
33+
operator std::int64_t() const;
3334
operator float() const;
3435
operator double() const;
3536
operator std::string() const;
@@ -68,10 +69,10 @@ class DYNAMIC_GRAPH_DLLAPI Value {
6869
~Value();
6970
void deleteValue();
7071
explicit Value(const bool &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);
72+
explicit Value(const std::uint32_t &value);
73+
explicit Value(const std::uint64_t &value);
74+
explicit Value(const std::int32_t &value);
75+
explicit Value(const std::int64_t &value);
7576
explicit Value(const float &value);
7677
explicit Value(const double &value);
7778
explicit Value(const std::string &value);
@@ -112,10 +113,10 @@ class DYNAMIC_GRAPH_DLLAPI Value {
112113
public:
113114
friend class EitherType;
114115
bool boolValue() const;
115-
uint32_t unsignedValue() const;
116-
uint64_t unsignedlongintValue() const;
117-
int32_t intValue() const;
118-
int64_t longintValue() const;
116+
std::uint32_t unsignedValue() const;
117+
std::uint64_t unsignedlongintValue() const;
118+
std::int32_t intValue() const;
119+
std::int64_t longintValue() const;
119120
float floatValue() const;
120121
double doubleValue() const;
121122
std::string stringValue() const;

src/command/value.cpp

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

2323
EitherType::operator bool() const { return value_->boolValue(); }
24-
EitherType::operator uint32_t() const { return value_->unsignedValue(); }
25-
EitherType::operator uint64_t() const { return value_->unsignedlongintValue(); }
26-
EitherType::operator int32_t() const { return value_->intValue(); }
27-
EitherType::operator int64_t() const { return value_->longintValue(); }
24+
EitherType::operator std::uint32_t() const { return value_->unsignedValue(); }
25+
EitherType::operator std::uint64_t() const { return value_->unsignedlongintValue(); }
26+
EitherType::operator std::int32_t() const { return value_->intValue(); }
27+
EitherType::operator std::int64_t() const { return value_->longintValue(); }
2828
EitherType::operator float() const { return value_->floatValue(); }
2929
EitherType::operator double() const { return value_->doubleValue(); }
3030
EitherType::operator std::string() const { return value_->stringValue(); }
@@ -40,16 +40,16 @@ void Value::deleteValue() {
4040
delete (const bool *)value_;
4141
break;
4242
case UNSIGNED:
43-
delete (const uint32_t *)value_;
43+
delete (const std::uint32_t *)value_;
4444
break;
4545
case UNSIGNEDLONGINT:
46-
delete (const uint64_t *)value_;
46+
delete (const std::uint64_t *)value_;
4747
break;
4848
case INT:
49-
delete (const int32_t *)value_;
49+
delete (const std::int32_t *)value_;
5050
break;
5151
case LONGINT:
52-
delete (const int64_t *)value_;
52+
delete (const std::int64_t *)value_;
5353
break;
5454
case FLOAT:
5555
delete (const float *)value_;
@@ -83,12 +83,12 @@ void Value::deleteValue() {
8383
Value::~Value() { deleteValue(); }
8484

8585
Value::Value(const bool &value) : type_(BOOL), value_(new bool(value)) {}
86-
Value::Value(const uint32_t &value)
87-
: type_(UNSIGNED), value_(new uint32_t(value)) {}
88-
Value::Value(const uint64_t &value)
89-
: type_(UNSIGNEDLONGINT), value_(new uint64_t(value)) {}
90-
Value::Value(const int32_t &value) : type_(INT), value_(new int32_t(value)) {}
91-
Value::Value(const int64_t &value)
86+
Value::Value(const std::uint32_t &value)
87+
: type_(UNSIGNED), value_(new std::uint32_t(value)) {}
88+
Value::Value(const std::uint64_t &value)
89+
: type_(UNSIGNEDLONGINT), value_(new std::uint64_t(value)) {}
90+
Value::Value(const std::int32_t &value) : type_(INT), value_(new std::int32_t(value)) {}
91+
Value::Value(const std::int64_t &value)
9292
: type_(LONGINT), value_(new int64_t(value)) {}
9393
Value::Value(const float &value) : type_(FLOAT), value_(new float(value)) {}
9494
Value::Value(const double &value) : type_(DOUBLE), value_(new double(value)) {}
@@ -206,25 +206,25 @@ bool Value::boolValue() const {
206206
throw ExceptionAbstract(ExceptionAbstract::TOOLS, "value is not an bool");
207207
}
208208

209-
uint32_t Value::unsignedValue() const {
210-
if (type_ == UNSIGNED) return *((const uint32_t *)value_);
209+
std::uint32_t Value::unsignedValue() const {
210+
if (type_ == UNSIGNED) return *((const std::uint32_t *)value_);
211211
throw ExceptionAbstract(ExceptionAbstract::TOOLS,
212212
"value is not an unsigned int");
213213
}
214214

215-
uint64_t Value::unsignedlongintValue() const {
216-
if (type_ == UNSIGNEDLONGINT) return *((const uint64_t *)value_);
215+
std::uint64_t Value::unsignedlongintValue() const {
216+
if (type_ == UNSIGNEDLONGINT) return *((const std::uint64_t *)value_);
217217
throw ExceptionAbstract(ExceptionAbstract::TOOLS,
218218
"value is not an unsigned long int");
219219
}
220220

221-
int64_t Value::longintValue() const {
222-
if (type_ == LONGINT) return *((const int64_t *)value_);
221+
std::int64_t Value::longintValue() const {
222+
if (type_ == LONGINT) return *((const std::int64_t *)value_);
223223
throw ExceptionAbstract(ExceptionAbstract::TOOLS, "value is not an long int");
224224
}
225225

226-
int32_t Value::intValue() const {
227-
if (type_ == INT) return *((const int32_t *)value_);
226+
std::int32_t Value::intValue() const {
227+
if (type_ == INT) return *((const std::int32_t *)value_);
228228
throw ExceptionAbstract(ExceptionAbstract::TOOLS, "value is not an int");
229229
}
230230

@@ -356,13 +356,13 @@ std::ostream &operator<<(std::ostream &os, const Value &value) {
356356
template <>
357357
const Value::Type ValueHelper<bool>::TypeID = Value::BOOL;
358358
template <>
359-
const Value::Type ValueHelper<uint32_t>::TypeID = Value::UNSIGNED;
359+
const Value::Type ValueHelper<std::uint32_t>::TypeID = Value::UNSIGNED;
360360
template <>
361-
const Value::Type ValueHelper<uint64_t>::TypeID = Value::UNSIGNEDLONGINT;
361+
const Value::Type ValueHelper<std::uint64_t>::TypeID = Value::UNSIGNEDLONGINT;
362362
template <>
363-
const Value::Type ValueHelper<int32_t>::TypeID = Value::INT;
363+
const Value::Type ValueHelper<std::int32_t>::TypeID = Value::INT;
364364
template <>
365-
const Value::Type ValueHelper<int64_t>::TypeID = Value::LONGINT;
365+
const Value::Type ValueHelper<std::int64_t>::TypeID = Value::LONGINT;
366366
template <>
367367
const Value::Type ValueHelper<float>::TypeID = Value::FLOAT;
368368
template <>

0 commit comments

Comments
 (0)