本文整理汇总了C++中DataPtr::size方法的典型用法代码示例。如果您正苦于以下问题:C++ DataPtr::size方法的具体用法?C++ DataPtr::size怎么用?C++ DataPtr::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataPtr
的用法示例。
在下文中一共展示了DataPtr::size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: index
BOOST_FIXTURE_TEST_CASE(manyReferenceTimesAndValidTimes, TimeHandlerFixture)
{
add("2011-05-29 00:00:00", "2011-05-29 00:00:00");
add("2011-05-30 00:00:00", "2011-05-29 00:00:00");
add("2011-05-30 00:00:00", "2011-05-30 00:00:00");
add("2011-05-31 00:00:00", "2011-05-30 00:00:00");
WdbIndex index(gridData());
TimeHandler timeHandler(index);
timeHandler.addToCdm(cdm);
GridData::Time referenceTime1 = boost::posix_time::time_from_string("2011-05-29 00:00:00");
const CDMVariable & refTimeVar = cdm.getVariable(TimeHandler::referenceTimeName);
BOOST_CHECK_EQUAL(referenceTime1, timeFromData(timeHandler.getData(refTimeVar, 0)));
const CDMVariable & timeVar = cdm.getVariable(TimeHandler::validTimeName);
DataPtr times = timeHandler.getData(timeVar, 0);
GridData::Time validTime1 = boost::posix_time::time_from_string("2011-05-29 00:00:00");
GridData::Time validTime2 = boost::posix_time::time_from_string("2011-05-30 00:00:00");
BOOST_REQUIRE_EQUAL(2, times->size());
BOOST_CHECK_EQUAL(validTime1, timeFromData(times, 0));
BOOST_CHECK_EQUAL(validTime2, timeFromData(times, 1));
}
示例2: getData
SearchCacheMemDataPtr DistSearchCacheAdapter::getData(long id) {
DataPtr dataPair = distCacheAdapterPtr->get(id);
if(dataPair.get() != NULL) {
if(dataPair->size() <= 0) {
MCE_WARN("DistSearchCacheAdapter::getDataWithCAS not in memcached userid = " << id);
SearchCacheMemDataPtr tmp = new SearchCacheMemData;
return tmp;
}
string dataStr(dataPair->begin(), dataPair->end());
SearchCacheMemDataPtr data = new SearchCacheMemData;
data->ParseFromString(dataStr);
return data;
} else {
SearchCacheMemDataPtr tmp = new SearchCacheMemData;
return tmp;
}
}
示例3: load
bool CWorldMobPrototype::load(const String& resourceName)
{
CLog::instance()->log(CLog::msgFlagResources,CLog::msgLvlInfo,"Loading mob prototype from '%s'.\n",resourceName.c_str());
DataPtr dPtr = CResourceManager::instance()->load(resourceName);
if( !dPtr )
{
CLog::instance()->log(CLog::msgLvlError,"Error loading mob prototype: resource not found.\n",resourceName.c_str());
return false;
}
TiXmlDocument doc;
std::stringstream buf;
buf.write(dPtr->data(),dPtr->size());
buf >> doc;
if (doc.Error())
{
CLog::instance()->log(CLog::msgFlagResources, CLog::msgLvlError, _("Error loading mob prototype: XML parser returned an error: %s\n"), doc.ErrorDesc());
return false;
}
TiXmlNode* root = doc.FirstChild();
while( root && root->Type() == TiXmlNode::DECLARATION )
root = root->NextSibling();
if( !root || root->Type() != TiXmlNode::ELEMENT || strcmp(root->ToElement()->Value(),"MobPrototype") )
{
CLog::instance()->log(CLog::msgFlagResources, CLog::msgLvlError, _("Error loading mob prototype: resource isn't mob prototype. %s\n"),root->Value());
return false;
};
TiXmlNode* option;
for( option = root->FirstChild(); option; option = option->NextSibling() )
if( !processOption(option) )
{
CLog::instance()->log(CLog::msgFlagResources, CLog::msgLvlError, _("Error loading mob prototype: error in file near '%s'.\n"),option->Value());
return false;
};
return true;
};
示例4:
DataPtrStreamWrapper(DataPtr &vec)
{
setg(vec->data(), vec->data(), vec->data() + vec->size());
}