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

# /Users/fpy/titan-1-5-MBARI/Mers/Utils/Io/Xml/Sax/DoubleCH.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 "DoubleCH.h"
    00012 #include <xercesc/util/XMLString.hpp>
    00013 #include <xercesc/util/XMLDouble.hpp>
    00014 #include <xercesc/sax2/SAX2XMLReader.hpp>
    00015
    00017
    00018 using namespace Mers::Utils::Io::Xml::Sax;
    00019 using XERCES_CPP_NAMESPACE::SAX2XMLReader;
    00020 using XERCES_CPP_NAMESPACE::Attributes;
    00021 using XERCES_CPP_NAMESPACE::XMLString;
    00022 using XERCES_CPP_NAMESPACE::XMLDouble;
    00023
    00025
    00026 DoubleCH::DoubleCH( SAX2XMLReader * reader,
    00027         ContentHandler * parent, ContentCallback< double > * callback )
    00028         : ContentHandler( reader, parent ),
    00029                 m_Value( 0.0 ), m_Callback( callback )
    00030 {
    00031 }
    00032
    00034
    00035 void DoubleCH::characters( const XMLCh * const chars,
    00036         const unsigned int length )
    00037 {
    00038         // Note that these are not NULL terminated.
    00039         XMLCh * nullTermChars = new XMLCh[ length + 1 ];
    00040         XMLString::copyNString( nullTermChars, chars, length );
    00041
    00042         // If this is not all spaces, convert it to a double.
    00043         if( !XMLString::isAllWhiteSpace( nullTermChars ) ) {
    00044                 XMLDouble dbl( nullTermChars );
    00045                 m_Value = dbl.getValue();
    00046         }
    00047
    00048         delete[] nullTermChars;
    00049 }
    00050
    00052
    00053 void DoubleCH::endElement(const XMLCh * const uri,
    00054         const XMLCh * const localname, const XMLCh * const qname)
    00055 {
    00056         // Call our callback function.
    00057         m_Callback->handleContent( m_Value, localname );
    00058
    00059         // Do the default stuff.  This may delete us.
    00060         ContentHandler::endElement( uri, localname, qname );
    00061 }
    00062
    00064