more docu
This commit is contained in:
62
doc/examples/address.cxx
Normal file
62
doc/examples/address.cxx
Normal file
@@ -0,0 +1,62 @@
|
||||
/*! @file
|
||||
|
||||
@id $Id$
|
||||
*/
|
||||
// 1 2 3 4 5 6 7 8
|
||||
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
||||
|
||||
// g++ -I../src ../src/xml.cxx address.cxx
|
||||
|
||||
#include <xml-cxx/xml.hxx>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
|
||||
int main(int, char**) try {
|
||||
// Example template in factory instantiation
|
||||
xml::Factory addrTpl(xml::Node("address")
|
||||
<<(xml::Node("name").limits(1, 1)
|
||||
<<xml::String("first").limits(1, 1)
|
||||
<<xml::String("middle") // 0..n -> .limit(0, 0)
|
||||
<<xml::String("last").limits(1, 1))
|
||||
<<(xml::Node("location").max(1)
|
||||
<<xml::String("line").min(1))
|
||||
<<xml::String("email")
|
||||
<<xml::String("url")
|
||||
<<xml::String("country").max(1));
|
||||
// Example XML file to read
|
||||
std::stringstream ss("\
|
||||
<address>\
|
||||
<name>\
|
||||
<first>Marc</first>\
|
||||
<middle>Roman</middle>\
|
||||
<last>Wäckerlin</last>\
|
||||
</name>\
|
||||
<location>\
|
||||
<line>SwissSign AG</line>\
|
||||
<line>Pfingstweidstrasse 60b</line>\
|
||||
<line>8005 Zürich</line>\
|
||||
</location>\
|
||||
<country>Schweiz</country>\
|
||||
<email>marc@waeckerlin.org</email>\
|
||||
<email>marc.waeckerlin@swisssign.com</email>\
|
||||
<url>http://dev.swisssign.com/trac/libxml-cxx</url>\
|
||||
<url>http://marc.wäckerlin.ch</url>\
|
||||
<url>http://marc.waeckerlin.org</url>\
|
||||
<url>http://dev.swisssign.com</url>\
|
||||
<url>http://swissign.com</url>\
|
||||
<url>http://swissign.ch</url>\
|
||||
</address>");
|
||||
std::auto_ptr<xml::Node> author(addrTpl.read(ss));
|
||||
// write to stdout
|
||||
std::cout<<"Successfully read:"<<std::endl
|
||||
<<"------------------------------"<<std::endl
|
||||
<<*author<<std::endl
|
||||
<<"------------------------------"<<std::endl;
|
||||
// store in project's AUTHORS file
|
||||
std::ofstream ofs("../AUTHORS");
|
||||
ofs<<*author<<std::endl;
|
||||
return 0;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr<<"**** Error: "<<e.what()<<std::endl;
|
||||
}
|
14
doc/examples/makefile.am
Normal file
14
doc/examples/makefile.am
Normal file
@@ -0,0 +1,14 @@
|
||||
## @id $Id$
|
||||
|
||||
## 1 2 3 4 5 6 7 8
|
||||
## 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
||||
|
||||
AM_CXXFLAGS += -I ${top_srcdir}/src
|
||||
AM_LDFLAGS = -L${top_builddir}/src
|
||||
|
||||
noinst_PROGRAMS = address
|
||||
|
||||
address_SOURCES = address.cxx
|
||||
address_LDADD = -lxml-cxx
|
||||
|
||||
MAINTAINERCLEANFILES = makefile.in
|
Reference in New Issue
Block a user