diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2019-05-14 13:07:23 +0200 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2019-05-14 15:15:56 +0000 |
commit | 273f3fa6cee9c215fcdea6b5ee52ad34eb146452 (patch) | |
tree | 45ca1aef7a815f682f7f4f30336369c19d727de8 /src/coap/qcoapoption.h | |
parent | c90feba464526c9d00ccc63c0f372963fffc8d21 (diff) |
Improve the API of QCoapOption
- The RFC specifies the following option formats: empty, opaque, uint
and string. Leave only the construcors for the specified types.
- Rename value getters to reflect the expected value type.
- Move the internally used setter methods to the private class.
This change is based on the feedback from API review.
Change-Id: I0b482770b9c02e64b0f345384ebf58ec29a7e9bc
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/coap/qcoapoption.h')
-rw-r--r-- | src/coap/qcoapoption.h | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/coap/qcoapoption.h b/src/coap/qcoapoption.h index ea9dc3c..ed8ebaf 100644 --- a/src/coap/qcoapoption.h +++ b/src/coap/qcoapoption.h @@ -64,10 +64,9 @@ public: Size1 = 60 }; - QCoapOption(OptionName name = Invalid, const QByteArray &value = QByteArray()); - QCoapOption(OptionName name, QStringView value); - QCoapOption(OptionName name, const char *value); - QCoapOption(OptionName name, quint32 value); + QCoapOption(OptionName name = Invalid, const QByteArray &opaqueValue = QByteArray()); + QCoapOption(OptionName name, const QString &stringValue); + QCoapOption(OptionName name, quint32 intValue); QCoapOption(const QCoapOption &other); QCoapOption(QCoapOption &&other); ~QCoapOption(); @@ -76,8 +75,9 @@ public: QCoapOption &operator=(QCoapOption &&other) Q_DECL_NOTHROW; void swap(QCoapOption &other) Q_DECL_NOTHROW; - QByteArray value() const; - quint32 valueToInt() const; + QByteArray opaqueValue() const; + quint32 uintValue() const; + QString stringValue() const; int length() const; OptionName name() const; bool isValid() const; @@ -85,12 +85,6 @@ public: bool operator==(const QCoapOption &other) const; bool operator!=(const QCoapOption &other) const; -protected: - void setValue(const QByteArray &value); - void setValue(QStringView value); - void setValue(const char *value); - void setValue(quint32 value); - private: QCoapOptionPrivate *d_ptr; |