#ifndef INCLUDED_COMPILEFORK_
#define INCLUDED_COMPILEFORK_

#include <string>
#include <vector>

#include <bobcat/fork>
#include <bobcat/pipe>

class CompileFork: public FBB::Fork
{
    FBB::Pipe d_childOutput;   // child writes this
    std::string d_source;
    std::vector<std::string> d_lines;
    int d_ret = 1;

    public:
        void reset(std::string const &source);

        int ret() const;
        std::string const &source() const;
        size_t size() const;
        std::vector<std::string> const &lines() const;
        
    private:
        void childRedirections()    override;
        void childProcess()         override;
        void parentProcess()        override;
};

inline int CompileFork::ret() const
{
    return d_ret;
}
        
inline std::string const &CompileFork::source() const
{
    return d_source;
}
        
inline size_t CompileFork::size() const
{
    return d_lines.size();
}
        
inline std::vector<std::string> const &CompileFork::lines() const
{
    return d_lines;
}
        
#endif
