Example #1
0
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;

}
Example #2
0
bool File::WriteAllText(StringRef filePath, StringRef str)
{
	FileStream writer(filePath, FileOpenMode::DestoryWriteOrCreate, FileDataType::Text);
	if (writer.IsOpen())
	{
		return writer.WriteString(str,false) == str.Length();
	}
	return false;
}
Example #3
0
bool StringParser::StringTo(const StringRef& inString, int base /*= 10*/)
{
	if (inString.Length() != 4)
	{
		return false;
	}

	return inString.Compare("TRUE", true) == 0;
}
Example #4
0
bool IPAddress::IsPort(StringRef inValue)
{
	//Port format:<d*>
	RETURN_FALSE_IF_EMPTY(inValue);

	size_t length = inValue.Length();
	for (size_t i = 0; i < length; i++)
	{
		if (!isdigit(inValue[i]))
		{
			return false;
		}
	}
	return true;
}
Example #5
0
void NetworkBuffer::Write(const StringRef& val)
{
	return Write((byte*)val.c_str(), val.Length());
}
Example #6
0
WHeapString StringParser::ToW(const StringRef& str)
{
	WHeapString tempBuffer;
	ConvertToBuffer(str.c_str(), str.Length(), tempBuffer);
	return tempBuffer;
}
Example #7
0
intp StringParser::ConvertToBuffer(const StringRef& inBuffer, WHeapString& outBuffer)
{
	return ConvertToBuffer(inBuffer.Buffer(), inBuffer.Length(), outBuffer);
}
Example #8
0
//------------------------------------------------------------
VIREO_EXPORT Int32 Data_GetStringLength(StringRef stringObject)
{
    VIREO_ASSERT(String::ValidateHandle(stringObject));
    return stringObject->Length();
}