本文整理汇总了C++中raknet::RakString::Allocate方法的典型用法代码示例。如果您正苦于以下问题:C++ RakString::Allocate方法的具体用法?C++ RakString::Allocate怎么用?C++ RakString::Allocate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类raknet::RakString
的用法示例。
在下文中一共展示了RakString::Allocate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SplitURI
void RakString::SplitURI(RakNet::RakString &header, RakNet::RakString &domain, RakNet::RakString &path)
{
header.Clear();
domain.Clear();
path.Clear();
size_t strLen = strlen(sharedString->c_str);
char c;
unsigned int i=0;
if (strncmp(sharedString->c_str, "http://", 7)==0)
i+=(unsigned int) strlen("http://");
else if (strncmp(sharedString->c_str, "https://", 8)==0)
i+=(unsigned int) strlen("https://");
if (strncmp(sharedString->c_str, "www.", 4)==0)
i+=(unsigned int) strlen("www.");
if (i!=0)
{
header.Allocate(i+1);
strncpy(header.sharedString->c_str, sharedString->c_str, i);
header.sharedString->c_str[i]=0;
}
domain.Allocate(strLen-i+1);
char *domainOutput=domain.sharedString->c_str;
unsigned int outputIndex=0;
for (; i < strLen; i++)
{
c=sharedString->c_str[i];
if (c=='/')
{
break;
}
else
{
domainOutput[outputIndex++]=sharedString->c_str[i];
}
}
domainOutput[outputIndex]=0;
path.Allocate(strLen-header.GetLength()-outputIndex+1);
outputIndex=0;
char *pathOutput=path.sharedString->c_str;
for (; i < strLen; i++)
{
pathOutput[outputIndex++]=sharedString->c_str[i];
}
pathOutput[outputIndex]=0;
}