dbertoni    2002/11/13 17:56:58

  Modified:    c/src/XSLT NamespacesHandler.cpp
  Log:
  More generic implementation.  Added typedefs for typenamed types.
  
  Revision  Changes    Path
  1.28      +45 -26    xml-xalan/c/src/XSLT/NamespacesHandler.cpp
  
  Index: NamespacesHandler.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/NamespacesHandler.cpp,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- NamespacesHandler.cpp     13 Nov 2002 17:51:20 -0000      1.27
  +++ NamespacesHandler.cpp     14 Nov 2002 01:56:57 -0000      1.28
  @@ -79,18 +79,19 @@
   
   
   
  -template<class VectorType>
  +template<class VectorType, class MemberFunctionType>
   const typename VectorType::value_type*
  -findByPrefix(
  +find(
                        const VectorType&               theVector,
  -                     const XalanDOMString&   thePrefix)
  +                     const XalanDOMString&   theString,
  +                     MemberFunctionType              theMemberFunction)
   {
        const typename VectorType::const_iterator       theEnd(theVector.end());
        typename VectorType::const_iterator                     
theCurrent(theVector.begin());
   
        while(theCurrent != theEnd)
        {
  -             if ((*theCurrent).getPrefix() == thePrefix)
  +             if (((*theCurrent).*theMemberFunction)() == theString)
                {
                        return &*theCurrent;
                }
  @@ -105,18 +106,19 @@
   
   
   
  -template<class VectorType>
  +template<class VectorType, class MemberFunctionType>
   typename VectorType::value_type*
  -findByPrefixNonConst(
  +findNonConst(
                        VectorType&                             theVector,
  -                     const XalanDOMString&   thePrefix)
  +                     const XalanDOMString&   theString,
  +                     MemberFunctionType              theMemberFunction)
   {
        const typename VectorType::iterator             theEnd(theVector.end());
        typename VectorType::iterator                   
theCurrent(theVector.begin());
   
        while(theCurrent != theEnd)
        {
  -             if ((*theCurrent).getPrefix() == thePrefix)
  +             if (((*theCurrent).*theMemberFunction)() == theString)
                {
                        return &*theCurrent;
                }
  @@ -133,26 +135,39 @@
   
   template<class VectorType>
   const typename VectorType::value_type*
  +findByPrefix(
  +                     const VectorType&               theVector,
  +                     const XalanDOMString&   thePrefix)
  +{
  +     typedef typename VectorType::value_type         value_type;
  +
  +     return find(theVector, thePrefix, &value_type::getPrefix);
  +}
  +
  +
  +
  +template<class VectorType>
  +typename VectorType::value_type*
  +findByPrefixNonConst(
  +                     VectorType&                             theVector,
  +                     const XalanDOMString&   thePrefix)
  +{
  +     typedef typename VectorType::value_type         value_type;
  +
  +     return findNonConst(theVector, thePrefix, &value_type::getPrefix);
  +}
  +
  +
  +
  +template<class VectorType>
  +const typename VectorType::value_type*
   findByURI(
                        const VectorType&               theVector,
                        const XalanDOMString&   theNamespaceURI)
   {
  -     const typename VectorType::const_iterator       theEnd(theVector.end());
  -     typename VectorType::const_iterator                     
theCurrent(theVector.begin());
  -
  -     while(theCurrent != theEnd)
  -     {
  -             if ((*theCurrent).getURI() == theNamespaceURI)
  -             {
  -                     return &*theCurrent;
  -             }
  -             else
  -             {
  -                     ++theCurrent;
  -             }
  -     }
  +     typedef typename VectorType::value_type         value_type;
   
  -     return 0;
  +     return find(theVector, theNamespaceURI, &value_type::getURI);
   }
   
   
  @@ -165,7 +180,9 @@
                        const XalanDOMString&                   thePrefix,
                        const XalanDOMString&                   theURI)
   {
  -     const typename VectorType::value_type* const            theEntry =
  +     typedef typename VectorType::value_type         value_type;
  +
  +     const value_type* const         theEntry =
                findByPrefix(theVector, thePrefix);
   
        if (theEntry != 0)
  @@ -175,7 +192,7 @@
        else
        {
                theVector.push_back(
  -                     VectorType::value_type(
  +                     value_type(
                                
theConstructionContext.getPooledString(thePrefix),
                                
theConstructionContext.getPooledString(theURI)));
   
  @@ -193,7 +210,9 @@
                        const XalanDOMString&                   thePrefix,
                        const XalanDOMString&                   theURI)
   {
  -     typename VectorType::value_type* const  theEntry =
  +     typedef typename VectorType::value_type         value_type;
  +
  +     value_type* const       theEntry =
                findByPrefixNonConst(theVector, thePrefix);
   
        if (theEntry == 0)
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to