- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# /Users/fpy/titan-1-5-MBARI/Mers/Utils/Io/Xml/Sax/StringCH.cpp

    00001
    00002 //
    00003 // Copyright (c) 2005           Model-based Embedded and Robotic Systems Group
    00004 // All Rights Reserved          Massachusetts Institute of Technology
    00005 //
    00006 // This software is provided as is. Model-based Embedded and Robotic Systems
    00007 // (MERS) group does not assume any responsibility.
    00008 //
    00010
    00011 #include "StringCH.h"
    00012 #include <Mers/Utils/Lang/String.h>
    00013 #include <xercesc/util/XMLString.hpp>
    00014 #include <xercesc/sax2/SAX2XMLReader.hpp>
    00015
    00017
    00018 using namespace Mers::Utils::Io::Xml::Sax;
    00019 using Mers::Utils::Lang::String;
    00020 using XERCES_CPP_NAMESPACE::SAX2XMLReader;
    00021 using XERCES_CPP_NAMESPACE::Attributes;
    00022 using XERCES_CPP_NAMESPACE::XMLString;
    00023
    00025
    00026 StringCH::StringCH( SAX2XMLReader * reader,
    00027         ContentHandler * parent, ContentCallback< String * > * callback )
    00028         : ContentHandler( reader, parent ),
    00029                 m_Callback( callback )
    00030 {
    00031         m_Value = new String();
    00032 }
    00033
    00035
    00036 void StringCH::characters( const XMLCh * const chars,
    00037         const unsigned int length )
    00038 {
    00039         // Note that these are not NULL terminated.
    00040         XMLCh * nullTermChars = new XMLCh[ length + 1 ];
    00041         XMLString::copyNString( nullTermChars, chars, length );
    00042         char * cChars = XMLString::transcode( nullTermChars );
    00043
    00044         *m_Value += cChars;
    00045
    00046         XMLString::release( &cChars );
    00047         delete[] nullTermChars;
    00048 }
    00049
    00051
    00052 void StringCH::endElement(const XMLCh * const uri,
    00053         const XMLCh * const localname, const XMLCh * const qname)
    00054 {
    00055         // Call our callback function.
    00056         m_Callback->handleContent( m_Value, localname );
    00057
    00058         // Do the default stuff.  This may delete us.
    00059         ContentHandler::endElement( uri, localname, qname );
    00060 }
    00061
    00063