1#ifndef PERSISTED_RULE_INCLUDED
2#define PERSISTED_RULE_INCLUDED
75 if (is_enabled_c !=
nullptr && is_enabled_c[0] ==
'Y')
84 message = std::optional<std::string>(message_arg);
121 if (value !=
nullptr) {
131 std::optional<std::string> value) {
133 if (!value.has_value()) {
134 cursor->
set(column,
nullptr, 0);
137 const std::string &s = value.value();
138 cursor->
set(column, s.c_str(), s.length());
A rule as persisted on disk.
Definition: persisted_rule.h:41
void set_if_present(rts::Cursor *cursor, rts::Cursor::column_id column, std::optional< std::string > value)
Writes a string value to the cursor's column if it exists.
Definition: persisted_rule.h:130
void set_message(const std::string &message_arg)
Convenience function, may be called with a const char*.
Definition: persisted_rule.h:83
void copy_and_set(std::optional< std::string > *property, rts::Cursor *c, int colno)
Reads from a Cursor and writes to a property of type std::optional<string> after forcing a copy of th...
Definition: persisted_rule.h:118
void set_pattern_digest(const std::string &s)
Convenience function, may be called with a const char*.
Definition: persisted_rule.h:88
bool write_to(rts::Cursor *c)
Writes the values in this Persisted_rule to the table at the row pointed to by the cursor.
Definition: persisted_rule.h:102
std::optional< std::string > message
The plugin's message, write-only.
Definition: persisted_rule.h:56
std::optional< std::string > normalized_pattern
The normalized pattern, write-only.
Definition: persisted_rule.h:62
bool is_enabled
True if the rule is enabled.
Definition: persisted_rule.h:53
std::optional< std::string > pattern_digest
The pattern's digest, write-only.
Definition: persisted_rule.h:59
std::optional< std::string > replacement
The rewrite rule's replacement string.
Definition: persisted_rule.h:50
std::optional< std::string > pattern_db
The pattern's current database.
Definition: persisted_rule.h:47
void set_normalized_pattern(const std::string &s)
Convenience function, may be called with a const char*.
Definition: persisted_rule.h:93
std::optional< std::string > pattern
The rewrite rule's pattern string.
Definition: persisted_rule.h:44
Persisted_rule(rts::Cursor *c)
Constructs a Persisted_rule object that copies all data into the current heap.
Definition: persisted_rule.h:69
Writable cursor that allows reading and updating of rows in a persistent table.
Definition: service_rules_table.h:63
int write()
Writes the row in the write buffer to the table at the current row.
Definition: rules_table_service.cc:176
column_id pattern_digest_column() const
Definition: service_rules_table.h:87
column_id normalized_pattern_column() const
Definition: service_rules_table.h:88
column_id message_column() const
Definition: service_rules_table.h:86
column_id enabled_column() const
Definition: service_rules_table.h:85
void set(int colno, const char *str, size_t length)
Sets the value of column colno to a string value.
Definition: rules_table_service.cc:163
static const column_id ILLEGAL_COLUMN_ID
Definition: service_rules_table.h:67
const char * fetch_string(int fieldno)
Fetches the value of the column with the given number as a C string.
Definition: rules_table_service.cc:138
column_id pattern_column() const
Definition: service_rules_table.h:80
void make_writeable()
Prepares the write buffer for updating the current row.
Definition: rules_table_service.cc:158
column_id pattern_database_column() const
Definition: service_rules_table.h:81
column_id replacement_column() const
Definition: service_rules_table.h:84
int column_id
Definition: service_rules_table.h:65
Definition: service_rules_table.h:45
void free_string(const char *str)
Frees a const char pointer allocated in the server's dynamic library using new[].
Definition: rules_table_service.cc:67
Plugin service that provides access to the rewrite rules table that is used by the Rewriter plugin.