From ae1633d2df0cfebf6ad23d5fd4c3c36653874599 Mon Sep 17 00:00:00 2001 From: ishmal Date: Sun, 4 May 2008 16:09:41 +0000 Subject: [PATCH] Remove warnings --- src/io/xsltstream.cpp | 39 ++++++++++++++++++++++++++++++++++----- src/io/xsltstream.h | 22 +++++++++++++++++++--- 2 files changed, 53 insertions(+), 8 deletions(-) diff --git a/src/io/xsltstream.cpp b/src/io/xsltstream.cpp index 71619a51e..6f35d9cb6 100644 --- a/src/io/xsltstream.cpp +++ b/src/io/xsltstream.cpp @@ -2,9 +2,9 @@ * XSL Transforming input and output classes * * Authors: - * Bob Jamison + * Bob Jamison * - * Copyright (C) 2004 Inkscape.org + * Copyright (C) 2004-2008 Inkscape.org * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -25,25 +25,54 @@ namespace IO //######################################################################### //# X S L T S T Y L E S H E E T //######################################################################### + /** * - */ -XsltStyleSheet::XsltStyleSheet(InputStream &xsltSource) throw (StreamException) + */ +XsltStyleSheet::XsltStyleSheet(InputStream &xsltSource) + throw (StreamException) + : stylesheet(NULL) +{ + if (!read(xsltSource)) { + throw StreamException("read failed"); + } +} + +/** + * + */ +XsltStyleSheet::XsltStyleSheet() + : stylesheet(NULL) +{ +} + + + +/** + * + */ +bool XsltStyleSheet::read(InputStream &xsltSource) { StringOutputStream outs; pipeStream(xsltSource, outs); std::string strBuf = outs.getString().raw(); xmlDocPtr doc = xmlParseMemory(strBuf.c_str(), strBuf.size()); stylesheet = xsltParseStylesheetDoc(doc); + //following not necessary. handled by xsltFreeStylesheet(stylesheet); //xmlFreeDoc(doc); + if (!stylesheet) + return false; + return true; } + /** * */ XsltStyleSheet::~XsltStyleSheet() { - xsltFreeStylesheet(stylesheet); + if (stylesheet) + xsltFreeStylesheet(stylesheet); } diff --git a/src/io/xsltstream.h b/src/io/xsltstream.h index 13d9550fa..32d9d12f8 100644 --- a/src/io/xsltstream.h +++ b/src/io/xsltstream.h @@ -5,9 +5,9 @@ * * * Authors: - * Bob Jamison + * Bob Jamison * - * Copyright (C) 2004 Inkscape.org + * Copyright (C) 2004-2008 Inkscape.org * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -35,8 +35,24 @@ class XsltStyleSheet public: + /** + * Constructor with loading + */ XsltStyleSheet(InputStream &source) throw (StreamException); - + + /** + * Simple constructor, no loading + */ + XsltStyleSheet(); + + /** + * Loader + */ + bool read(InputStream &source); + + /** + * Destructor + */ virtual ~XsltStyleSheet(); xsltStylesheetPtr stylesheet; -- 2.30.2