1

I would like to create a custom facet that applies to all streamed text output, and access the operated-on stream's internal extensible array (i.e. via iword).

If I were only interested in having the custom string manipulator operate on numbers, I could do something like what's described here: C++ custom stream manipulator that changes next item on stream

If I didn't need access to the iosbase, I could use codecvt's do_out method, as is described here: How to easily indent output to ofstream?, but I don't have access to the stream's ios_base within the codecvt facet (as far as I can tell).

Is there a way to define a custom facet that will be called on all stream output, as is the case with codecvt, but where I have access to ios_base& as is the case with num_put? Is there a way I can access the stream the codecvt facet is currently being applied to?

Community
  • 1
  • 1
Spacemoose
  • 3,856
  • 1
  • 27
  • 48

1 Answers1

0

I might have a solution to this question, but I am not sure what the policy/guidelines are on quoting external links/references in stackExchange.

I created a custom streambuf object (creating an ostream) that contained a secondary store for the characters that were processed by stream.

I have looked at your github source -- and was wondering if, when you create your indent_facet, if you could pass the stream to the indent_facet constructor; and then use that pointer to get the streambuf; and through that, the secondary store?

Like I said, I have a much more detailed description of what I'm thinking about.

Thanks,

Tom

Community
  • 1
  • 1
Charles Thomas
  • 965
  • 10
  • 11