[xsd-users] Help me: How to find out what is the type of a class

James Mei jxmei3 at gmail.com
Thu Oct 22 00:08:31 EDT 2009


Hi Boris

The sample code below works with normal pointer to a class. But when it is a
TreeNode->Data is "const sequence <tDataSet> &", then the following code
crashed.

xml_schema::type* t = static_cast<xml_schema::type*> (TreeNode->Data);
//<-- crash here if TreeNode->Data has "const sequence <tDataSet> &"

if (tGSE* gse = dynamic_cast<tGSE*> (t))
{
 // Handle gse.
}
else if (tAddress* addr = dynamic_cast<tAddress*> (t))
{
 // Handle addr.
}

Here is the code that assigning the TreeNode->Data pointer

    TTreeNode *tn_DS=spd->hTree->Items->AddChild(hParent, "Data Sets");
    tn_DS->Data=&LD->LN0().DataSet();  //this is the "const sequence
<tDataSet> &"
    for (i = 0; i < LD->LN0().DataSet().size(); i++) {
        tn=spd->hTree->Items->AddChild(tn_DS,
LD->LN0().DataSet().at(i).name().c_str());
        tn->Data =  &LD->LN0().DataSet().at(i);        //it works fine
    }

May I know how to tell the different between const sequence
<xml_schema::type*> and <xml_schema::type*> ?

Cheers
James


> On Wed, Oct 21, 2009 at 10:22 PM, Boris Kolpackov <boris at codesynthesis.com
> > wrote:
>
>> Hi James,
>>
>> In the future please keep your replies CC'ed to the xsd-users mailing
>> list as discussed in the posting guidelines:
>>
>> http://www.codesynthesis.com/support/posting-guidelines.xhtml
>>
>>
>> James Mei <jxmei3 at gmail.com> writes:
>>
>> > May I also know if the class contain the actual name of the element in
>> > string form ?
>>
>> No.
>>
>>
>> > I have tried
>> > scl.get()->Header()._node()->getNodeName(), which
>> > scl.get()->Header()._node() should be the *DOMNode, but it is NULL all
>> the
>> > time.
>>
>> Yes, you can do this but you will need to turn on DOM association during
>> parsing. See Section 5.1, "DOM Association" in the C++/Tree Mapping User
>> Manual for more information:
>>
>>
>> http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#5.1
>>
>> Boris
>>
>
>


More information about the xsd-users mailing list