Note that there are some explanatory texts on larger screens.

plurals
  1. POconvert std::vector<T> into Dataset^
    primarykey
    data
    text
    <p>I have a vector of c++ structs, and I need to put this into a managed, typed dataset.</p> <pre><code>std::vector&lt;Record*&gt; record_collection; class Record{ public: Record(){}; virtual ~Record(){}; virtual void serialize(std::ostream&amp; dest){ dest &lt;&lt; "Record" &lt;&lt; std::endl; } }; </code></pre> <p>Record* is a base class - I need to handle the derived class. A typical example is </p> <pre><code>class TestRecord:public Record{ public: TestRecord(){}; ~TestRecord(){}; std::string t_str; int t_int; double t_double; void serialize(std::ostream&amp; dest){ dest &lt;&lt; t_int &lt;&lt; ',' &lt;&lt; t_double &lt;&lt; ',' &lt;&lt; t_str &lt;&lt; ',' &lt;&lt; std::endl; }; }; </code></pre> <p>Essentially, I need to reproduce the serialize method, except that I need to make DataColumns for <code>t_str</code>, <code>t_int</code>, and <code>t_double</code>, type the columns appropriately, and then put the values in them. </p> <p>I can edit anything as required at this point, but I need to set up the pattern such that anything that implements record can have its data members can be serialized into a managed dataset with typed columns. </p> <p>Can anyone advise on a pattern, or a suggestion, that would help? I could do it with inspection on a tuple if this were Python, but in c++11 a tuple needs to be of predefined type.</p> <p>The problem here is that I may not compile record or TestRecord with /cli, in which case I could pass in the datatable to the record and let it populate it itself - so I'm looking for a better solution than the ones I have:</p> <p>a) Write a managed wrapper for <em>every</em> derived class b) Do type inspection.</p> <p>Is there a pattern I've missed?</p> <p>Thanks, Melanie</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload