本文整理汇总了C++中SharedVariant::getStats方法的典型用法代码示例。如果您正苦于以下问题:C++ SharedVariant::getStats方法的具体用法?C++ SharedVariant::getStats怎么用?C++ SharedVariant::getStats使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharedVariant
的用法示例。
在下文中一共展示了SharedVariant::getStats方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getStats
void SharedVariant::getStats(SharedVariantStats *stats) const {
stats->initStats();
stats->variantCount = 1;
switch (m_type) {
case KindOfUninit:
case KindOfNull:
case KindOfBoolean:
case KindOfInt64:
case KindOfDouble:
case KindOfStaticString:
stats->dataSize = sizeof(m_data.dbl);
stats->dataTotalSize = sizeof(SharedVariant);
break;
case KindOfObject:
if (getIsObj()) {
SharedVariantStats childStats;
m_data.obj->getSizeStats(&childStats);
stats->addChildStats(&childStats);
break;
}
// fall through
case KindOfString:
stats->dataSize = m_data.str->size();
stats->dataTotalSize = sizeof(SharedVariant) + sizeof(StringData) +
stats->dataSize;
break;
default:
assert(is(KindOfArray));
if (getSerializedArray()) {
stats->dataSize = m_data.str->size();
stats->dataTotalSize = sizeof(SharedVariant) + sizeof(StringData) +
stats->dataSize;
break;
}
if (isPacked()) {
stats->dataTotalSize = sizeof(SharedVariant) +
sizeof(ImmutablePackedArray);
auto size = m_data.packed->size();
stats->dataTotalSize += sizeof(SharedVariant*) * size;
for (size_t i = 0; i < size; i++) {
SharedVariant *v = m_data.packed->vals()[i];
SharedVariantStats childStats;
v->getStats(&childStats);
stats->addChildStats(&childStats);
}
} else {
auto array = m_data.array;
stats->dataTotalSize = sizeof(SharedVariant) + array->getStructSize();
for (size_t i = 0, n = array->size(); i < n; i++) {
SharedVariantStats childStats;
array->getKeyIndex(i)->getStats(&childStats);
stats->addChildStats(&childStats);
array->getValIndex(i)->getStats(&childStats);
stats->addChildStats(&childStats);
}
}
break;
}
}
示例2: getStats
void SharedVariant::getStats(SharedVariantStats *stats) const {
stats->initStats();
stats->variantCount = 1;
switch (m_type) {
case KindOfUninit:
case KindOfNull:
case KindOfBoolean:
case KindOfInt64:
case KindOfDouble:
case KindOfStaticString:
stats->dataSize = sizeof(m_data.dbl);
stats->dataTotalSize = sizeof(SharedVariant);
break;
case KindOfObject:
if (getIsObj()) {
SharedVariantStats childStats;
m_data.obj->getSizeStats(&childStats);
stats->addChildStats(&childStats);
break;
}
// fall through
case KindOfString:
stats->dataSize = m_data.str->size();
stats->dataTotalSize = sizeof(SharedVariant) + sizeof(StringData) +
stats->dataSize;
break;
default:
assert(is(KindOfArray));
if (getSerializedArray()) {
stats->dataSize = m_data.str->size();
stats->dataTotalSize = sizeof(SharedVariant) + sizeof(StringData) +
stats->dataSize;
break;
}
if (getIsVector()) {
stats->dataTotalSize = sizeof(SharedVariant) + sizeof(VectorData);
stats->dataTotalSize += sizeof(SharedVariant*) * m_data.vec->m_size;
for (size_t i = 0; i < m_data.vec->m_size; i++) {
SharedVariant *v = m_data.vec->vals()[i];
SharedVariantStats childStats;
v->getStats(&childStats);
stats->addChildStats(&childStats);
}
} else {
ImmutableMap *map = m_data.map;
stats->dataTotalSize = sizeof(SharedVariant) + map->getStructSize();
for (int i = 0; i < map->size(); i++) {
SharedVariantStats childStats;
map->getKeyIndex(i)->getStats(&childStats);
stats->addChildStats(&childStats);
map->getValIndex(i)->getStats(&childStats);
stats->addChildStats(&childStats);
}
}
break;
}
}