Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add overloads to JSON::Value to allow assignment of size_t types (#214) #215

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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