Skip to content

Commit 98ce7da

Browse files
committed
cpp scripts
1 parent 0acf6bf commit 98ce7da

File tree

2 files changed

+644
-681
lines changed

2 files changed

+644
-681
lines changed

c/uwapi/uwapi/scripts.hpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#ifndef unnatural_uwapi_scripts_hpp_zhgfa8g4
2+
#define unnatural_uwapi_scripts_hpp_zhgfa8g4
3+
4+
#include <vector>
5+
6+
#include "scripts.h"
7+
8+
namespace uw
9+
{
10+
template<class T>
11+
auto makeVector(T *data, uint32 cnt)
12+
{
13+
std::vector<std::remove_cv_t<T>> res;
14+
res.resize(cnt);
15+
memcpy(res.data(), data, cnt * sizeof(T));
16+
return res;
17+
}
18+
19+
template<class S>
20+
requires(requires { S::data; })
21+
auto makeVector(const S *src)
22+
{
23+
return makeVector(src->data, src->count);
24+
}
25+
26+
inline auto makeVector(const UwIds &ids)
27+
{
28+
return makeVector(ids.ids, ids.count);
29+
}
30+
31+
inline auto allEntities()
32+
{
33+
UwIds ids;
34+
uwAllEntities(&ids);
35+
return makeVector(ids);
36+
}
37+
}
38+
39+
#endif // unnatural_uwapi_scripts_hpp_zhgfa8g4

0 commit comments

Comments
 (0)