// This file is part of PyCPL the ESO CPL Python language bindings
// Copyright (C) 2020-2026 European Southern Observatory
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

#include "cplcore/array.hpp"

#include <string>

namespace cpl
{
namespace core
{

template <>
int*
cpl_array_get_data(cpl_array* array)
{
  return cpl_array_get_data_int(array);
}

template <>
long long*
cpl_array_get_data(cpl_array* array)
{
  return cpl_array_get_data_long_long(array);
}

template <>
float*
cpl_array_get_data(cpl_array* array)
{
  return cpl_array_get_data_float(array);
}

template <>
double*
cpl_array_get_data(cpl_array* array)
{
  return cpl_array_get_data_double(array);
}

template <>
float _Complex*
cpl_array_get_data(cpl_array* array)
{
  return cpl_array_get_data_float_complex(array);
}

template <>
double _Complex*
cpl_array_get_data(cpl_array* array)
{
  return cpl_array_get_data_double_complex(array);
}

template <>
std::vector<std::string>
cpl_array_as_vector<std::string>(cpl_array* input)
{
  char** array_data = cpl_array_get_data_string(input);
  size array_size = cpl_array_get_size(input);
  std::vector<std::string> vec(array_size);
  for (int i = 0; i < array_size; ++i) {
    vec[i] = std::string(array_data[i]);
  }
  return vec;
}

}  // namespace core
}  // namespace cpl