diff options
| author | Bent Bisballe Nyeng <deva@aasimon.org> | 2018-07-25 21:31:27 +0200 | 
|---|---|---|
| committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2018-08-12 11:16:31 +0200 | 
| commit | 3e25a2a2f1fb881debade053d4862f094614e24a (patch) | |
| tree | 77c20d61e99306e3aa33054bb8f1eb0d4e6ae0e2 /src | |
| parent | f2fa9543a11fd5551aa619160d5a02b886fb1bbb (diff) | |
Remove obsolete SAXParser class and eXpat dependency.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Makefile.am | 8 | ||||
| -rw-r--r-- | src/saxparser.cc | 132 | ||||
| -rw-r--r-- | src/saxparser.h | 65 | 
3 files changed, 2 insertions, 203 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 14da4d6..3ecdc76 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,12 +4,10 @@ libdg_la_CPPFLAGS = \  	-I$(top_srcdir)/include -I$(top_srcdir)/hugin \  	-I$(top_srcdir)/hugin -I$(top_srcdir)/pugixml/src \  	$(SSEFLAGS) \ -	$(ZITA_CPPFLAGS) $(SNDFILE_CFLAGS) $(EXPAT_CFLAGS) \ -	$(PTHREAD_CFLAGS) +	$(ZITA_CPPFLAGS) $(SNDFILE_CFLAGS) $(PTHREAD_CFLAGS)  libdg_la_LIBADD = \ -	$(ZITA_LIBS) $(SNDFILE_LIBS) $(EXPAT_LIBS) \ -	$(PTHREAD_LIBS) +	$(ZITA_LIBS) $(SNDFILE_LIBS) $(PTHREAD_LIBS)  # If you add a file here, remember to add it to plugin/Makefile.mingw32.in  nodist_libdg_la_SOURCES = \ @@ -41,7 +39,6 @@ nodist_libdg_la_SOURCES = \  	random.cc \  	sample.cc \  	semaphore.cc \ -	saxparser.cc \  	staminafilter.cc \  	thread.cc \  	versionstr.cc @@ -85,7 +82,6 @@ EXTRA_DIST = \  	random.h \  	rangemap.h \  	sample.h \ -	saxparser.h \  	semaphore.h \  	settings.h \  	staminafilter.h \ diff --git a/src/saxparser.cc b/src/saxparser.cc deleted file mode 100644 index 280e608..0000000 --- a/src/saxparser.cc +++ /dev/null @@ -1,132 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/*************************************************************************** - *            saxparser.cc - * - *  Tue Jul 22 16:26:22 CEST 2008 - *  Copyright 2008 Bent Bisballe Nyeng - *  deva@aasimon.org - ****************************************************************************/ - -/* - *  This file is part of DrumGizmo. - * - *  DrumGizmo is free software; you can redistribute it and/or modify - *  it under the terms of the GNU Lesser General Public License as published by - *  the Free Software Foundation; either version 3 of the License, or - *  (at your option) any later version. - * - *  DrumGizmo is distributed in the hope that it will be useful, - *  but WITHOUT ANY WARRANTY; without even the implied warranty of - *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - *  GNU Lesser General Public License for more details. - * - *  You should have received a copy of the GNU Lesser General Public License - *  along with DrumGizmo; if not, write to the Free Software - *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA. - */ -#include "saxparser.h" - -#include <sstream> -#include <iostream> - -#include <hugin.hpp> - -SAXParser::SAXParser() -{ -	parser = XML_ParserCreate(nullptr); -	if(!parser) -	{ -		ERR(sax, "Couldn't allocate memory for parser\n"); -		// throw Exception(...); TODO -		return; -	} - -	XML_SetUserData(parser, this); -	XML_UseParserAsHandlerArg(parser); -	XML_SetElementHandler(parser, SAXParser::startHandler, SAXParser::endHandler); -	XML_SetCharacterDataHandler(parser, SAXParser::characterHandler); -} - -SAXParser::~SAXParser() -{ -	XML_ParserFree(parser); -} - -int SAXParser::parseFile(const std::string& filename) -{ -	if(filename.empty()) -	{ -		return 0; -	} - -	std::ifstream file(filename, std::ifstream::in); - -	if(!file.is_open()) -	{ -		return 1; -	} - -	std::stringstream ss; -	ss << file.rdbuf(); -	std::string str = ss.str(); - -	return parseString(str, filename); -} - -int SAXParser::parseString(const std::string& str, -                           const std::string& xml_source_name) -{ -	DEBUG(sax, "parse(buffer %d bytes)\n", (int)str.length()); - -	if(!XML_Parse(parser, str.c_str(), str.length(), true)) -	{ -		parseError(str, XML_ErrorString(XML_GetErrorCode(parser)), -		           xml_source_name, (int)XML_GetCurrentLineNumber(parser)); -		return 1; -	} - -	return 0; -} - -void SAXParser::parseError(const std::string& buf, const std::string& error, -                           const std::string& xml_source_name, -                           std::size_t lineno) -{ -	std::cerr << "SAXParser error trying to parse from source: " << -		xml_source_name << "\n"; -	std::cerr << "At line " << lineno << ": " << error << "\n"; -	std::cerr << "Buffer " << buf.size() << " bytes: \n[\n"; -	std::cerr << buf; -	std::cerr << "\n]" << std::endl; -} - -void SAXParser::characterHandler(void* parser, const XML_Char* cData, int len) -{ -	SAXParser* sax_parser = (SAXParser*)XML_GetUserData(parser); -	std::string chars(cData, len); -	sax_parser->characterData(chars); -} - -void SAXParser::startHandler(void* parser, const char* el, const char** attr) -{ -	SAXParser* sax_parser = (SAXParser*)XML_GetUserData(parser); - -	// Convert to comfy C++ values... -	attr_t attributes; - -	while(*attr) -	{ -		std::string at_name = *attr++; -		std::string at_value = *attr++; - -		attributes.emplace(at_name, at_value); -	} - -	sax_parser->startTag(std::string(el), attributes); -} - -void SAXParser::endHandler(void* parser, const char* el) -{ -	SAXParser* sax_parser = (SAXParser*)XML_GetUserData(parser); -	sax_parser->endTag(std::string(el)); -} diff --git a/src/saxparser.h b/src/saxparser.h deleted file mode 100644 index 4b1a273..0000000 --- a/src/saxparser.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/*************************************************************************** - *            saxparser.h - * - *  Tue Jul 22 16:26:21 CEST 2008 - *  Copyright 2008 Bent Bisballe Nyeng - *  deva@aasimon.org - ****************************************************************************/ - -/* - *  This file is part of DrumGizmo. - * - *  DrumGizmo is free software; you can redistribute it and/or modify - *  it under the terms of the GNU Lesser General Public License as published by - *  the Free Software Foundation; either version 3 of the License, or - *  (at your option) any later version. - * - *  DrumGizmo is distributed in the hope that it will be useful, - *  but WITHOUT ANY WARRANTY; without even the implied warranty of - *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - *  GNU Lesser General Public License for more details. - * - *  You should have received a copy of the GNU Lesser General Public License - *  along with DrumGizmo; if not, write to the Free Software - *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA. - */ -#pragma once - -#include <string> -#include <unordered_map> -#include <expat.h> -#include <fstream> - -class SAXParser -{ -public: -	SAXParser(); -	virtual ~SAXParser(); - -	//! Parses the data from the file. -	virtual int parseFile(const std::string& filename); - -	//! Parses all the data in the buffer. -	virtual int parseString(const std::string& str, -	                        const std::string& xml_source_name = ""); - -protected: -	using attr_t = std::unordered_map<std::string, std::string>; - -	virtual void characterData(const std::string& data) {} -	virtual void startTag(const std::string& name, const attr_t& attr) {} -	virtual void endTag(const std::string& name) {} -	virtual void parseError(const std::string& buf, -	                        const std::string& error, -	                        const std::string& xml_source_name, -	                        std::size_t lineno); - -private: -	XML_Parser parser; -	std::string filename; - -	static void characterHandler(void* parser, const XML_Char* cData, int len); -	static void startHandler(void* parser, const char* el, const char** attr); -	static void endHandler(void* parser, const char* el); -};  | 
