Program Listing for File CStringHelper.h

Return to documentation for file (src/desert_classes/CStringHelper.h)

/****************************************************************************
 * Copyright (C) 2024 Davide Costa                                          *
 *                                                                          *
 * This file is part of RMW desert.                                         *
 *                                                                          *
 *   RMW desert 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 any      *
 *   later version.                                                         *
 *                                                                          *
 *   RMW desert 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 RMW desert.  If not, see <http://www.gnu.org/licenses/>.    *
 ****************************************************************************/

#ifndef CSTRING_HELPER_H_
#define CSTRING_HELPER_H_

#include "rosidl_runtime_c/u16string.h"
#include "rosidl_runtime_c/string.h"
#include "rosidl_runtime_c/u16string_functions.h"
#include "rosidl_runtime_c/string_functions.h"

#include <stdexcept>
#include <vector>
#include <string>

namespace CStringHelper
{
  std::string convert_to_std_string(void * str);
  std::vector<std::string> convert_to_std_vector_string(void * str_array, size_t size);
  std::vector<std::string> convert_sequence_to_std_vector_string(void * str_seq);

  std::u16string convert_to_std_u16string(void * str);
  std::vector<std::u16string> convert_to_std_vector_u16string(void * str_array, size_t size);
  std::vector<std::u16string> convert_sequence_to_std_vector_u16string(void * str_seq);

  void assign_string(std::string str, void * field);
  void assign_vector_string(std::vector<std::string> cpp_string_vector, void * str_array, size_t size);
  void assign_vector_string_to_sequence(std::vector<std::string> cpp_string_vector, void * str_seq);

  void assign_u16string(std::u16string str, void * field);
  void assign_vector_u16string(std::vector<std::u16string> cpp_string_vector, void * str_array, size_t size);
  void assign_vector_u16string_to_sequence(std::vector<std::u16string> cpp_string_vector, void * str_seq);
}


#endif