MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / parse_tuple

Function parse_tuple

lite/example/cpp_example/npy.h:285–304  ·  view source on GitHub ↗

Parses the string represenatation of a Python tuple into a vector of its items */

Source from the content-addressed store, hash-verified

283 Parses the string represenatation of a Python tuple into a vector of its items
284 */
285inline std::vector<std::string> parse_tuple(std::string in) {
286 std::vector<std::string> v;
287 const char seperator = ',';
288
289 in = trim(in);
290
291 if ((in.front() == '(') && (in.back() == ')'))
292 in = in.substr(1, in.length() - 2);
293 else {
294 fprintf(stderr, "Invalid Python tuple.");
295 }
296
297 std::istringstream iss(in);
298
299 for (std::string token; std::getline(iss, token, seperator);) {
300 v.push_back(token);
301 }
302
303 return v;
304}
305
306template <typename T>
307inline std::string write_tuple(const std::vector<T>& v) {

Callers 1

parse_headerFunction · 0.70

Calls 4

frontMethod · 0.80
backMethod · 0.80
trimFunction · 0.70
push_backMethod · 0.45

Tested by

no test coverage detected