00001 /* 00002 * Copyright 2002-2005 The Apache Software Foundation. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 /* 00018 * XSEC 00019 * 00020 * XSECCanon := Base (abstract) class for canonicalisation objects 00021 * 00022 * 00023 * Author(s): Berin Lautenbach 00024 * 00025 * $Id: XSECCanon.hpp,v 1.7 2005/02/03 13:09:31 milan Exp $ 00026 */ 00027 00028 // XSEC includes 00029 #include <xsec/framework/XSECDefs.hpp> 00030 #include <xsec/utils/XSECSafeBuffer.hpp> 00031 00032 XSEC_DECLARE_XERCES_CLASS(DOMNode); 00033 XSEC_DECLARE_XERCES_CLASS(DOMDocument); 00034 00035 // -------------------------------------------------------------------------------- 00036 // Defines 00037 // -------------------------------------------------------------------------------- 00038 00039 #define XSECCANNON_BUFFER_START_SIZE 8192 /* Default size for the outBuffer */ 00040 00041 00042 // -------------------------------------------------------------------------------- 00043 // XSECCanon Virtual Class definition 00044 // -------------------------------------------------------------------------------- 00045 00046 // Most of the interface work is done within this class. However the actual 00047 // processing is done via the processNextNode virtual function that must be 00048 // implemented by all children classes. 00049 00050 class CANON_EXPORT XSECCanon { 00051 00052 protected: 00053 00054 // Data structures 00055 00056 XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * mp_doc; // Xerces DOM Node that defines the document 00057 XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * mp_startNode, // Node to start processing from 00058 *mp_nextNode; // Next Node to be processeed 00059 safeBuffer m_buffer; // Buffer holding parsed output 00060 int m_bufferLength, // Length of input currently in buffer 00061 m_bufferPoint; // Next "character" to copy out 00062 bool m_allNodesDone; // Have we completed? 00063 00064 00065 public: 00066 00067 // Constructors 00068 00069 XSECCanon(); 00070 XSECCanon(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *newDoc); 00071 XSECCanon( 00072 XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *newDoc, 00073 XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *newStartNode); 00074 00075 // Destructors 00076 00077 virtual ~XSECCanon(); 00078 00079 // Public Methods 00080 00081 // outputBuffer is used by all canonicalisers to output the next numBytes bytes of 00082 // canonicalised XML to the nominated buffer 00083 00084 int outputBuffer(unsigned char *outBuffer, int numBytes); 00085 00086 // setStartNode sets the starting point for the output if it is a sub-document 00087 // that needs canonicalisation and we want to re-start 00088 00089 bool setStartNode(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *newStartNode); 00090 00091 protected: 00092 00093 // processNextNode is the pure virtual function that must be implemented by all canons 00094 00095 virtual int processNextNode() = 0; 00096 00097 }; 00098