RISCSoftware / cpacs_tigl_gen

Generates CPACS schema based classes for TiGL
Apache License 2.0
5 stars 5 forks source link

Handle empty text elements / attributes #7

Closed rainman110 closed 7 years ago

rainman110 commented 7 years ago

The generator currently accepts empty elements / attributes, even if those elements / attributes are required by the schema.

We should change this to the following behavior:

To test this behavior, make e.g. the parentUID element of the wing empty.

bernhardmgruber commented 7 years ago

I agree to your second constraint, required std::string elements should not be empty. But I think it should be handled the same way as required elements which are missing. Currently, an error message is logged in this case (cf. CodeGen.cpp:656). I would also prefer an exception here, because missing required elements cause the corresponding data members to be left uninitialized, potentially causing undefined behavior.

Regarding the first constraint, I would regard it as an error if the element (despite being optional) is empty. Simply because the presence of an element should depend on the presence of its XML tag, not its content.