OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   XML Stream in C++

[ Lists Home | Date Index | Thread Index ]


Hello everyone,

I am rather new on this list, and I do not know all yet what relates to the 
XML.
I am still being studied, and I make my last year.  For three years that 
teatcher asks me to shit c++ code has length of day, and I start has to like 
this ...

What I love in this language, it is that when I require to make a program, I 
launch google, I will seek 60% of the code on all the projects existing 
under free licence and I do not have any more whom has to make some links to 
have my applications.
I have to try to use the library sax & dom, but I do not find them very 
intuitive.
I wondered thus why there was no XML stream.
For a c++ programmer, I think that it would be simpler to write a program 
which resembles has this:

class Book {
  char *_nom;
  ...

  friend oxstream& operator<<(oxstream&, const Book&);
  friend ixstream& operator>>(ixstream&, Book&);

  friend ostream& operator<<(ostream&, const Book&);
  friend istream& operator>>(istream&, Book&);
};

int main()
{
  ifxstream xmlfile("book.xml");
  tag t = xmlfile.getTag();
  Book bk;
  vector<Book> vBk;

  if(t != "INVENTAIRE")
    return 1;

  while( (t = xmlfile.getTag()) != "/INVENTAIRE") {
    xmlfile.popTag(t);
    xmlfile >> bk;

    if(!xmlfile)
      return 2;

    vBk.push_back(bk);
  }

  for(vector<Book>::const_iterator p = vBk.begin(); p < vBk.end(); ++p)
    cout << *p << endl;

  return 0;
}

With this type of code, I can send a book, or all the books on a file, a 
socket, a pipe, or same in memory without problem.
It could y have (without too having still reflects has the question) a 
hierarchy of this type:


       (ios) -> xios  (for XML Input/Output Stream)
               /    \
              /      \
             /        \
        ixstream    oxstream
         /  |  \    /  |  \

       ...  (stream file, memory, socket, ...)

One beneficie thus of all the advantages of flows.

All this is the fruit of a dream which I has just made this night.
I thus do not have yet deep the question.

I would have just liked to know what you think of all this.


  Christophe.


PS: Sorry for my verry bad english.
    Thank you http://www.netbel.be/translation/ for help me.




_________________________________________________________________
Discutez en ligne avec vos amis, essayez MSN Messenger : 
http://messenger.msn.fr/





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS