Add a compile_output::clone() method that can be overridden

Add a clone() method that can be overridden by subclasses. This allows
copying compile state when needed in a way that preserves
polymorphism.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
This commit is contained in:
Mark Stemm
2024-10-02 08:54:46 -07:00
committed by poiana
parent c55adf38b4
commit 093d9234a5

View File

@@ -20,6 +20,8 @@ limitations under the License.
#include "indexed_vector.h"
#include "falco_rule.h"
#include <memory>
namespace rule_loader {
struct compile_output {
compile_output() = default;
@@ -29,6 +31,10 @@ struct compile_output {
compile_output(const compile_output&) = default;
compile_output& operator=(const compile_output&) = default;
virtual std::unique_ptr<compile_output> clone() const {
return std::make_unique<compile_output>(*this);
};
indexed_vector<falco_list> lists;
indexed_vector<falco_macro> macros;
indexed_vector<falco_rule> rules;