Defined in header <cparse/Generator.hh>

virtual std::ostream& getStream() = 0;

Returns the stream the emission is written to. Typically an std::ofstream opened by the subclass in its constructor, or a reference to an externally-owned std::ostream passed in by the caller.

Parameters

None.

Return value

A reference to the output stream.

Exceptions

Implementations should not throw.

Notes

Called pervasively during emission — every character or line written to the output goes through getStream(). The subclass is expected to keep the stream alive for the duration of the emission; the base class does no lifetime management on the returned reference.

Example

class MyGen : public fedem::parser::Generator {
    std::ofstream out_;
public:
    explicit MyGen(std::string const& path) : out_(path) {}
    std::ostream& getStream() override { return out_; }
    // ...
};

See also