Boost logo

Boost :

From: Drew Hohmann (drew_at_[hidden])
Date: 2007-11-14 10:26:14


I am saving multiple classes which contain STL collections, and in turn
those STL collections contain classes that contain more STL collections.
  A sample XML file follows.

The problem occurs when I try and move the XML file into a database, and
I receive the error "The table (item) cannot be the child table to
itself in nested relations."

In the collections_save_imp.hpp file, under the save_collection
function, the key line is
ar << boost::serialization::make_nvp("item", *it++);

I was thinking of instead of using the constant string "item" when
saving a STL collection, to keep track of the parent table name, and
modify the string based on the parent name. For example, under animals
item would be changed to "animals_item", under trials would be changed
to "trials_item", and under platforms would be changed to "platforms_item".

Is this the correct way to solve my problem, and if so does anyone have
any suggestions on how to implement it?

Thanks,
Drew Hohmann
Software Engineer

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE boost_serialization>
<boost_serialization signature="serialization::archive" version="4">
<project class_id="0" tracking_level="0" version="1">
        <m_name>New Project</m_name>
        <animals class_id="1" tracking_level="0" version="0">
                <count>1</count>
                <item_version>1</item_version>
                <item class_id="2" tracking_level="0" version="1">
                        <m_name>test</m_name>
                        <m_gender>Male</m_gender>
                        <m_species></m_species>
                        <m_strain></m_strain>
                </item>
        </animals>
        <trials class_id="3" tracking_level="0" version="0">
                <count>8</count>
                <item_version>1</item_version>
                <item class_id="4" tracking_level="0" version="1">
                        <trialinfo class_id="5" tracking_level="0" version="1">
                                <m_trial_type></m_trial_type>
                                <platforms class_id="7" tracking_level="0" version="0">
                                        <count>1</count>
                                        <item_version>1</item_version>
                                        <item class_id="8" tracking_level="0" version="1">
                                                <circle class_id="9" tracking_level="0" version="1">
                                                        <m_x>86</m_x>
                                                        <m_y>80</m_y>
                                                </circle>
                                                <m_name>p1</m_name>
                                                <m_platformtype>0</m_platformtype>
                                        </item>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk