[iostreams] Prepending and appending output data in a filter

I have a filter, derived from multichar_output_filter, in which I am both prepending data and appending data. In other words the data being written to the sink will be greater than the data being passed into the filter's 'template<typename Sink> std::streamsize write(Sink& dest, const char* s, std::streamsize n)' member function, which my filter is implementing. Is this an allowable use of filters ? Do I still return the 'n' streamsize data being passed in or do I return the actual length of the data being written ? Can I use the 'template<typename T> std::streamsize write( T& t, const typename char_type_of<T>::type* s, std::streamsize n );' function to write the data, or do I need to 'put' each character to the sink using the 'template<typename Sink> void put(Sink& snk, typename char_type_of<Sink>::type c);' function instead ?

Edward Diener wrote:
I have a filter, derived from multichar_output_filter, in which I am both prepending data and appending data. In other words the data being written to the sink will be greater than the data being passed into the filter's 'template<typename Sink> std::streamsize write(Sink& dest, const char* s, std::streamsize n)' member function, which my filter is implementing.
Is this an allowable use of filters ?
yes.
Do I still return the 'n' streamsize data being passed in or do I return the actual length of the data being written ?
From one of the tutorial examples: template<typename Sink> std::streamsize write(Sink& dest, const char* s, std::streamsize n) { // Consume up to n filtered characters from the buffer s, // writing filtered characters to dest. Return the number // of characters consumed. }
Can I use the
'template<typename T> std::streamsize write( T& t, const typename char_type_of<T>::type* s, std::streamsize n );'
function to write the data,
yes
participants (2)
-
Edward Diener
-
eg