Newer
Older
fMemoryManager->deallocate(fHost);//delete [] fHost;
fHost = XMLString::replicate(srcPtr, fMemoryManager);
// Update source pointer to the end
srcPtr += XMLString::stringLen(fHost);
}
}
}
else
//
// http protocol requires two forward slashes
// we didn't get them, so throw an exception
//
if (fProtocol == HTTP) {
ThrowXML
(
MalformedURLException
, XMLExcepts::URL_ExpectingTwoSlashes
);
}
}
//
// If there was a host part, then we have to grovel through it for
// all the bits and pieces it can hold.
//
if (fHost)
{
//
// Look for a '@' character, which indicates a user name. If we
// find one, then everything between the start of the host data
// and the character is the user name.
//
ptr1 = XMLString::findAny(fHost, listTwo);
if (ptr1)
{
// Get this info out as the user name
*ptr1 = 0;
fMemoryManager->deallocate(fUser);//delete [] fUser;
fUser = XMLString::replicate(fHost, fMemoryManager);
ptr1++;
// And now cut these chars from the host string
XMLString::cut(fHost, ptr1 - fHost);
// Is there a password inside the user string?
ptr2 = XMLString::findAny(fUser, listThree);
if (ptr2)
{
// Remove it from the user name string
*ptr2 = 0;
// And copy out the remainder to the password field
ptr2++;
fMemoryManager->deallocate(fPassword);//delete [] fPassword;
fPassword = XMLString::replicate(ptr2, fMemoryManager);
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
}
}
//
// Ok, so now we are at the actual host name, if any. If we are
// not at the end of the host data, then lets see if we have a
// port trailing the
//
ptr1 = XMLString::findAny(fHost, listThree);
if (ptr1)
{
// Remove it from the host name
*ptr1 = 0;
// Try to convert it to a numeric port value and store it
ptr1++;
if (!XMLString::textToBin(ptr1, fPortNum))
ThrowXML(MalformedURLException, XMLExcepts::URL_BadPortField);
}
// If the host ended up empty, then toss is
if (!*fHost)
{
delete[] fHost;
fHost = 0;
}
}
// If we are at the end, then we are done now
if (!*srcPtr)
{
return;
}
//
// Next is the path part. It can be absolute, i.e. starting with a
// forward slash character, or relative. Its basically everything up
// to the end of the string or to any trailing query or fragment.
//
ptr1 = XMLString::findAny(srcPtr, listFive);
if (!ptr1)
{
fMemoryManager->deallocate(fPath);//delete [] fPath;
fPath = XMLString::replicate(srcPtr, fMemoryManager);
return;
}
// Everything from where we are to what we found is the path
if (ptr1 > srcPtr)
{
fMemoryManager->deallocate(fPath);//delete [] fPath;
fPath = (XMLCh*) fMemoryManager->allocate
(
(ptr1 - srcPtr + 1) * sizeof(XMLCh)
);//new XMLCh[(ptr1 - srcPtr) + 1];
ptr2 = fPath;
while (srcPtr < ptr1)
*ptr2++ = *srcPtr++;
*ptr2 = 0;
}
//
// If we found a fragment, then it is the rest of the string and we
// are done.
//
if (*srcPtr == chPound)
{
srcPtr++;
fMemoryManager->deallocate(fFragment);//delete [] fFragment;
fFragment = XMLString::replicate(srcPtr, fMemoryManager);
return;
}
//
// The query is either the rest of the string, or up to the fragment
// separator.
//
srcPtr++;
ptr1 = XMLString::findAny(srcPtr, listSix);
fMemoryManager->deallocate(fQuery);//delete [] fQuery;
fQuery = XMLString::replicate(srcPtr, fMemoryManager);
fQuery = (XMLCh*) fMemoryManager->allocate
(
(ptr1 - srcPtr + 1) * sizeof(XMLCh)
);//new XMLCh[(ptr1 - srcPtr) + 1];
ptr2 = fQuery;
while (srcPtr < ptr1)
*ptr2++ = *srcPtr++;
*ptr2 = 0;
}
// If we are not at the end now, then everything else is the fragment
if (*srcPtr == chPound)
{
srcPtr++;
fMemoryManager->deallocate(fFragment);//delete [] fFragment;
fFragment = XMLString::replicate(srcPtr, fMemoryManager);