RpcRequest: fix accessors

This commit is contained in:
Stéphane Lepin 2019-11-15 19:58:57 +01:00
parent 528d81106e
commit d2bb1ddc29
2 changed files with 20 additions and 20 deletions

View File

@ -36,12 +36,12 @@ const QString& RpcRequest::methodName() const
return _methodName; return _methodName;
} }
const obs_data_t* RpcRequest::parameters() const const OBSData RpcRequest::parameters() const
{ {
return _parameters; return OBSData(_parameters);
} }
bool RpcRequest::hasField(QString name, obs_data_type expectedFieldType, obs_data_number_type expectedNumberType) const bool RpcRequest::hasField(QString name, obs_data_type expectedFieldType, obs_data_number_type expectedNumberType) const
{ {
if (!_parameters || name.isEmpty() || name.isNull()) { if (!_parameters || name.isEmpty() || name.isNull()) {
return false; return false;
@ -69,37 +69,37 @@ bool RpcRequest::hasField(QString name, obs_data_type expectedFieldType, obs_dat
return true; return true;
} }
bool RpcRequest::hasBool(QString fieldName) const bool RpcRequest::hasBool(QString fieldName) const
{ {
return this->hasField(fieldName, OBS_DATA_BOOLEAN); return this->hasField(fieldName, OBS_DATA_BOOLEAN);
} }
bool RpcRequest::hasString(QString fieldName) const bool RpcRequest::hasString(QString fieldName) const
{ {
return this->hasField(fieldName, OBS_DATA_STRING); return this->hasField(fieldName, OBS_DATA_STRING);
} }
bool RpcRequest::hasNumber(QString fieldName, obs_data_number_type expectedNumberType) const bool RpcRequest::hasNumber(QString fieldName, obs_data_number_type expectedNumberType) const
{ {
return this->hasField(fieldName, OBS_DATA_NUMBER, expectedNumberType); return this->hasField(fieldName, OBS_DATA_NUMBER, expectedNumberType);
} }
bool RpcRequest::hasInteger(QString fieldName) const bool RpcRequest::hasInteger(QString fieldName) const
{ {
return this->hasNumber(fieldName, OBS_DATA_NUM_INT); return this->hasNumber(fieldName, OBS_DATA_NUM_INT);
} }
bool RpcRequest::hasDouble(QString fieldName) const bool RpcRequest::hasDouble(QString fieldName) const
{ {
return this->hasNumber(fieldName, OBS_DATA_NUM_DOUBLE); return this->hasNumber(fieldName, OBS_DATA_NUM_DOUBLE);
} }
bool RpcRequest::hasArray(QString fieldName) const bool RpcRequest::hasArray(QString fieldName) const
{ {
return this->hasField(fieldName, OBS_DATA_ARRAY); return this->hasField(fieldName, OBS_DATA_ARRAY);
} }
bool RpcRequest::hasObject(QString fieldName) const bool RpcRequest::hasObject(QString fieldName) const
{ {
return this->hasField(fieldName, OBS_DATA_OBJECT); return this->hasField(fieldName, OBS_DATA_OBJECT);
} }

View File

@ -29,17 +29,17 @@ public:
const QString& messageId() const; const QString& messageId() const;
const QString& methodName() const; const QString& methodName() const;
const obs_data_t* parameters() const; const OBSData parameters() const;
bool hasField(QString fieldName, obs_data_type expectedFieldType = OBS_DATA_NULL, const bool hasField(QString fieldName, obs_data_type expectedFieldType = OBS_DATA_NULL,
obs_data_number_type expectedNumberType = OBS_DATA_NUM_INVALID); obs_data_number_type expectedNumberType = OBS_DATA_NUM_INVALID) const;
bool hasBool(QString fieldName); const bool hasBool(QString fieldName) const;
bool hasString(QString fieldName); const bool hasString(QString fieldName) const;
bool hasNumber(QString fieldName, obs_data_number_type expectedNumberType = OBS_DATA_NUM_INVALID); const bool hasNumber(QString fieldName, obs_data_number_type expectedNumberType = OBS_DATA_NUM_INVALID) const;
bool hasInteger(QString fieldName); const bool hasInteger(QString fieldName) const;
bool hasDouble(QString fieldName); const bool hasDouble(QString fieldName) const;
bool hasArray(QString fieldName); const bool hasArray(QString fieldName) const;
bool hasObject(QString fieldName); const bool hasObject(QString fieldName) const;
private: private:
const QString _messageId; const QString _messageId;