本文整理汇总了C++中DataDesc::LengthIsSize方法的典型用法代码示例。如果您正苦于以下问题:C++ DataDesc::LengthIsSize方法的具体用法?C++ DataDesc::LengthIsSize怎么用?C++ DataDesc::LengthIsSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataDesc
的用法示例。
在下文中一共展示了DataDesc::LengthIsSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetLength
UPInt String::GetLength() const
{
// Optimize length accesses for non-UTF8 character strings.
DataDesc* pdata = GetData();
UPInt length, size = pdata->GetSize();
if (pdata->LengthIsSize())
return size;
length = (UPInt)UTF8Util::GetLength(pdata->Data, (UPInt)size);
if (length == size)
pdata->Size |= String_LengthIsSize;
return length;
}
示例2: String
String String::Substring(UPInt start, UPInt end) const
{
UPInt length = GetLength();
if ((start >= length) || (start >= end))
return String();
DataDesc* pdata = GetData();
// If size matches, we know the exact index range.
if (pdata->LengthIsSize())
return String(pdata->Data + start, end - start);
// Get position of starting character.
SPInt byteStart = UTF8Util::GetByteIndex(start, pdata->Data, pdata->GetSize());
SPInt byteSize = UTF8Util::GetByteIndex(end - start, pdata->Data + byteStart, pdata->GetSize()-byteStart);
return String(pdata->Data + byteStart, (UPInt)byteSize);
}
示例3: GetCharAt
UInt32 String::GetCharAt(UPInt index) const
{
SPInt i = (SPInt) index;
DataDesc* pdata = GetData();
const char* buf = pdata->Data;
UInt32 c;
if (pdata->LengthIsSize())
{
OVR_ASSERT(index < pdata->GetSize());
buf += i;
return UTF8Util::DecodeNextChar_Advance0(&buf);
}
c = UTF8Util::GetCharAt(index, buf, pdata->GetSize());
return c;
}
示例4: GetData
String& String::Insert(const char* substr, UPInt posAt, SPInt strSize)
{
DataDesc* poldData = GetData();
UPInt oldSize = poldData->GetSize();
UPInt insertSize = (strSize < 0) ? OVR_strlen(substr) : (UPInt)strSize;
UPInt byteIndex = (poldData->LengthIsSize()) ?
posAt : (UPInt)UTF8Util::GetByteIndex(posAt, poldData->Data, oldSize);
OVR_ASSERT(byteIndex <= oldSize);
DataDesc* pnewData = AllocDataCopy2(oldSize + insertSize, 0,
poldData->Data, byteIndex, substr, insertSize);
memcpy(pnewData->Data + byteIndex + insertSize,
poldData->Data + byteIndex, oldSize - byteIndex);
SetData(pnewData);
poldData->Release();
return *this;
}