Commit cbc9e5be authored by Frederick Zhang's avatar Frederick Zhang

use long instead of string for searching mode

parent b3bc81de
......@@ -302,11 +302,14 @@ zval * bdict::to_array(const bool include_meta) const {
return zv;
}
zval * bdict::search(const std::string &needle, const std::string &mode, const std::string path) const {
bool modek = (mode.find('k') == std::string::npos) ? false : true;
bool modev = (mode.find('v') == std::string::npos) ? false : true;
if (!(modek || modev))
zval * bdict::search(const std::string &needle, const long &mode, const std::string path) const {
if (mode < 0 || mode > 1)
bitem::throw_general_exception("Illegal search mode");
bool modek = false, modev = false;
if (mode == 0)
modek = true;
else
modev = true;
zval _zv;
zval *zv = &_zv;
......
......@@ -31,7 +31,7 @@ class bdict : 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 std::string &mode, const std::string path) const;
zval * search(const std::string &needle, const long &mode, const std::string path) const;
};
#endif
......@@ -68,6 +68,6 @@ zval * bint::to_array(const bool include_meta) const {
return zv;
}
zval * bint::search(const std::string &needle, const std::string &mode, const std::string path) const {
zval * bint::search(const std::string &needle, const long &mode, const std::string path) const {
return nullptr;
}
......@@ -28,7 +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 std::string &mode, const std::string path) const;
zval * search(const std::string &needle, const long &mode, const std::string path) const;
};
#endif
......@@ -28,7 +28,8 @@ class bitem {
virtual std::string encode() const = 0;
static zval * load(const std::string &file_path);
void save(const std::string &file_path) const;
virtual zval * search(const std::string &needle, const std::string &mode, const std::string path) const = 0;
// mode 0: search in keys; mode 1: search in values
virtual zval * search(const std::string &needle, const long &mode, const std::string path) const = 0;
};
#endif
......@@ -323,11 +323,14 @@ zval * blist::to_array(const bool include_meta) const {
return zv;
}
zval * blist::search(const std::string &needle, const std::string &mode, const std::string path) const {
bool modek = (mode.find('k') == std::string::npos) ? false : true;
bool modev = (mode.find('v') == std::string::npos) ? false : true;
if (!(modek || modev))
zval * blist::search(const std::string &needle, const long &mode, const std::string path) const {
if (mode < 0 || mode > 1)
bitem::throw_general_exception("Illegal search mode");
bool modek = false, modev = false;
if (mode == 0)
modek = true;
else
modev = true;
zval _zv;
zval *zv = &_zv;
......
......@@ -32,7 +32,7 @@ class blist : 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 std::string &mode, const std::string path) const;
zval * search(const std::string &needle, const long &mode, const std::string path) const;
};
#endif
......@@ -72,6 +72,6 @@ zval * bstr::to_array(const bool include_meta) const {
return zv;
}
zval * bstr::search(const std::string &needle, const std::string &mode, const std::string path) const {
zval * bstr::search(const std::string &needle, const long &mode, const std::string path) const {
return nullptr;
}
......@@ -28,7 +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 std::string &mode, const std::string path) 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