Skip to content

Commit

Permalink
Add overloads to JSON::Value to allow assignment of size_t types (DDV…
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-dyfis-net committed Nov 23, 2024
1 parent 7a3fd0c commit 695e2be
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,11 @@ JSON::Value::Value(int64_t val){
myType = INTEGER;
intVal = val;
}
/// Sets this JSON::Value to the given integer.
JSON::Value::Value(size_t val){
myType = INTEGER;
intVal = val;
}

/// Sets this JSON::Value to the given double.
JSON::Value::Value(double val){
Expand Down Expand Up @@ -692,6 +697,11 @@ JSON::Value &JSON::Value::operator=(const uint64_t &rhs){
return ((*this) = (int64_t)rhs);
}

/// Sets this JSON::Value to the given integer.
JSON::Value &JSON::Value::operator=(const size_t &rhs){
return ((*this) = (int64_t)rhs);
}

/// Sets this JSON::Value to the given double.
JSON::Value &JSON::Value::operator=(const double &rhs){
null();
Expand Down
2 changes: 2 additions & 0 deletions lib/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ namespace JSON{
Value(int64_t val);
Value(uint32_t val);
Value(uint64_t val);
Value(size_t val);
Value(double val);
Value(bool val);
// comparison operators
Expand All @@ -63,6 +64,7 @@ namespace JSON{
Value &operator=(const int32_t &rhs);
Value &operator=(const uint64_t &rhs);
Value &operator=(const uint32_t &rhs);
Value &operator=(const size_t &rhs);
Value &operator=(const double &rhs);
Value &operator=(const bool &rhs);
// converts to basic types
Expand Down

0 comments on commit 695e2be

Please sign in to comment.