mirror of
https://github.com/nasa/trick.git
synced 2025-05-30 14:14:35 +00:00
* Added interface file includes for C++ types supported by swig * Testing swig interface includes * Inital pass at testing STL access via input file for swig interface file update * Updated test comparison for keys() return function that swig generates for std::map. Added SIM_test_ip_stl to the trickops yml file * Updated trick_swig.i to remove redundant includes * Renamed input file for SIM_test_ip_stL * Added typemap so swig can convert from C++ std::string pointer to python string * Commented out some %include .i files. Also commented out %import for unordered_map as not supported by swig3 in the test code. * Removed duplicated includes and added checking swig version for some .i files. * Moved std_sstream.i to the right place as the order matters. * Moved all work in progress .i files in swig 3 to swig 4 block. * Removed unused files and added proper purposes for header files. * Updated vector of char16_t and char32_t tests. --------- Co-authored-by: Hong Chen <hchen99@users.noreply.github.com> Co-authored-by: mherr <mherr@pop-os.lan>
104 lines
3.0 KiB
C++
104 lines
3.0 KiB
C++
/*
|
|
PURPOSE: (Defines the STLIPTest class, which serves as a testbed for various STL
|
|
container types instantiated with C++ types such as int, double, char, etc.)
|
|
LIBRARY_DEPENDENCIES: (
|
|
()
|
|
)
|
|
*/
|
|
|
|
#ifndef STL_IP_TEST_HH
|
|
#define STL_IP_TEST_HH
|
|
|
|
#include <iostream>
|
|
#include <cstdint>
|
|
#include <cuchar>
|
|
|
|
#include <list>
|
|
#include <queue>
|
|
#include <deque>
|
|
|
|
#include <map>
|
|
#include <unordered_map>
|
|
|
|
#include <set>
|
|
#include <unordered_set>
|
|
|
|
#include <array>
|
|
#include <vector>
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
#include <cstddef>
|
|
|
|
#include "test_classes/include/container_types.hh"
|
|
|
|
struct TestStructure
|
|
{
|
|
int a;
|
|
double b;
|
|
|
|
};
|
|
|
|
class STLIPTest
|
|
{
|
|
friend class InputProcessor;
|
|
|
|
public:
|
|
STLIPTest() = default;
|
|
~STLIPTest() = default;
|
|
|
|
//STLs
|
|
//Char Types
|
|
|
|
//inline char16_t to_char16_t(char c) {return static_cast<char16_t>(c);}
|
|
|
|
// Python doesn't have a char16_t type, so we use int for compatibility
|
|
// Add a character to the vector (accepts int for Python compatibility)
|
|
void addCharToVector(std::vector<char16_t>& vec, int value) {
|
|
vec.push_back(static_cast<char16_t>(value));
|
|
}
|
|
// Get a character from the vector (returns as int for Python compatibility)
|
|
int getCharFromVector(std::vector<char16_t>& vec, size_t index) {
|
|
if (index >= vec.size()) {
|
|
// Handle out of bounds access
|
|
throw std::out_of_range("Index out of bounds");
|
|
}
|
|
// Convert char16_t to int when returning to Python
|
|
return static_cast<int>(vec[index]);
|
|
}
|
|
|
|
// Python doesn't have a char32_t type, so we use int for compatibility
|
|
// Add a character to the vector (accepts int for Python compatibility)
|
|
void addCharToVector(std::vector<char32_t>& vec, int value) {
|
|
vec.push_back(static_cast<char32_t>(value));
|
|
}
|
|
// Get a character from the vector (returns as int for Python compatibility)
|
|
int getCharFromVector(std::vector<char32_t>& vec, size_t index) {
|
|
if (index >= vec.size()) {
|
|
// Handle out of bounds access
|
|
throw std::out_of_range("Index out of bounds");
|
|
}
|
|
// Convert char16_t to int when returning to Python
|
|
return static_cast<int>(vec[index]);
|
|
}
|
|
|
|
STLContainerTypes<char> char_types;
|
|
STLContainerTypes<signed char> signed_char_types;
|
|
STLContainerTypes<unsigned char> unsigned_char_types;
|
|
STLContainerTypes<char16_t> char16_t_types;
|
|
STLContainerTypes<char32_t> char32_t_types;
|
|
STLContainerTypes<short int> short_int_types;
|
|
STLContainerTypes<unsigned short int> unsigned_short_int_types;
|
|
STLContainerTypes<int> int_types;
|
|
STLContainerTypes<unsigned int> unsigned_int_types;
|
|
STLContainerTypes<long int> long_int_types;
|
|
STLContainerTypes<unsigned long int> unsigned_long_int_types;
|
|
STLContainerTypes<long long int> long_long_int_types;
|
|
STLContainerTypes<unsigned long long int> unsigned_long_long_int_types;
|
|
STLContainerTypes<float> float_types;
|
|
STLContainerTypes<double> double_types;
|
|
STLContainerTypes<long double> long_double_types;
|
|
};
|
|
|
|
#endif |