xalan-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbert...@apache.org
Subject cvs commit: xml-xalan/c/src/XSLT CountersTable.cpp CountersTable.hpp ElemNumber.cpp ElemNumber.hpp StylesheetExecutionContextDefault.cpp StylesheetHandler.cpp StylesheetRoot.cpp StylesheetRoot.hpp
Date Tue, 24 Sep 2002 06:57:43 GMT
dbertoni    2002/09/23 23:57:43

  Modified:    c/src/XSLT CountersTable.cpp CountersTable.hpp
                        ElemNumber.cpp ElemNumber.hpp
                        StylesheetExecutionContextDefault.cpp
                        StylesheetHandler.cpp StylesheetRoot.cpp
                        StylesheetRoot.hpp
  Log:
  Use vector for xsl:number counters table.
  
  Revision  Changes    Path
  1.4       +7 -5      xml-xalan/c/src/XSLT/CountersTable.cpp
  
  Index: CountersTable.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/CountersTable.cpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CountersTable.cpp	26 Sep 2001 21:30:23 -0000	1.3
  +++ CountersTable.cpp	24 Sep 2002 06:57:42 -0000	1.4
  @@ -90,16 +90,18 @@
   int
   CountersTable::countNode(
   			StylesheetExecutionContext&		support,
  -			const ElemNumber*				numberElem,
  +			const ElemNumber&				numberElem,
   			XalanNode*						node)
   {
  +	assert(numberElem.getID() < m_countersVector.size());
  +
   	int		count = 0;
   
  -	CounterVectorType&	counters = m_counterMap[numberElem];
  +	CounterVectorType&	counters = m_countersVector[numberElem.getID()];
   
   	const CounterVectorType::size_type	nCounters = counters.size();
   
  -	XalanNode*	target = numberElem->getTargetNode(support, node);
  +	XalanNode*	target = numberElem.getTargetNode(support, node);
   
   	if(0 != target)
   	{
  @@ -121,7 +123,7 @@
   		// the backwards list (m_newFound) to the forwards list
   		// (counter.m_countNodes).
   		count = 0;
  -		for(; 0 != target; target = numberElem->getPreviousNode(support, target))
  +		for(; 0 != target; target = numberElem.getPreviousNode(support, target))
   		{   
   			// First time in, we should not have to check for previous counts, 
   			// since the original target node was already checked in the 
  @@ -157,7 +159,7 @@
   
   		// If we got to this point, then we didn't find a counter, so make 
   		// one and add it to the list.
  -		counters.push_back(Counter(numberElem));
  +		counters.push_back(Counter(&numberElem));
   
   		Counter&	counter = counters.back();
   
  
  
  
  1.6       +24 -13    xml-xalan/c/src/XSLT/CountersTable.hpp
  
  Index: CountersTable.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/CountersTable.hpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- CountersTable.hpp	1 Aug 2002 18:09:27 -0000	1.5
  +++ CountersTable.hpp	24 Sep 2002 06:57:42 -0000	1.6
  @@ -182,13 +182,10 @@
   
   #if defined(XALAN_NO_NAMESPACES)
   	typedef vector<Counter>					CounterVectorType;
  -	typedef map<const ElemNumber*,
  -				CounterVectorType,
  -				less<const ElemNumber*> >	ElemToCounterVectorMapType;
  +	typedef vector<CounterVectorType>		ElemCounterVectorVectorType;
   #else
   	typedef std::vector<Counter>			CounterVectorType;
  -	typedef std::map<const ElemNumber*,
  -					 CounterVectorType>		ElemToCounterVectorMapType;
  +	typedef std::vector<CounterVectorType>	ElemCounterVectorVectorType;
   #endif
   
   	typedef Counter::NodeVectorType			NodeVectorType;
  @@ -196,14 +193,28 @@
   	/**
   	 * Construct a CountersTable.
   	 */
  -	CountersTable() :
  -		m_counterMap(),
  +	CountersTable(unsigned long		theSize = 0) :
  +		m_countersVector(),
   		m_newFound()
   	{
  +		resize(theSize);
   	};
   
   
   	/**
  +	 * Resize the table.  The must be done prior
  +	 * to using the table, if the size was not past
  +	 * in the constructor.
  +	 *
  +	 * @theSize The new size
  +	 */
  +	void
  +	resize(unsigned long	theSize)
  +	{
  +		m_countersVector.resize(theSize);
  +	}
  +
  +	/**
   	 * Count forward until the given node is found, or until 
   	 * we have looked to the given amount.
   	 *
  @@ -215,7 +226,7 @@
   	int
   	countNode(
   			StylesheetExecutionContext&		executionContext,
  -			const ElemNumber*				numberElem,
  +			const ElemNumber&				numberElem,
   			XalanNode*						node);
   
   	/**
  @@ -226,21 +237,21 @@
   	{
   		m_newFound.clear();
   
  -		m_counterMap.clear();
  +		m_countersVector.clear();
   	}
   
   private:
   
   	/**
  -	 * A map which holds counters for ElemNumber instances.
  +	 * A vector which holds counters for ElemNumber instances.
   	 */
  -	ElemToCounterVectorMapType	m_counterMap;
  +	ElemCounterVectorVectorType		m_countersVector;
   
   
   	/**
   	 * A vector to use as a temporary buffer.
   	 */
  -	NodeVectorType				m_newFound;
  +	NodeVectorType					m_newFound;
   };
   
   
  
  
  
  1.65      +6 -4      xml-xalan/c/src/XSLT/ElemNumber.cpp
  
  Index: ElemNumber.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemNumber.cpp,v
  retrieving revision 1.64
  retrieving revision 1.65
  diff -u -r1.64 -r1.65
  --- ElemNumber.cpp	24 Sep 2002 01:42:34 -0000	1.64
  +++ ElemNumber.cpp	24 Sep 2002 06:57:42 -0000	1.65
  @@ -107,7 +107,8 @@
   			Stylesheet&						stylesheetTree,
   			const AttributeList&			atts,
   			int								lineNumber,
  -			int								columnNumber) :
  +			int								columnNumber,
  +			unsigned long					id) :
   	ElemTemplateElement(constructionContext,
   						stylesheetTree,
   						lineNumber,
  @@ -121,7 +122,8 @@
   	m_lang_avt(0),
   	m_lettervalue_avt(0),
   	m_groupingSeparator_avt(0),
  -	m_groupingSize_avt(0)
  +	m_groupingSize_avt(0),
  +	m_id(id)
   	
   {
   	const unsigned int	nAttrs = atts.getLength();
  @@ -499,7 +501,7 @@
   
   		numberList[i] = ctable.countNode(
   							executionContext,
  -							this,
  +							*this,
   							target);
   	}
   
  @@ -550,7 +552,7 @@
   		if(eAny == m_level)
   		{
   			const int	theNumber =
  -				ctable.countNode(executionContext, this, sourceNode);
  +				ctable.countNode(executionContext, *this, sourceNode);
   
   			formatNumberList(
   				executionContext,
  
  
  
  1.41      +11 -1     xml-xalan/c/src/XSLT/ElemNumber.hpp
  
  Index: ElemNumber.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemNumber.hpp,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- ElemNumber.hpp	9 Sep 2002 18:39:49 -0000	1.40
  +++ ElemNumber.hpp	24 Sep 2002 06:57:42 -0000	1.41
  @@ -132,13 +132,15 @@
   	 * @param atts                list of attributes for element
   	 * @param lineNumber				line number in document
   	 * @param columnNumber			column number in document
  +	 * @param id				  The unique ID within the stylesheet for this xsl:number element
   	 */
   	ElemNumber(
   			StylesheetConstructionContext&	constructionContext,
   			Stylesheet&						stylesheetTree,
   			const AttributeList&			atts,
   			int								lineNumber,
  -			int								columnNumber);
  +			int								columnNumber,
  +			unsigned long					id);
   
   	virtual
   	~ElemNumber();
  @@ -151,6 +153,12 @@
   	virtual void
   	execute(StylesheetExecutionContext&		executionContext) const;
   
  +	unsigned long
  +	getID() const
  +	{
  +		return m_id;
  +	}
  +
   	/**
   	 * Get the previous node to be counted.
   	 */
  @@ -392,6 +400,8 @@
   	const AVT*		m_lettervalue_avt;
   	const AVT*		m_groupingSeparator_avt;
   	const AVT*		m_groupingSize_avt;
  +
  +	const unsigned long		m_id;
   
   	/**
    	 * The string "@".
  
  
  
  1.102     +2 -0      xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.cpp
  
  Index: StylesheetExecutionContextDefault.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.cpp,v
  retrieving revision 1.101
  retrieving revision 1.102
  diff -u -r1.101 -r1.102
  --- StylesheetExecutionContextDefault.cpp	24 Sep 2002 05:59:38 -0000	1.101
  +++ StylesheetExecutionContextDefault.cpp	24 Sep 2002 06:57:42 -0000	1.102
  @@ -297,6 +297,8 @@
   	{
   		m_xsltProcessor->setExecutionContext(this);
   	}
  +
  +	m_countersTable.resize(theStylesheet->getElemNumberCount());
   }
   
   
  
  
  
  1.89      +7 -3      xml-xalan/c/src/XSLT/StylesheetHandler.cpp
  
  Index: StylesheetHandler.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetHandler.cpp,v
  retrieving revision 1.88
  retrieving revision 1.89
  diff -u -r1.88 -r1.89
  --- StylesheetHandler.cpp	24 Sep 2002 05:59:38 -0000	1.88
  +++ StylesheetHandler.cpp	24 Sep 2002 06:57:42 -0000	1.89
  @@ -513,9 +513,13 @@
   					break;
   
   				case StylesheetConstructionContext::ELEMNAME_NUMBER:
  -					elem = new ElemNumber(m_constructionContext,
  -										m_stylesheet,
  -										atts, lineNumber, columnNumber);
  +					elem = new ElemNumber(
  +							m_constructionContext,
  +							m_stylesheet,
  +							atts,
  +							lineNumber,
  +							columnNumber,
  +							m_stylesheet.getStylesheetRoot().getNextElemNumberID());
   					break;
             
   				case StylesheetConstructionContext::ELEMNAME_VARIABLE:
  
  
  
  1.63      +2 -1      xml-xalan/c/src/XSLT/StylesheetRoot.cpp
  
  Index: StylesheetRoot.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetRoot.cpp,v
  retrieving revision 1.62
  retrieving revision 1.63
  diff -u -r1.62 -r1.63
  --- StylesheetRoot.cpp	21 Sep 2002 01:24:41 -0000	1.62
  +++ StylesheetRoot.cpp	24 Sep 2002 06:57:42 -0000	1.63
  @@ -142,7 +142,8 @@
   	m_needToBuildKeysTable(false),
   	m_outputEscapeURLs(true),
   	m_indentAmount(-1),
  -	m_omitMETATag(false)
  +	m_omitMETATag(false),
  +	m_elemNumberNextID(0)
   {
   	// Our base class has already resolved the URI and pushed it on
   	// the back of the include stack, so get it from there...
  
  
  
  1.21      +16 -0     xml-xalan/c/src/XSLT/StylesheetRoot.hpp
  
  Index: StylesheetRoot.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetRoot.hpp,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- StylesheetRoot.hpp	21 Sep 2002 01:24:41 -0000	1.20
  +++ StylesheetRoot.hpp	24 Sep 2002 06:57:42 -0000	1.21
  @@ -443,6 +443,18 @@
   			StylesheetExecutionContext&		executionContext,
   			KeyTablesTableType&				theKeysTable) const;
   
  +	unsigned long
  +	getNextElemNumberID()
  +	{
  +		return m_elemNumberNextID++;
  +	}
  +
  +	unsigned long
  +	getElemNumberCount() const
  +	{
  +		return m_elemNumberNextID;
  +	}
  +
   private:
   
   	/**
  @@ -509,6 +521,10 @@
   	 */
   	bool						m_omitMETATag;
   
  +	/**
  +	 * This is set to true if we should omit the META tag in HTML output (the default is false)
  +	 */
  +	unsigned long				m_elemNumberNextID;
   
   	// Not implemented...
       StylesheetRoot(const StylesheetRoot&);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org


Mime
View raw message