framework/src/st_things/st_things_representation.c
//--------------------------------------------------------------------------------
/**
 * Api definition for creating the instance of representation internally.
 */
Api definition for creating the instance of representation internally.
Api definition for creating the instance of representation internally .
st_things_representation_s *create_representation_inst_internal(OCRepPayload *payload)
{
	st_things_representation_s *rep = (st_things_representation_s *) things_malloc(sizeof(st_things_representation_s));
	RET_VAL_IF_NULL(TAG, rep, "Failed to allocate memory for representation.", NULL);
	rep->get_str_value = &get_str_value;
	rep->get_bool_value = &get_bool_value;
	rep->get_int_value = &get_int_value;
	rep->get_double_value = &get_double_value;
	rep->get_byte_value = &get_byte_value;
	rep->get_object_value = &get_object_value;
	rep->set_str_value = &set_str_value;
	rep->set_bool_value = &set_bool_value;
	rep->set_int_value = &set_int_value;
	rep->set_double_value = &set_double_value;
	rep->set_byte_value = &set_byte_value;
	rep->set_object_value = &set_object_value;
	rep->get_str_array_value = &get_str_array_value;
	rep->get_int_array_value = &get_int_array_value;
	rep->get_double_array_value = &get_double_array_value;
	rep->get_object_array_value = &get_object_array_value;
	rep->set_str_array_value = &set_str_array_value;
	rep->set_int_array_value = &set_int_array_value;
	rep->set_double_array_value = &set_double_array_value;
	rep->set_object_array_value = &set_object_array_value;
	if (NULL != payload) {
		THINGS_LOG_D(TAG, "Setting the given payload in the representation.");
		rep->payload = payload;
	} else {
		THINGS_LOG_D(TAG, "Creating a new payload and setting it in the representation.");
		rep->payload = OCRepPayloadCreate();
		if (NULL == rep->payload) {
			THINGS_LOG_E(TAG, "Failed to create payload for representation.");
			destroy_representation_inst_internal(rep, false);
			return NULL;
		}
	}
	return rep;
}
st_things_representation_s * create_representation_inst_internal ( OCRepPayload * payload ) { st_things_representation_s * rep = ( st_things_representation_s * ) things_malloc ( sizeof ( st_things_representation_s ) ) ; RET_VAL_IF_NULL ( TAG , rep , " " , NULL ) ; rep -> get_str_value = & get_str_value ; rep -> get_bool_value = & get_bool_value ; rep -> get_int_value = & get_int_value ; rep -> get_double_value = & get_double_value ; rep -> get_byte_value = & get_byte_value ; rep -> get_object_value = & get_object_value ; rep -> set_str_value = & set_str_value ; rep -> set_bool_value = & set_bool_value ; rep -> set_int_value = & set_int_value ; rep -> set_double_value = & set_double_value ; rep -> set_byte_value = & set_byte_value ; rep -> set_object_value = & set_object_value ; rep -> get_str_array_value = & get_str_array_value ; rep -> get_int_array_value = & get_int_array_value ; rep -> get_double_array_value = & get_double_array_value ; rep -> get_object_array_value = & get_object_array_value ; rep -> set_str_array_value = & set_str_array_value ; rep -> set_int_array_value = & set_int_array_value ; rep -> set_double_array_value = & set_double_array_value ; rep -> set_object_array_value = & set_object_array_value ; if ( NULL != payload ) { THINGS_LOG_D ( TAG , " " ) ; rep -> payload = payload ; } else { THINGS_LOG_D ( TAG , " " ) ; rep -> payload = OCRepPayloadCreate ( ) ; if ( NULL == rep -> payload ) { THINGS_LOG_E ( TAG , " " ) ; destroy_representation_inst_internal ( rep , false ) ; return NULL ; } } return rep ; }
Api definition for creating the instance of representation internally.
Api definition for creating the instance of representation internally .