// generated from rosidl_generator_c/resource/idl__functions.c.em
// with input from pylon_ros2_camera_interfaces:srv/IssueScheduledActionCommand.idl
// generated code does not contain a copyright notice
#include "pylon_ros2_camera_interfaces/srv/detail/issue_scheduled_action_command__functions.h"

#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>

#include "rcutils/allocator.h"

// Include directives for member types
// Member `broadcast_address`
#include "rosidl_runtime_c/string_functions.h"

bool
pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__init(pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request * msg)
{
  if (!msg) {
    return false;
  }
  // device_key
  // group_key
  // group_mask
  // action_time_ns_from_current_timestamp
  // broadcast_address
  if (!rosidl_runtime_c__String__init(&msg->broadcast_address)) {
    pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__fini(msg);
    return false;
  }
  return true;
}

void
pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__fini(pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request * msg)
{
  if (!msg) {
    return;
  }
  // device_key
  // group_key
  // group_mask
  // action_time_ns_from_current_timestamp
  // broadcast_address
  rosidl_runtime_c__String__fini(&msg->broadcast_address);
}

bool
pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__are_equal(const pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request * lhs, const pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request * rhs)
{
  if (!lhs || !rhs) {
    return false;
  }
  // device_key
  if (lhs->device_key != rhs->device_key) {
    return false;
  }
  // group_key
  if (lhs->group_key != rhs->group_key) {
    return false;
  }
  // group_mask
  if (lhs->group_mask != rhs->group_mask) {
    return false;
  }
  // action_time_ns_from_current_timestamp
  if (lhs->action_time_ns_from_current_timestamp != rhs->action_time_ns_from_current_timestamp) {
    return false;
  }
  // broadcast_address
  if (!rosidl_runtime_c__String__are_equal(
      &(lhs->broadcast_address), &(rhs->broadcast_address)))
  {
    return false;
  }
  return true;
}

bool
pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__copy(
  const pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request * input,
  pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request * output)
{
  if (!input || !output) {
    return false;
  }
  // device_key
  output->device_key = input->device_key;
  // group_key
  output->group_key = input->group_key;
  // group_mask
  output->group_mask = input->group_mask;
  // action_time_ns_from_current_timestamp
  output->action_time_ns_from_current_timestamp = input->action_time_ns_from_current_timestamp;
  // broadcast_address
  if (!rosidl_runtime_c__String__copy(
      &(input->broadcast_address), &(output->broadcast_address)))
  {
    return false;
  }
  return true;
}

pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request *
pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__create()
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request * msg = (pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request *)allocator.allocate(sizeof(pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request), allocator.state);
  if (!msg) {
    return NULL;
  }
  memset(msg, 0, sizeof(pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request));
  bool success = pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__init(msg);
  if (!success) {
    allocator.deallocate(msg, allocator.state);
    return NULL;
  }
  return msg;
}

void
pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__destroy(pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request * msg)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  if (msg) {
    pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__fini(msg);
  }
  allocator.deallocate(msg, allocator.state);
}


bool
pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__Sequence__init(pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__Sequence * array, size_t size)
{
  if (!array) {
    return false;
  }
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request * data = NULL;

  if (size) {
    data = (pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request *)allocator.zero_allocate(size, sizeof(pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request), allocator.state);
    if (!data) {
      return false;
    }
    // initialize all array elements
    size_t i;
    for (i = 0; i < size; ++i) {
      bool success = pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__init(&data[i]);
      if (!success) {
        break;
      }
    }
    if (i < size) {
      // if initialization failed finalize the already initialized array elements
      for (; i > 0; --i) {
        pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__fini(&data[i - 1]);
      }
      allocator.deallocate(data, allocator.state);
      return false;
    }
  }
  array->data = data;
  array->size = size;
  array->capacity = size;
  return true;
}

void
pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__Sequence__fini(pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__Sequence * array)
{
  if (!array) {
    return;
  }
  rcutils_allocator_t allocator = rcutils_get_default_allocator();

  if (array->data) {
    // ensure that data and capacity values are consistent
    assert(array->capacity > 0);
    // finalize all array elements
    for (size_t i = 0; i < array->capacity; ++i) {
      pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__fini(&array->data[i]);
    }
    allocator.deallocate(array->data, allocator.state);
    array->data = NULL;
    array->size = 0;
    array->capacity = 0;
  } else {
    // ensure that data, size, and capacity values are consistent
    assert(0 == array->size);
    assert(0 == array->capacity);
  }
}

pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__Sequence *
pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__Sequence__create(size_t size)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__Sequence * array = (pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__Sequence *)allocator.allocate(sizeof(pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__Sequence), allocator.state);
  if (!array) {
    return NULL;
  }
  bool success = pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__Sequence__init(array, size);
  if (!success) {
    allocator.deallocate(array, allocator.state);
    return NULL;
  }
  return array;
}

void
pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__Sequence__destroy(pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__Sequence * array)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  if (array) {
    pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__Sequence__fini(array);
  }
  allocator.deallocate(array, allocator.state);
}

bool
pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__Sequence__are_equal(const pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__Sequence * lhs, const pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__Sequence * rhs)
{
  if (!lhs || !rhs) {
    return false;
  }
  if (lhs->size != rhs->size) {
    return false;
  }
  for (size_t i = 0; i < lhs->size; ++i) {
    if (!pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__are_equal(&(lhs->data[i]), &(rhs->data[i]))) {
      return false;
    }
  }
  return true;
}

bool
pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__Sequence__copy(
  const pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__Sequence * input,
  pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__Sequence * output)
{
  if (!input || !output) {
    return false;
  }
  if (output->capacity < input->size) {
    const size_t allocation_size =
      input->size * sizeof(pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request);
    pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request * data =
      (pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request *)realloc(output->data, allocation_size);
    if (!data) {
      return false;
    }
    for (size_t i = output->capacity; i < input->size; ++i) {
      if (!pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__init(&data[i])) {
        /* free currently allocated and return false */
        for (; i-- > output->capacity; ) {
          pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__fini(&data[i]);
        }
        free(data);
        return false;
      }
    }
    output->data = data;
    output->capacity = input->size;
  }
  output->size = input->size;
  for (size_t i = 0; i < input->size; ++i) {
    if (!pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Request__copy(
        &(input->data[i]), &(output->data[i])))
    {
      return false;
    }
  }
  return true;
}


// Include directives for member types
// Member `message`
// already included above
// #include "rosidl_runtime_c/string_functions.h"

bool
pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__init(pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response * msg)
{
  if (!msg) {
    return false;
  }
  // success
  // message
  if (!rosidl_runtime_c__String__init(&msg->message)) {
    pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__fini(msg);
    return false;
  }
  return true;
}

void
pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__fini(pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response * msg)
{
  if (!msg) {
    return;
  }
  // success
  // message
  rosidl_runtime_c__String__fini(&msg->message);
}

bool
pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__are_equal(const pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response * lhs, const pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response * rhs)
{
  if (!lhs || !rhs) {
    return false;
  }
  // success
  if (lhs->success != rhs->success) {
    return false;
  }
  // message
  if (!rosidl_runtime_c__String__are_equal(
      &(lhs->message), &(rhs->message)))
  {
    return false;
  }
  return true;
}

bool
pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__copy(
  const pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response * input,
  pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response * output)
{
  if (!input || !output) {
    return false;
  }
  // success
  output->success = input->success;
  // message
  if (!rosidl_runtime_c__String__copy(
      &(input->message), &(output->message)))
  {
    return false;
  }
  return true;
}

pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response *
pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__create()
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response * msg = (pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response *)allocator.allocate(sizeof(pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response), allocator.state);
  if (!msg) {
    return NULL;
  }
  memset(msg, 0, sizeof(pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response));
  bool success = pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__init(msg);
  if (!success) {
    allocator.deallocate(msg, allocator.state);
    return NULL;
  }
  return msg;
}

void
pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__destroy(pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response * msg)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  if (msg) {
    pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__fini(msg);
  }
  allocator.deallocate(msg, allocator.state);
}


bool
pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__Sequence__init(pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__Sequence * array, size_t size)
{
  if (!array) {
    return false;
  }
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response * data = NULL;

  if (size) {
    data = (pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response *)allocator.zero_allocate(size, sizeof(pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response), allocator.state);
    if (!data) {
      return false;
    }
    // initialize all array elements
    size_t i;
    for (i = 0; i < size; ++i) {
      bool success = pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__init(&data[i]);
      if (!success) {
        break;
      }
    }
    if (i < size) {
      // if initialization failed finalize the already initialized array elements
      for (; i > 0; --i) {
        pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__fini(&data[i - 1]);
      }
      allocator.deallocate(data, allocator.state);
      return false;
    }
  }
  array->data = data;
  array->size = size;
  array->capacity = size;
  return true;
}

void
pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__Sequence__fini(pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__Sequence * array)
{
  if (!array) {
    return;
  }
  rcutils_allocator_t allocator = rcutils_get_default_allocator();

  if (array->data) {
    // ensure that data and capacity values are consistent
    assert(array->capacity > 0);
    // finalize all array elements
    for (size_t i = 0; i < array->capacity; ++i) {
      pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__fini(&array->data[i]);
    }
    allocator.deallocate(array->data, allocator.state);
    array->data = NULL;
    array->size = 0;
    array->capacity = 0;
  } else {
    // ensure that data, size, and capacity values are consistent
    assert(0 == array->size);
    assert(0 == array->capacity);
  }
}

pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__Sequence *
pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__Sequence__create(size_t size)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__Sequence * array = (pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__Sequence *)allocator.allocate(sizeof(pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__Sequence), allocator.state);
  if (!array) {
    return NULL;
  }
  bool success = pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__Sequence__init(array, size);
  if (!success) {
    allocator.deallocate(array, allocator.state);
    return NULL;
  }
  return array;
}

void
pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__Sequence__destroy(pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__Sequence * array)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  if (array) {
    pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__Sequence__fini(array);
  }
  allocator.deallocate(array, allocator.state);
}

bool
pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__Sequence__are_equal(const pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__Sequence * lhs, const pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__Sequence * rhs)
{
  if (!lhs || !rhs) {
    return false;
  }
  if (lhs->size != rhs->size) {
    return false;
  }
  for (size_t i = 0; i < lhs->size; ++i) {
    if (!pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__are_equal(&(lhs->data[i]), &(rhs->data[i]))) {
      return false;
    }
  }
  return true;
}

bool
pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__Sequence__copy(
  const pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__Sequence * input,
  pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__Sequence * output)
{
  if (!input || !output) {
    return false;
  }
  if (output->capacity < input->size) {
    const size_t allocation_size =
      input->size * sizeof(pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response);
    pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response * data =
      (pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response *)realloc(output->data, allocation_size);
    if (!data) {
      return false;
    }
    for (size_t i = output->capacity; i < input->size; ++i) {
      if (!pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__init(&data[i])) {
        /* free currently allocated and return false */
        for (; i-- > output->capacity; ) {
          pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__fini(&data[i]);
        }
        free(data);
        return false;
      }
    }
    output->data = data;
    output->capacity = input->size;
  }
  output->size = input->size;
  for (size_t i = 0; i < input->size; ++i) {
    if (!pylon_ros2_camera_interfaces__srv__IssueScheduledActionCommand_Response__copy(
        &(input->data[i]), &(output->data[i])))
    {
      return false;
    }
  }
  return true;
}
