aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-01-21 11:47:13 -0500
committerJack Lloyd <[email protected]>2018-01-21 11:47:13 -0500
commitaadd0595c6aca0b3f040e1e3baabdcd00a5df8bd (patch)
tree97564629ac9efc07114669e82f458f7a958ccfc6 /src/lib
parent9c679f487e3f7da9a2ab5fad02b082c483d86c87 (diff)
Add Pipe::prepend_filter
Fixes #1402
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/filters/pipe.cpp15
-rw-r--r--src/lib/filters/pipe.h18
2 files changed, 32 insertions, 1 deletions
diff --git a/src/lib/filters/pipe.cpp b/src/lib/filters/pipe.cpp
index ed6abbad8..0bba81bf2 100644
--- a/src/lib/filters/pipe.cpp
+++ b/src/lib/filters/pipe.cpp
@@ -214,6 +214,19 @@ void Pipe::append_filter(Filter* filter)
do_append(filter);
}
+void Pipe::prepend(Filter* filter)
+ {
+ do_prepend(filter);
+ }
+
+void Pipe::prepend_filter(Filter* filter)
+ {
+ if(m_outputs->message_count() != 0)
+ throw Invalid_State("Cannot call Pipe::prepend_filter after start_msg");
+
+ do_prepend(filter);
+ }
+
/*
* Append a Filter to the Pipe
*/
@@ -238,7 +251,7 @@ void Pipe::do_append(Filter* filter)
/*
* Prepend a Filter to the Pipe
*/
-void Pipe::prepend(Filter* filter)
+void Pipe::do_prepend(Filter* filter)
{
if(m_inside_msg)
throw Invalid_State("Cannot prepend to a Pipe while it is processing");
diff --git a/src/lib/filters/pipe.h b/src/lib/filters/pipe.h
index 9ba299024..03b516083 100644
--- a/src/lib/filters/pipe.h
+++ b/src/lib/filters/pipe.h
@@ -270,6 +270,9 @@ class BOTAN_PUBLIC_API(2,0) Pipe final : public DataSource
/**
* Insert a new filter at the front of the pipe
+ * Deprecated because runtime modification of Pipes is deprecated.
+ * You can instead use prepend_filter which only works before the first
+ * message is processed.
* @param filt the new filter to insert
*/
BOTAN_DEPRECATED("Runtime modification of Pipe deprecated")
@@ -277,6 +280,9 @@ class BOTAN_PUBLIC_API(2,0) Pipe final : public DataSource
/**
* Insert a new filter at the back of the pipe
+ * Deprecated because runtime modification of Pipes is deprecated.
+ * You can instead use append_filter which only works before the first
+ * message is processed.
* @param filt the new filter to insert
*/
BOTAN_DEPRECATED("Runtime modification of Pipe deprecated")
@@ -306,6 +312,17 @@ class BOTAN_PUBLIC_API(2,0) Pipe final : public DataSource
void append_filter(Filter* filt);
/**
+ * Prepend a new filter onto the filter sequence. This may only be
+ * called immediately after initial construction, before _any_
+ * calls to start_msg have been made.
+ *
+ * This function (unlike prepend) is not deprecated, as it allows
+ * only modification of the pipe at initialization (before use)
+ * rather than after messages have been processed.
+ */
+ void prepend_filter(Filter* filt);
+
+ /**
* Construct a Pipe of up to four filters. The filters are set up
* in the same order as the arguments.
*/
@@ -325,6 +342,7 @@ class BOTAN_PUBLIC_API(2,0) Pipe final : public DataSource
private:
void destruct(Filter*);
void do_append(Filter* filt);
+ void do_prepend(Filter* filt);
void find_endpoints(Filter*);
void clear_endpoints(Filter*);