[Liblas-commits] hg-main-tree: start on serializing libpc::Schema
to xml
liblas-commits at liblas.org
liblas-commits at liblas.org
Sat Apr 30 09:32:02 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/a4ad96e13b27
changeset: 697:a4ad96e13b27
user: Howard Butler <hobu.inc at gmail.com>
date: Sat Apr 30 08:31:52 2011 -0500
description:
start on serializing libpc::Schema to xml
diffstat:
include/libpc/drivers/oci/Schema.hpp | 12 ++++++++++--
src/drivers/oci/Schema.cpp | 24 ++++++++++++++++++++++++
2 files changed, 34 insertions(+), 2 deletions(-)
diffs (84 lines):
diff -r bfbd4b432f77 -r a4ad96e13b27 include/libpc/drivers/oci/Schema.hpp
--- a/include/libpc/drivers/oci/Schema.hpp Fri Apr 29 14:17:25 2011 -0500
+++ b/include/libpc/drivers/oci/Schema.hpp Sat Apr 30 08:31:52 2011 -0500
@@ -55,6 +55,8 @@
#include <libxml/tree.h>
#include <libxml/xinclude.h>
#include <libxml/xmlIO.h>
+#include <libxml/encoding.h>
+#include <libxml/xmlwriter.h>
#include <boost/shared_ptr.hpp>
#include <boost/concept_check.hpp>
@@ -84,15 +86,20 @@
Schema& operator=(const Schema&); // not implemented
Schema(const Schema&); // not implemented;
+
+
// We're going to put all of our libxml2 primatives into shared_ptrs
// that have custom deleters that clean up after themselves so we
- // have a good chance at having clean exception-safe code
-
+ // have a good chance at having clean exception-safe code
typedef boost::shared_ptr<void> DocPtr;
typedef boost::shared_ptr<void> SchemaParserCtxtPtr;
typedef boost::shared_ptr<void> SchemaPtr;
typedef boost::shared_ptr<void> SchemaValidCtxtPtr;
+ typedef boost::shared_ptr<void> TextWriterPtr;
+
+ TextWriterPtr writeHeader(DocPtr doc);
+
DocPtr m_doc;
DocPtr m_schema_doc;
@@ -102,6 +109,7 @@
SchemaValidCtxtPtr m_schema_valid_ctx;
xmlParserOption m_doc_options;
+
void* m_global_context;
libpc::Schema m_schema;
diff -r bfbd4b432f77 -r a4ad96e13b27 src/drivers/oci/Schema.cpp
--- a/src/drivers/oci/Schema.cpp Fri Apr 29 14:17:25 2011 -0500
+++ b/src/drivers/oci/Schema.cpp Sat Apr 30 08:31:52 2011 -0500
@@ -82,6 +82,16 @@
}
};
+struct WriterDeleter
+{
+ template <typename T>
+ void operator()(T* ptr)
+ {
+ ::xmlFreeTextWriter(ptr);
+ }
+};
+
+
static bool sort_dimensions(libpc::DimensionLayout const& a, libpc::DimensionLayout const& b)
{
return a < b;
@@ -273,6 +283,20 @@
print_element_names(cur_node->children);
}
}
+
+Schema::TextWriterPtr Schema::writeHeader(DocPtr doc)
+{
+ xmlDoc* d = static_cast<xmlDoc*>(doc.get());
+
+ TextWriterPtr writer = TextWriterPtr(xmlNewTextWriterDoc(&d, FALSE), WriterDeleter());
+
+ xmlTextWriterPtr w = static_cast<xmlTextWriterPtr>(writer.get());
+
+ xmlTextWriterSetIndent(w, TRUE);
+ xmlTextWriterStartDocument(writer, NULL, "utf-8", NULL);
+ return writer;
+}
+
void Schema::LoadSchema()
{
std::vector<libpc::DimensionLayout> layouts;
More information about the Liblas-commits
mailing list