MCPcopy Create free account
hub / github.com/citp/BlockSci / AddBytesMethods

Class AddBytesMethods

blockscipy/src/simple/bytes_proxy.cpp:21–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19namespace py = pybind11;
20
21struct AddBytesMethods {
22 template <typename FuncApplication>
23 void operator()(FuncApplication func) {
24 using namespace blocksci;
25 func(method_tag, "startswith", +[](const py::bytes &bytes, const std::string &str) -> bool {
26 auto bytesString = static_cast<std::string>(bytes);
27 return bytesString.find(str, 0) == 0;
28 }, "Returns true if the byte string has the given prefix");
29 func(method_tag, "endswith", +[](const py::bytes &bytes, const std::string &str) -> bool {
30 auto bytesString = static_cast<std::string>(bytes);
31 return bytesString.size() >= str.size() &&
32 bytesString.compare(bytesString.size() - str.size(), str.size(), str) == 0;
33 }, "Returns true if the byte string has the given suffix");
34 }
35};
36
37void addBytesProxyMethods(AllProxyClasses<py::bytes> &cls) {
38 cls.applyToAll(AddProxyMethods{});

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected