本文整理汇总了C++中StringRef::SubString方法的典型用法代码示例。如果您正苦于以下问题:C++ StringRef::SubString方法的具体用法?C++ StringRef::SubString怎么用?C++ StringRef::SubString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringRef
的用法示例。
在下文中一共展示了StringRef::SubString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadToken
StringRef SirenTextParser::ReadToken(StringRef& refProto)
{
refProto = refProto.TrimBegin();
if (refProto.IsEmpty())
{
return StringRef::Empty;
}
if (StdString::IsDigit(refProto[0]))
{
Log::FormatError("Token cannot begin with number:{}", refProto[0]);
return StringRef::Empty;
}
size_t tokenLength = 0;
size_t length = refProto.Length();
for (size_t i = 0; i < length - 1; ++i)
{
int c = refProto[i];
if (StdString::IsToken(c))
{
++tokenLength;
}
else
{
break;
}
}
StringRef token = refProto.SubString(0, tokenLength);
refProto = refProto.SubString(tokenLength);
return token;
}
示例2: ReadAttribute
StringRef SirenTextParser::ReadAttribute(StringRef& refProto)
{
refProto = refProto.TrimBegin();
intp index = refProto.IndexOf(']');
if (index < 0)
{
Log::Error("Cannot find ] on attribute");
return false;
}
StringRef result = refProto.SubString(0, index);
refProto = refProto.SubString(index + 1);
return result;
}
示例3: GetExtension
StringRef FileInfo::GetExtension( StringRef file )
{
intp index= file.IndexOf('.');
if (index>0)
{
return file.SubString(index);
}
return StringRef::Empty;
}
示例4: ReadExpectedChar
bool SirenTextParser::ReadExpectedChar(StringRef& refProto, char val)
{
refProto = refProto.TrimBegin();
if (refProto.IsEmpty() || refProto[0] != val)
{
return false;
}
refProto = refProto.SubString(1);
return true;
}
示例5: ReadFunctionArguments
bool SirenTextParser::ReadFunctionArguments(StringRef& refProto, List<StringRef>& outArguments)
{
//read arguments
intp endIndex = refProto.IndexOf(')');
if (endIndex < 0)
{
Log::Error("Invalid function.Lost ')' ");
return false;
}
StringRef args = refProto.SubString(1, endIndex - 1);
bool isSuccess = StringParser::Split(args, ",", outArguments, false);
if (!isSuccess)
{
Log::FormatError("Invalid function argument:{}", args);
return false;
}
refProto = refProto.SubString(endIndex);
return EndBlock(refProto);
}
示例6: Parse
bool ISirenFunction::Parse(SirenAssembly& assembly, StringRef& refProto)
{
//read arguments
intp endIndex = refProto.IndexOf(')');
if (endIndex < 0)
{
Log::Error("Invalid function.Lost ')' ");
return false;
}
StringRef args = refProto.SubString(1, endIndex - 1);
bool isSuccess = StringParser::Split(args, ",", mArguments, false);
if (!isSuccess)
{
Log::FormatError("Invalid function argument:{}", args);
return false;
}
refProto = refProto.SubString(endIndex);
return SirenTextParser::EndBlock(refProto);
}
示例7: ReadNextPrintChar
char SirenTextParser::ReadNextPrintChar(StringRef& refProto)
{
refProto = refProto.TrimBegin();
if (refProto.IsEmpty())
{
return '\0';
}
char c = refProto[0];
refProto = refProto.SubString(1);
return c;
}
示例8: EndType
bool SirenTextParser::EndType(StringRef& refProto)
{
refProto = refProto.TrimBegin();
intp index = refProto.IndexOf('}');
if (index < 0)
{
Log::Error("Cannot find }");
return false;
}
refProto = refProto.SubString(index + 1);
return EndBlock(refProto);;
}
示例9: CheckFileType
FileType FileInfo::CheckFileType( StringRef fileExt )
{
if (fileExt.IsNullOrEmpty())
{
return FileType::Unknown;
}
fileExt=fileExt.SubString(1); //remove '.' at head
FileType* fileType= mFileExtDict.TryGetValue(fileExt);
if (fileType!=NULL)
{
return *fileType;
}
return FileType::Unknown;
}