本文整理汇总了C++中PropertyBase::Type方法的典型用法代码示例。如果您正苦于以下问题:C++ PropertyBase::Type方法的具体用法?C++ PropertyBase::Type怎么用?C++ PropertyBase::Type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertyBase
的用法示例。
在下文中一共展示了PropertyBase::Type方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MarshalToBuffer
/* static */
int Message::MarshalToBuffer(Message * msg, pGina::Memory::Buffer * buffer)
{
pGina::Memory::BinaryWriter writer(buffer);
writer.Write((unsigned char) CURRENT_MESSAGE_FORMAT_VERSION);
PropertyMap& properties = msg->Properties();
for(Message::PropertyMap::iterator itr = properties.begin(); itr != properties.end(); ++itr)
{
// Property name
writer.Write(itr->first);
PropertyBase * propBase = itr->second;
// Special case, if its a string, and its empty, we want to write
// nothing for value
if(propBase->Type() == String)
{
pGina::Messaging::Property<std::wstring> * prop = static_cast<pGina::Messaging::Property<std::wstring> *>(propBase);
if(prop->Value().empty())
propBase->Type(EmptyString);
}
// Property type
writer.Write((unsigned char)propBase->Type());
// now work out type/value
switch(propBase->Type())
{
case Boolean:
{
pGina::Messaging::Property<bool> * prop = static_cast<pGina::Messaging::Property<bool> *>(propBase);
writer.Write(prop->Value());
}
break;
case Byte:
{
pGina::Messaging::Property<unsigned char> * prop = static_cast<pGina::Messaging::Property<unsigned char> *>(propBase);
writer.Write(prop->Value());
}
break;
case EmptyString:
// Do nothing, no value here
break;
case Integer:
{
pGina::Messaging::Property<int> * prop = static_cast<pGina::Messaging::Property<int> *>(propBase);
writer.Write(prop->Value());
}
break;
case String:
{
pGina::Messaging::Property<std::wstring> * prop = static_cast<pGina::Messaging::Property<std::wstring> *>(propBase);
writer.Write(prop->Value());
}
break;
}
}
return writer.BytesWritten();
}