Annotation of parser3/src/types/pa_vdnode.C, revision 1.1
1.1 ! parser 1: /** @node
! 2: Parser: @b dnode parser type.
! 3:
! 4: Copyright(c) 2001 ArtLebedev Group(http://www.artlebedev.com)
! 5:
! 6: Author: Alexander Petrosyan <paf@design.ru>(http://design.ru/paf)
! 7:
! 8: $Id: pa_vnode.C,v 1.1 2001/09/15 11:48:41 parser Exp $
! 9: */
! 10:
! 11: #if _MSC_VER
! 12: # pragma warning(disable:4291) // disable warning
! 13: // "no matching operator delete found; memory will not be freed if initialization throws an exception
! 14: #endif
! 15:
! 16: #include "pa_vdnode.h"
! 17: #include "pa_vstring.h"
! 18:
! 19: #include <util/XMLString.hpp>
! 20: #include <util/PlatformUtils.hpp>
! 21: #include <util/TransService.hpp>
! 22: /*
! 23: void VDnode_cleanup(void *vnode) {
! 24: //_asm int 3;
! 25: static_cast<VDDom *>(vnode)->cleanup();
! 26: }
! 27: */
! 28:
! 29: /// @test pool maxBytes
! 30: static const char *strX(const XalanDOMString& s) {
! 31: // return XMLString::transcode(s.c_str());
! 32: XMLTransService::Codes resValue;
! 33: XMLTranscoder& transcoder=*XMLPlatformUtils::fgTransService->makeNewTranscoderFor(
! 34: "windows-1251", resValue, 0x400);
! 35: const unsigned int maxBytes=0x100;
! 36: XMLByte* toFill=(XMLByte *)malloc(maxBytes*sizeof(XMLByte));
! 37: unsigned int charsEaten;
! 38: unsigned int size=transcoder.transcodeTo(
! 39: s.c_str(), s.length(),
! 40: toFill,
! 41: maxBytes,
! 42: charsEaten,
! 43: XMLTranscoder::UnRep_RepChar /*UnRep_Throw*/
! 44: );
! 45: toFill[size]=0;
! 46: return (const char *)toFill;
! 47: }
! 48:
! 49: void _throw(Pool& pool, const String *source, const XSLException& e) {
! 50: if(e.getURI().empty())
! 51: PTHROW(0, 0,
! 52: source,
! 53: "%s (%s)",
! 54: strX(e.getMessage()), // message for exception
! 55: strX(e.getType()) // type of exception
! 56: );
! 57: else
! 58: PTHROW(0, 0,
! 59: source,
! 60: "%s (%s) %s(%d:%d)'",
! 61: strX(e.getMessage()), // message for exception
! 62: strX(e.getType()), // type of exception
! 63:
! 64: strX(e.getURI()), // URI for the associated document, if any
! 65: e.getLineNumber(), // line number, or -1 if unknown
! 66: e.getColumnNumber() // column number, or -1 if unknown
! 67: );
! 68: }
! 69:
! 70: /// VDnode: $CLASS,$method
! 71: Value *VDnode::get_element(const String& aname) {
! 72: // $CLASS,$method
! 73: if(Value *result=VStateless_object::get_element(aname))
! 74: return result;
! 75:
! 76: // fields
! 77:
! 78: if(aname=="name") {
! 79: const char *name_cstr=strX(get_node(pool(), &aname).getNodeName());
! 80: String& name=*NEW String(pool(), name_cstr);
! 81: return NEW VString(name);
! 82: }
! 83:
! 84: if(aname=="value") {
! 85: const char *value_cstr=strX(get_node(pool(), &aname).getNodeValue());
! 86: String& value=*NEW String(pool(), value_cstr);
! 87: return NEW VString(value);
! 88: }
! 89:
! 90: if(aname=="first-child") {
! 91: return NEW VDnode(pool(), get_node(pool(), &aname).getFirstChild());
! 92: }
! 93:
! 94: return 0;
! 95: }
E-mail: