You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@locus.apache.org on 2000/08/11 23:14:57 UTC

cvs commit: xml-xalan/c/src/PlatformSupport URISupport.cpp

dbertoni    00/08/11 14:14:56

  Modified:    c/src/PlatformSupport URISupport.cpp
  Log:
  New functions.
  
  Revision  Changes    Path
  1.6       +52 -42    xml-xalan/c/src/PlatformSupport/URISupport.cpp
  
  Index: URISupport.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/URISupport.cpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- URISupport.cpp	2000/06/27 16:28:32	1.5
  +++ URISupport.cpp	2000/08/11 21:14:54	1.6
  @@ -74,64 +74,65 @@
   URISupport::URLAutoPtrType
   URISupport::getURLFromString(const XalanDOMString&	urlString)
   {
  -#if !defined(XALAN_NO_NAMESPACES)
  -	using std::auto_ptr;
  -#endif
  -
   	URLAutoPtrType	url(new XMLURL);
   
   	try 
  +	{
  +		url->setURL(c_wstr(getURLStringFromString(urlString)));
  +	}
  +	catch (...)
   	{
  -		XalanDOMString	theNormalizedURI(clone(urlString));
  +		throw ("Error! Cannot create url for: " + urlString);
  +	}
  +	return url;
  +}
   
  -		// Let's see what sort of URI we have...
  -		const unsigned int	len = length(theNormalizedURI);
  -		const unsigned int	index = indexOf(theNormalizedURI, ':');
  +XalanDOMString
  +URISupport::getURLStringFromString(const XalanDOMString&	urlString)
  +{
  +	XalanDOMString	theNormalizedURI(clone(urlString));
   
  -		bool				protocolPresent = false;
  +	// Let's see what sort of URI we have...
  +	const unsigned int	len = length(theNormalizedURI);
  +	const unsigned int	index = indexOf(theNormalizedURI, ':');
   
  -		if (index != len)
  -		{
  -			// $$$ ToDo: XMLURL::lookupByName() is supposed to be static, but is not.
  -			const XMLURL::Protocols		theProtocol =
  -				XMLURL().lookupByName(c_wstr(substring(theNormalizedURI, 0 , index)));
  +	bool				protocolPresent = false;
   
  -			if (theProtocol != XMLURL::Unknown)
  -			{
  -				protocolPresent = true;
  -			}
  -		}
  +	if (index != len)
  +	{
  +		// $$$ ToDo: XMLURL::lookupByName() is supposed to be static, but is not.
  +		const XMLURL::Protocols		theProtocol =
  +			XMLURL().lookupByName(c_wstr(substring(theNormalizedURI, 0 , index)));
   
  -		if (protocolPresent == true)
  +		if (theProtocol != XMLURL::Unknown)
   		{
  -			NormalizeURIText(theNormalizedURI);
  +			protocolPresent = true;
   		}
  -		else
  -		{
  -			// Assume it's a file specification...
  -			array_auto_ptr<XMLCh>	theFullPath(XMLPlatformUtils::getFullPath(c_wstr(urlString)));
  -			assert(theFullPath.get() != 0);
  +	}
   
  -			theNormalizedURI = theFullPath.get();
  -			assert(length(theNormalizedURI) > 0);
  +	if (protocolPresent == true)
  +	{
  +		NormalizeURIText(theNormalizedURI);
  +	}
  +	else
  +	{
  +		// Assume it's a file specification...
  +		array_auto_ptr<XMLCh>	theFullPath(XMLPlatformUtils::getFullPath(c_wstr(urlString)));
  +		assert(theFullPath.get() != 0);
   
  -			NormalizeURIText(theNormalizedURI);
  +		theNormalizedURI = theFullPath.get();
  +		assert(length(theNormalizedURI) > 0);
   
  -			const XalanDOMString	theFilePrefix(indexOf(theNormalizedURI, '/') == 0 ?
  -						XALAN_STATIC_UCODE_STRING("file://") :
  -						XALAN_STATIC_UCODE_STRING("file:///"));
  +		NormalizeURIText(theNormalizedURI);
   
  -			theNormalizedURI = theFilePrefix + theNormalizedURI;
  -		}
  +		const XalanDOMString	theFilePrefix(indexOf(theNormalizedURI, '/') == 0 ?
  +					XALAN_STATIC_UCODE_STRING("file://") :
  +					XALAN_STATIC_UCODE_STRING("file:///"));
   
  -		url->setURL(c_wstr(theNormalizedURI));
  -	}
  -	catch (...)
  -	{
  -		throw ("Error! Cannot create url for: " + urlString);
  +		theNormalizedURI = theFilePrefix + theNormalizedURI;
   	}
   
  -	return url;
  +	return theNormalizedURI;
   }
   
   
  @@ -140,6 +141,16 @@
   URISupport::getURLFromString(
   			const XalanDOMString&	urlString,
   			const XalanDOMString&	base)
  +{	
  +	return getURLFromString(getURLStringFromString(urlString, base));
  +}
  +
  +
  +
  +XalanDOMString
  +URISupport::getURLStringFromString(
  +			const XalanDOMString&	urlString,
  +			const XalanDOMString&	base)
   {
   	XalanDOMString	context(clone(base));
   
  @@ -223,7 +234,7 @@
   		}
   	}
   
  -	return getURLFromString(context);
  +	return getURLStringFromString(context);
   }
   
   
  @@ -232,7 +243,6 @@
   URISupport::NormalizeURIText(XalanDOMString&	uriString)
   {
   #if !defined(XALAN_NO_NAMESPACES)
  -	using std::vector;
   	using std::replace;
   #endif