HTTPSession's get_int now has a default parameter.

This commit is contained in:
Relintai 2022-07-21 23:55:33 +02:00
parent 129a2a830d
commit a791c8f4b8
2 changed files with 11 additions and 3 deletions

View File

@ -52,10 +52,16 @@ Ref<Reference> HTTPSession::get_reference(const String &key) {
return Ref<Reference>(_data[key]); return Ref<Reference>(_data[key]);
} }
int HTTPSession::get_int(const String &key) { int HTTPSession::get_int(const String &key, const int def) {
// don't lock here // don't lock here
return _data[key]; Variant *v = _data.getptr(key);
if (!v) {
return def;
}
return *v;
} }
void HTTPSession::clear() { void HTTPSession::clear() {

View File

@ -16,6 +16,8 @@
//Add an api for variants, similar to get set_meta, but rw locked. //Add an api for variants, similar to get set_meta, but rw locked.
//Make sure it's obvious that it's not saved. Maybe set_temp_data ... //Make sure it's obvious that it's not saved. Maybe set_temp_data ...
//Also add an RWLock
class HTTPSession : public Reference { class HTTPSession : public Reference {
GDCLASS(HTTPSession, Reference); GDCLASS(HTTPSession, Reference);
@ -34,7 +36,7 @@ public:
const Variant &get_const(const String &key); const Variant &get_const(const String &key);
Object *get_object(const String &key); Object *get_object(const String &key);
Ref<Reference> get_reference(const String &key); Ref<Reference> get_reference(const String &key);
int get_int(const String &key); int get_int(const String &key, const int def = 0);
void clear(); void clear();
void reset(); void reset();