You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.
The current TinyXML++ API requires that each XML node is created, and added
to a parent, explicitly. As such, it can quickly become verbose. Consider
the following example:
Element measurements("measurements");
Element tbr("TotalBytesReceived");
tbr.SetAttribute("displayName", "Total Bytes Received");
tbr.SetText(12);
Element tbp("TotalBytesProcessed");
tbp.SetAttribute("displayName", "Total Bytes Processed");
tbp.SetText(14);
Element teb("TotalErroredBytes");
teb.SetAttribute("displayName", "Total Errored Bytes");
teb.SetText(42);
measurements.InsertEndChild(tbr);
measurements.InsertEndChild(tbp);
measurements.InsertEndChild(teb);
root->InsertEndChild(measurements);
That produces the following XML snippet:
<measurements>
<TotalBytesReceived displayName="Total Bytes
Received">12</TotalBytesReceived>
<TotalBytesProcessed displayName="Total Bytes
Processed">14</TotalBytesProcessed>
<TotalErroredBytes displayName="Total Errored
Bytes">42</TotalErroredBytes>
</measurements>
Through the use of judicious operator overloading we could have syntax like
the following:
*root <<
(Element("measurements")
<< (Element("TotalBytesReceived")("displayName", "Total Bytes
Received") = 12)
<< (Element("TotalBytesProcessed")("displayName", "Total Bytes
Processed") = 14)
<< (Element("TotalErroredBytes")("displayName", "Total Errored
Bytes") = 42));
(I've attached a trivial patch that allows this.)
For me this is a significant improvement. In particular I the SetAttribute
(operator()()) and SetText (operator=) changes fit well IMO. I'm less
happy with operator<< inserting a node...I'm still experimenting.
So, generally, the issue is that ticpp is quite verbose and we could
possibly make improvements. What do you think?
[Also, is it possible to start a discussion board? This isn't really the
right place to discuss improvements but there doesn't seem to be anywhere
else to communicate! We intend to use ticpp a fair bit within our company
and I'd like to try and help where I can.]
Original issue reported on code.google.com by [email protected] on 7 Apr 2009 at 2:26
Original issue reported on code.google.com by
[email protected]
on 7 Apr 2009 at 2:26Attachments:
The text was updated successfully, but these errors were encountered: