// -*- mode: C++; tab-width: 4; indent-tabs-mode: t; -*- vim:ts=4:sw=4 // // Copyright (C) 2004,2005 David Lau (skunix) // Chong Kai Xiong (descender) // // This file is part of The Plains of Usata. // // The Plains of Usata is licensed under the GNU General Public // License (GPL) version 2. For details, please see the COPYING file // included in the software distribution, or visit // http://www.fsf.org/licenses/gpl.html. // // $Id: scene_parser.cpp,v 1.1 2005/02/16 06:30:02 skunix Exp $ #include #include #include #include "scene_parser.hpp" #include #include namespace usata { class SceneDocument : public SceneElement { SceneDocument(SceneParser *parser); }; SceneParser::SceneParser(std::istream& stream, const std::string& stream_name) : mIs(stream), mStreamName(stream_name) { } void SceneParser::init() { } SceneParser::~SceneParser() { if (mThread.get()) { // std::cout << "waiting " << std::endl; mThread->join(); } } void SceneParser::element_start(const char* name, const char**attrib) { } void SceneParser::element_end(const char*) { } void SceneParser::content(const char*buf, int len) { } void SceneParser::thread_main() { std::streamsize readlen; std::streamsize x=0; bool done(false); void*buf; while (!done) { buf = get_buffer(1024); mIs.read(static_cast(buf),1024); readlen=mIs.gcount(); x+=readlen; if (!mIs) done=true; if (!parse_chunkb(readlen, done)) { std::cout << get_error() << std::endl; return; } } return; } void SceneParser::threaded_parse() { mThread.reset(new boost::thread(boost::bind(&SceneParser::thread_main,this))); } }