gz support for OSM xml reading and writing
This commit is contained in:
parent
ed15d5d1de
commit
d43d9fc908
10 changed files with 137 additions and 44 deletions
|
|
@ -5,8 +5,12 @@
|
|||
#ifndef UTIL_XML_XMLWRITER_H_
|
||||
#define UTIL_XML_XMLWRITER_H_
|
||||
|
||||
#ifdef ZLIB_FOUND
|
||||
#include <zlib.h>
|
||||
#endif
|
||||
#include <map>
|
||||
#include <ostream>
|
||||
#include <fstream>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
|
||||
|
|
@ -30,7 +34,15 @@ class XmlWriter {
|
|||
explicit XmlWriter(std::ostream* out);
|
||||
XmlWriter(std::ostream* out, bool pretty);
|
||||
XmlWriter(std::ostream* out, bool pretty, size_t indent);
|
||||
~XmlWriter(){};
|
||||
|
||||
explicit XmlWriter(const std::string& file);
|
||||
XmlWriter(const std::string& file, bool pretty);
|
||||
XmlWriter(const std::string& file, bool pretty, size_t indent);
|
||||
~XmlWriter(){
|
||||
#ifdef ZLIB_FOUND
|
||||
if (_gzfile) gzclose(_gzfile);
|
||||
#endif
|
||||
};
|
||||
|
||||
// open tag without attributes
|
||||
void openTag(const std::string& tag);
|
||||
|
|
@ -55,6 +67,11 @@ class XmlWriter {
|
|||
// close all open tags, essentially closing the document
|
||||
void closeTags();
|
||||
|
||||
// pushes XML escaped text to stream
|
||||
void putEsced(const std::string& str, char quot);
|
||||
void put(const std::string& str);
|
||||
void put(const char c);
|
||||
|
||||
private:
|
||||
enum XML_NODE_T { TAG, TEXT, COMMENT };
|
||||
|
||||
|
|
@ -67,19 +84,24 @@ class XmlWriter {
|
|||
};
|
||||
|
||||
std::ostream* _out;
|
||||
std::ofstream _outs;
|
||||
std::stack<XmlNode> _nstack;
|
||||
|
||||
bool _pretty;
|
||||
size_t _indent;
|
||||
|
||||
#ifdef ZLIB_FOUND
|
||||
gzFile _gzfile;
|
||||
#else
|
||||
int _gzfile;
|
||||
#endif
|
||||
|
||||
// handles indentation
|
||||
void doIndent();
|
||||
|
||||
// close "hanging" tags
|
||||
void closeHanging();
|
||||
|
||||
// pushes XML escaped text to stream
|
||||
void putEsced(std::ostream* out, const std::string& str, char quot);
|
||||
|
||||
// checks tag names for validiy
|
||||
void checkTagName(const std::string& str) const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue