falcong / pugixml

Automatically exported from code.google.com/p/pugixml
0 stars 0 forks source link

simplified interface #63

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This is what I've implemented in my project, on top of pugi:

using namespace pugi;
xml_document doc = new xml_document();
doc / "root" / "files" + "file" ["name"] = "abc.txt";
doc / "root" / "story" = "this is some story";
doc.save(...);

The XML produced:

<?xml version="1.0" ?>
<root>
  <files>
    <file name="abc.txt"/>
  </files>
  <story>this is some story</story>
</root>

With this wrapper I removed a lot of code from my project.

Maybe you can introduce something similar in PUGI?

Original issue reported on code.google.com by yegor256 on 28 May 2010 at 8:15

GoogleCodeExporter commented 9 years ago
I can share my code, but I'm sure you understand how it works. This approach 
looks much more C++ oriented 
than PUGI-s current C-style interface. The core or PUGI works perfect and I use 
in in my project. But they 
interface is very difficult for simple applications. Such a simplified 
mechanism of node access/creation would 
definitely help to make PUGI more popular. I think so :)

Original comment by yegor256 on 28 May 2010 at 8:17

GoogleCodeExporter commented 9 years ago
I'm sorry for a huge delay.

I do not want to provide such interface as a part of the default distribution. 
This abuses operator overloading too much, which often can lead to problems.

Still, the solution is very neat, so I looked into providing such interface as 
an extension to current one. Ideally it should work as follows - the user 
includes a separate file, and gets the new operators. If it will work this way, 
I can include the extension header in the contrib folder.

Unfortunately, this does not seem to be doable, since operator[] can't be 
overloaded externally (why?..). The only thing that comes to my mind currently 
is to have wrapper classes, i.e. xml_node_ext. However, this will occasionally 
require manual typecasting (for cases like node["attr"], where node is an 
xml_node).

Original comment by arseny.k...@gmail.com on 11 Jul 2010 at 5:34

GoogleCodeExporter commented 9 years ago

Original comment by arseny.k...@gmail.com on 11 Jul 2010 at 5:37

GoogleCodeExporter commented 9 years ago
Closing this due to the lack of new ideas or feedback; if you're interested in 
including the functionality as an additional header file and if your solution 
does not require modifying pugixml header, then please reopen the issue.

Original comment by arseny.k...@gmail.com on 31 Oct 2010 at 6:42