Skip to content

Commit

Permalink
refactor(libsinsp): set filterstring optionally
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Scolaro <roberto.scolaro21@gmail.com>
  • Loading branch information
therealbobo committed Aug 5, 2024
1 parent ddce334 commit f5c20e4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
10 changes: 2 additions & 8 deletions userspace/libsinsp/sinsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1661,7 +1661,7 @@ void sinsp::start_dropping_mode(uint32_t sampling_ratio)
}
#endif // _WIN32

void sinsp::set_filter(std::unique_ptr<sinsp_filter> filter)
void sinsp::set_filter(std::unique_ptr<sinsp_filter> filter, const std::optional<std::string>& filterstring)

Check warning on line 1664 in userspace/libsinsp/sinsp.cpp

View check run for this annotation

Codecov / codecov/patch

userspace/libsinsp/sinsp.cpp#L1664

Added line #L1664 was not covered by tests
{
if(m_filter != NULL)
{
Expand All @@ -1670,6 +1670,7 @@ void sinsp::set_filter(std::unique_ptr<sinsp_filter> filter)
}

m_filter = std::move(filter);
m_filterstring = filterstring.value_or("");
}

void sinsp::set_filter(const std::string& filter)
Expand All @@ -1686,13 +1687,6 @@ void sinsp::set_filter(const std::string& filter)
m_internal_flt_ast = compiler.get_filter_ast();
}

void sinsp::set_filter(const std::string& filterstring, std::unique_ptr<sinsp_filter> filter)
{
set_filter(std::move(filter));
m_filterstring = filterstring;
}


std::string sinsp::get_filter() const
{
return m_filterstring;
Expand Down
13 changes: 1 addition & 12 deletions userspace/libsinsp/sinsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,18 +303,7 @@ class SINSP_PUBLIC sinsp : public capture_stats_source
\param filter the runtime filter object
*/
void set_filter(std::unique_ptr<sinsp_filter> filter);

/*!
\brief Installs the given capture runtime filter object and accordingly
sets the filter string.
\param filter the filter string. Refer to the filtering language
section for information about the filtering
syntax.
\param filter the runtime filter object
*/
void set_filter(const std::string& filterstring, std::unique_ptr<sinsp_filter> filter);
void set_filter(std::unique_ptr<sinsp_filter> filter, const std::optional<std::string>& filterstring);

/*!
\brief Return the filter set for this capture.
Expand Down

0 comments on commit f5c20e4

Please sign in to comment.