Skip to content

Commit f0a06d0

Browse files
authored
Merge pull request #122 from dchanman/master
Add getPayloadDoubleValue to redfishPayload.h
2 parents 152b3cf + c095727 commit f0a06d0

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

include/redfishPayload.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,17 @@ REDFISH_EXPORT int getPayloadIntValue(redfishPayload* payload);
163163
* @return bool contained in the payload
164164
*/
165165
REDFISH_EXPORT bool getPayloadBoolValue(redfishPayload* payload, bool* is_boolean);
166+
/**
167+
* @brief Get the double value for the payload
168+
*
169+
* If the value of the payload is not a double, *is_double will be set to false and the return value should be considered invalid. Otherwise return
170+
* the double contained in the payload.
171+
*
172+
* @param payload The payload to get the double value of
173+
* @param is_double Pointer whose value will be set to true if the value of the payload is a double
174+
* @return double contained in the payload
175+
*/
176+
REDFISH_EXPORT double getPayloadDoubleValue(redfishPayload* payload, bool* is_double);
166177

167178
/**
168179
* @brief Obtain the node in the payload identified by the specified nodeName

src/payload.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,14 @@ bool getPayloadBoolValue(redfishPayload* payload, bool* is_boolean) {
269269
return json_boolean_value(payload->json);
270270
}
271271

272+
double getPayloadDoubleValue(redfishPayload* payload, bool* is_double) {
273+
if (is_double != NULL)
274+
{
275+
*is_double = json_is_real(payload->json);
276+
}
277+
return json_real_value(payload->json);
278+
}
279+
272280
redfishPayload* getPayloadByNodeName(redfishPayload* payload, const char* nodeName)
273281
{
274282
json_t* value;

0 commit comments

Comments
 (0)