parent
650e88e2c3
commit
9548b27052
10 changed files with 243 additions and 36 deletions
@ -0,0 +1,21 @@ |
||||
<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> |
@ -0,0 +1,22 @@ |
||||
This is a C++ class for reading and writing XML structures. |
||||
|
||||
All informaton can be found in the generated doxygen project documentation. |
||||
|
||||
Rationale: The initial idea was to map C++ data structures to XML |
||||
files for configuration files that can easily be edited by hand. This |
||||
library does not need any kind of C++ code parser or special pre |
||||
compiler. You can specify a schema entirly in native C++. The schema |
||||
is verified when XML is read and exceptions are thrown when the XML to |
||||
be pares is invalid. Exceptions specify exactly the location and |
||||
reason of the problem, so that the editor of the XML file can easily |
||||
find and correct the problem. |
||||
|
||||
(More rationale: See also "related Pages" in the doxygen project documentation) |
||||
|
||||
Structure of the files: |
||||
src: The source code of the library |
||||
doc/html: Doxygen documentation oft the library usage |
||||
doc/examples: Example code (included in doxygen documentation) |
||||
test: CppUnit test files - can also be taken as examples |
||||
|
||||
Project URL: http://dev.swisssign.com |
@ -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; |
||||
} |
@ -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 |
Loading…
Reference in new issue