patterns: Unified displaying and stringifying string patterns
This commit is contained in:
parent
47fd5bdc00
commit
26a7b3325d
@ -13,11 +13,11 @@ namespace hex::pl {
|
||||
return std::unique_ptr<Pattern>(new PatternString(*this));
|
||||
}
|
||||
|
||||
std::string getValue(prv::Provider *&provider) {
|
||||
std::string getValue(prv::Provider *&provider) const {
|
||||
return this->getValue(provider, this->getSize());
|
||||
}
|
||||
|
||||
std::string getValue(prv::Provider *&provider, size_t size) {
|
||||
std::string getValue(prv::Provider *&provider, size_t size) const {
|
||||
std::vector<u8> buffer(size, 0x00);
|
||||
provider->read(this->getOffset(), buffer.data(), size);
|
||||
return hex::encodeByteString(buffer);
|
||||
@ -28,14 +28,7 @@ namespace hex::pl {
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string toString(prv::Provider *provider) const override {
|
||||
std::string buffer(this->getSize(), 0x00);
|
||||
provider->read(this->getOffset(), buffer.data(), buffer.size());
|
||||
|
||||
std::erase_if(buffer, [](auto c) {
|
||||
return c == 0x00;
|
||||
});
|
||||
|
||||
return buffer;
|
||||
return this->getValue(provider);
|
||||
}
|
||||
|
||||
[[nodiscard]] bool operator==(const Pattern &other) const override { return areCommonPropertiesEqual<decltype(*this)>(other); }
|
||||
|
Loading…
Reference in New Issue
Block a user