Removing dependancy to a pointer of a specific type
<p>I'm wrapping a C api which has the following struct:</p>

<pre><code>typedef struct Value
{
    union 
    {
        int i;
        const char* s;
        bool b;
        struct StructureMember_T* firstStructureMember
        double d;
    } value;
} Value_T;
</code></pre>

<p>I use a setter function to set values in this struct from C++.</p>

<pre><code>class ValueSetter : public IValueSetter
{
public:
    explicit ValueSetter(Value_T* value) : _value(value)
    {
    }

    void operator()(int8_t v) const
    {
        _value-&gt;value.i = v;
    }

    ...

    void operator()(std::string&amp; s) const
    {
        _value-&gt;value.s = s.c_str();
    }

    void operator()(Structure&amp; s) const
    {
        _value-&gt;value.firstStructureMember = s.getFirstMember();
    }

private:
    Value_T* _value;
};
</code></pre>

<p>To deal with StructureMember_T*, I added the following class which I'm not happy with. For example, its interface is dependant on StructureMember_T from the c api. Any suggestion regarding another approach? I will be adding more functionality to the Structure class at a later date.</p>

<pre><code>class Structure
{
public:
    explicit Structure(Value_T* firstMember)
        : _firstMember(firstMember)
    {
    }

    StructureMember_T* getFirstMember()
    {
        return _firstMember;
    }

    void setFirstMember(StructureMember_T* firstMember)
    {
        _firstMember = firstMember;
    }

private:
    StructureMember_T* _firstMember;
};
</code></pre>
