jeudi 3 octobre 2019

Distinction between different "kinds" of member variables

I'm parsing large XML definition files. To achieve this I have started making classes for each "type" that you can encounter in the xml file.

<Element Factor="10">Whatever</Element>

Currently I put each type from the XML file in it's own class, with a few operators and the members of the type.

However, some of these types have both "child elements" and "attributes".

i.e.:

<MySimpleType min="20" max="100">
    <name>MyName</name>
    <SomeOtherElement>xxxx</SomeOtherElement>
</Mysimpletype>

Currently the class would look like this:

class MySimpleType{
    std::string MyName;
    TSomeOtherElement SomeOtherElement;
    int min;
    int max;
}

I am wondering if there's a way to annotate the class members so that it becomes clear whether the member in question is an attribute or an element.

The elements can have different types (which may be another custom class) and the attributes are mostly built-ins or ADT's.

Is there a way to clearly mark a member as being a 'element' or a 'attribute' ?

(Should it matter, I'm using Visual Studio 2015 with the built-in compiler, so I'm using c++11)

Aucun commentaire:

Enregistrer un commentaire