Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit83cecaa

Browse files
committed
Add parsedate.cpp
1 parente660e0a commit83cecaa

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

‎Jamfile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ local sourceFiles =
163163
TypeConstants.cpp
164164
Architecture.cpp
165165
DateTime.cpp
166+
parsedate.cpp
166167
List.cpp
167168

168169
#Kernel

‎bindings/support/parsedate.cpp‎

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,44 @@
88
namespacepy= pybind11;
99

1010

11-
voiddefine_parsedate(py::module_& m)
11+
// Funzione di esempio che accetta un array di stringhe in stile C
12+
externvoidset_dateformats(constchar **table);
13+
14+
// Converte uno std::vector<char*> in un array di stringhe in stile C
15+
voidset_dateformats_wrapper(const std::vector<std::string>& formats) {
16+
std::vector<constchar*> c_formats;
17+
for (constauto& format : formats) {
18+
c_formats.push_back(format.c_str());
19+
}
20+
c_formats.push_back(nullptr);// Aggiunge un terminatore nullo
21+
22+
set_dateformats(c_formats.data());
23+
}
24+
25+
// Funzione di esempio che restituisce un array di stringhe in stile C
26+
externconstchar **get_dateformats(void);
27+
28+
// Converte l'array di stringhe in stile C in uno std::vector<char*>
29+
std::vector<char*>get_dateformats_wrapper() {
30+
constchar **dateformats =get_dateformats();
31+
std::vector<char*> result;
32+
33+
// Assume che la fine dell'array sia segnata da un puntatore nullo
34+
for (size_t i =0; dateformats[i] !=nullptr; ++i) {
35+
result.push_back(const_cast<char*>(dateformats[i]));
36+
}
37+
38+
return result;
39+
}
40+
41+
PYBIND11_MODULE(parsedate, m)
1242
{
1343
m.def("parsedate", &parsedate,"",py::arg("dateString"),py::arg("now"));
1444

1545
m.def("parsedate_etc", &parsedate_etc,"",py::arg("dateString"),py::arg("now"),py::arg("_storedFlags"));
1646

17-
m.def("set_dateformats", &set_dateformats,"",py::arg("table"));
47+
m.def("set_dateformats", &set_dateformats_wrapper,"",py::arg("table"));
1848

19-
m.def("get_dateformats", &get_dateformats,"",py::arg(""));
49+
m.def("get_dateformats", &get_dateformats_wrapper,"", py::return_value_policy::take_ownership);
2050

2151
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp