Commit bf56ad3a authored by Frederick Zhang's avatar Frederick Zhang

provide "search" in bstr and bint

parent ce13e9f9
......@@ -56,3 +56,13 @@ zval * bint::to_array(const bool include_meta) const {
}
return zv;
}
zval * bint::search(const std::string &needle, const long &mode, const std::string path) const {
zval *zv = new zval();
array_init(zv);
if (mode == 0 && bitem::is_ll(needle) && _value == std::stoll(needle))
add_next_index_stringl(zv, path.c_str(), path.length());
return zv;
}
......@@ -28,6 +28,7 @@ class bint : public bitem {
static zval * parse(const std::string &ben, size_t &pt);
std::string encode() const;
zval * to_array(const bool include_meta) const;
zval * search(const std::string &needle, const long &mode, const std::string path) const;
};
#endif
......@@ -60,3 +60,13 @@ zval * bstr::to_array(const bool include_meta) const {
efree(_data);
return zv;
}
zval * bstr::search(const std::string &needle, const long &mode, const std::string path) const {
zval *zv = new zval();
array_init(zv);
if (mode == 0 && _value.find(needle) != std::string::npos)
add_next_index_stringl(zv, path.c_str(), path.length());
return zv;
}
......@@ -28,6 +28,7 @@ class bstr : public bitem {
static zval * parse(const std::string &ben, size_t &pt);
std::string encode() const;
zval * to_array(const bool include_meta) const;
zval * search(const std::string &needle, const long &mode, const std::string path) const;
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment