--- parser3/src/main/pa_pool.C 2001/10/19 12:43:30 1.34 +++ parser3/src/main/pa_pool.C 2001/10/19 14:42:53 1.36 @@ -4,7 +4,7 @@ Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - $Id: pa_pool.C,v 1.34 2001/10/19 12:43:30 parser Exp $ + $Id: pa_pool.C,v 1.36 2001/10/19 14:42:53 parser Exp $ */ #include "pa_pool.h" @@ -63,7 +63,7 @@ void Pool::update_transcoder() { XMLTransService::Codes resValue; transcoder=XMLPlatformUtils::fgTransService->makeNewTranscoderFor(charset->cstr(), resValue, 60); if(!transcoder) - THROW(0, 0, + throw Exception(0, 0, charset, "unsupported encoding"); } @@ -87,7 +87,7 @@ const char *Pool::transcode_cstr(const X error=false; } } catch(XMLException& e) { - exception()._throw(*this, 0, e); + Exception::convert(*this, 0, e); } return (const char *)dest; } @@ -95,14 +95,13 @@ String& Pool::transcode(const XalanDOMSt return *new(*this) String(*this, transcode_cstr(s)); } -/// @test who would free up result? -XalanDOMString& Pool::transcode_buf(const char *buf, size_t buf_size) { +std::auto_ptr Pool::transcode_buf(const char *buf, size_t buf_size) { update_transcoder(); unsigned int dest_size=0; XMLCh* dest=(XMLCh *)malloc((buf_size+1)*sizeof(XMLCh)); unsigned char *charSizes=(unsigned char *)malloc(buf_size*sizeof(unsigned char)); - XalanDOMString *result; + std::auto_ptr result; try { if(transcoder) { unsigned int bytesEaten; @@ -113,15 +112,15 @@ XalanDOMString& Pool::transcode_buf(cons bytesEaten, charSizes ); - result=new XalanDOMString(dest, dest_size); + result=std::auto_ptr(new XalanDOMString(dest, dest_size)); } } catch(XMLException& e) { - exception()._throw(*this, 0, e); + Exception::convert(*this, 0, e); } - return *result; + return result; } -XalanDOMString& Pool::transcode(const String& s) { +std::auto_ptr Pool::transcode(const String& s) { const char *cstr=s.cstr(String::UL_XML); return transcode_buf(cstr, strlen(cstr));