Browse Source

[Project] Allow to extract augmentation values

tags/3.3
Vsevolod Stakhov 1 year ago
parent
commit
c256285b71
No account linked to committer's email address
2 changed files with 29 additions and 0 deletions
  1. 15
    0
      src/libserver/symcache/symcache_item.cxx
  2. 14
    0
      src/libserver/symcache/symcache_item.hxx

+ 15
- 0
src/libserver/symcache/symcache_item.cxx View File

@@ -500,6 +500,21 @@ cache_item::get_augmentation_weight() const -> int
});
}

auto cache_item::get_numeric_augmentation(std::string_view name) const -> std::optional<double>
{
const auto augmentation_value_maybe = rspamd::find_map(this->augmentations, name);

if (augmentation_value_maybe.has_value()) {
const auto &augmentation = augmentation_value_maybe.value().get();

if (std::holds_alternative<double>(augmentation.value)) {
return std::get<double>(augmentation.value);
}
}

return std::nullopt;
}


auto virtual_item::get_parent(const symcache &cache) const -> const cache_item *
{

+ 14
- 0
src/libserver/symcache/symcache_item.hxx View File

@@ -417,6 +417,20 @@ public:
*/
auto get_augmentation_weight() const -> int;

/**
* Returns numeric augmentation value
* @param name
* @return
*/
auto get_numeric_augmentation(std::string_view name) const -> std::optional<double>;

/**
* Returns string augmentation value
* @param name
* @return
*/
auto get_string_augmentation(std::string_view name) const -> std::optional<std::string_view>;

/**
* Add a virtual symbol as a child of some normal symbol
* @param ptr

Loading…
Cancel
Save