Lines Matching refs:attribute
16 #include "attribute.h"
192 IAM_STATIC ResultCode ParseAttributeSerializedMsgInner(Attribute *attribute, const Uint8Array msg,
206 LOG_INFO("attribute:%{public}u too long:%{public}u, skip", type, length);
220 LOG_INFO("attribute:%{public}u not found, skip", type);
224 ResultCode setAttrResult = SetAttributeUint8Array(attribute, type, readData);
231 IAM_STATIC ResultCode ParseAttributeSerializedMsg(Attribute *attribute, const Uint8Array msg)
236 ResultCode result = ParseAttributeSerializedMsgInner(attribute, msg, readBuffer);
247 AttributeImpl *attribute = Malloc(sizeof(AttributeImpl));
248 IF_TRUE_LOGE_AND_RETURN_VAL(attribute == NULL, NULL);
249 (void)memset_s(attribute, sizeof(AttributeImpl), 0, sizeof(AttributeImpl));
251 return attribute;
258 Attribute *attribute = CreateEmptyAttribute();
259 if (attribute == NULL) {
264 ResultCode result = ParseAttributeSerializedMsg(attribute, msg);
267 FreeAttribute((Attribute **)&attribute);
271 return attribute;
280 const AttributeImpl *attribute = (const AttributeImpl *)attributePublic;
283 Uint8Array *array = attribute->values[i];
306 void FreeAttribute(Attribute **attribute)
308 IF_TRUE_LOGE_AND_RETURN(attribute == NULL);
309 IF_TRUE_LOGE_AND_RETURN(*attribute == NULL);
310 AttributeImpl *impl = (AttributeImpl *)*attribute;
315 IAM_FREE_AND_SET_NULL(*attribute);
318 ResultCode GetAttributeUint32(const Attribute *attribute, AttributeKey key, uint32_t *value)
320 IF_TRUE_LOGE_AND_RETURN_VAL(attribute == NULL, RESULT_BAD_PARAM);
325 ResultCode getAttrResult = GetAttributeUint8Array(attribute, key, &uint32Data);
333 ResultCode SetAttributeUint32(Attribute *attribute, AttributeKey key, const uint32_t value)
335 IF_TRUE_LOGE_AND_RETURN_VAL(attribute == NULL, RESULT_BAD_PARAM);
339 SetAttributeUint8Array(attribute, key, (Uint8Array) { (uint8_t *)&netOrderValue, sizeof(netOrderValue) });
345 ResultCode GetAttributeInt32(const Attribute *attribute, AttributeKey key, int32_t *retValue)
347 IF_TRUE_LOGE_AND_RETURN_VAL(attribute == NULL, RESULT_BAD_PARAM);
350 return GetAttributeUint32(attribute, key, (uint32_t *)retValue);
353 ResultCode SetAttributeInt32(Attribute *attribute, AttributeKey key, const int32_t value)
355 IF_TRUE_LOGE_AND_RETURN_VAL(attribute == NULL, RESULT_BAD_PARAM);
357 return SetAttributeUint32(attribute, key, (uint32_t)value);
360 ResultCode GetAttributeUint64(const Attribute *attribute, AttributeKey key, uint64_t *retValue)
362 IF_TRUE_LOGE_AND_RETURN_VAL(attribute == NULL, RESULT_BAD_PARAM);
367 ResultCode getAttrResult = GetAttributeUint8Array(attribute, key, &uint64Data);
375 ResultCode SetAttributeUint64(Attribute *attribute, AttributeKey key, const uint64_t value)
377 IF_TRUE_LOGE_AND_RETURN_VAL(attribute == NULL, RESULT_BAD_PARAM);
381 SetAttributeUint8Array(attribute, key, (Uint8Array){ (uint8_t *)&netOrderValue, sizeof(netOrderValue) });
387 ResultCode GetAttributeLength(const Attribute *attribute, AttributeKey key, uint32_t *len)
389 IF_TRUE_LOGE_AND_RETURN_VAL(attribute == NULL, RESULT_BAD_PARAM);
392 const AttributeImpl *attributePri = (const AttributeImpl *)attribute;
411 const AttributeImpl *attribute = (const AttributeImpl *)attributePub;
417 if (attribute->values[attributeIndex] == NULL) {
422 if (attribute->values[attributeIndex]->data != NULL && attribute->values[attributeIndex]->len != 0) {
423 errno_t memcpyRet = memcpy_s(retData->data, retData->len, attribute->values[attributeIndex]->data,
424 attribute->values[attributeIndex]->len);
426 retData->len = attribute->values[attributeIndex]->len;
440 AttributeImpl *attribute = (AttributeImpl *)attributePub;
446 DestroyUint8Array(&attribute->values[attributeIndex]);
447 attribute->values[attributeIndex] = CreateUint8ArrayByData(data.data, data.len);
448 if (attribute->values[attributeIndex] == NULL) {
456 ResultCode GetAttributeUint64Array(const Attribute *attribute, AttributeKey key, Uint64Array *retData)
458 IF_TRUE_LOGE_AND_RETURN_VAL(attribute == NULL, RESULT_BAD_PARAM);
463 ResultCode getAttrResult = GetAttributeUint8Array(attribute, key, &uint64ArrayData);
475 ResultCode SetAttributeUint64Array(Attribute *attribute, AttributeKey key, const Uint64Array data)
477 IF_TRUE_LOGE_AND_RETURN_VAL(attribute == NULL, RESULT_BAD_PARAM);
490 result = SetAttributeUint8Array(attribute, key,