• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ defaultBuilder函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中defaultBuilder函数的典型用法代码示例。如果您正苦于以下问题:C++ defaultBuilder函数的具体用法?C++ defaultBuilder怎么用?C++ defaultBuilder使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了defaultBuilder函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: memset

	void LLTemplateMessageBuilderTestObject::test<20>()
		// block build order !-> binary order
	{
		U8 buffer1[MAX_BUFFER_SIZE];
		memset(buffer1, 0, MAX_BUFFER_SIZE);
		U8 buffer2[MAX_BUFFER_SIZE];
		memset(buffer2, 0, MAX_BUFFER_SIZE);
		U32 bufferSize1, bufferSize2;

		// build template: Test0 before Test1
		LLMessageTemplate messageTemplate = defaultTemplate();
		messageTemplate.addBlock(createBlock(const_cast<char*>(_PREHASH_Test0), MVT_U32, 4, MBT_SINGLE));
		messageTemplate.addBlock(createBlock(const_cast<char*>(_PREHASH_Test1), MVT_U32, 4, MBT_SINGLE));

		// build message: 1st declared block var == 0xaaaa, 2nd declared block var == 0xbbbb
		LLTemplateMessageBuilder* builder = defaultBuilder(messageTemplate, const_cast<char*>(_PREHASH_Test0));
		builder->addU32(_PREHASH_Test0, 0xaaaa);
		builder->nextBlock(_PREHASH_Test1);
		builder->addU32(_PREHASH_Test0, 0xbbbb);
		bufferSize1 = builder->buildMessage(buffer1, MAX_BUFFER_SIZE, 0);
		delete builder;

		// build message: 1st declared block var == 0xaaaa, 2nd declared block var == 0xbbbb
		builder = defaultBuilder(messageTemplate, const_cast<char*>(_PREHASH_Test1));
		builder->addU32(_PREHASH_Test0, 0xbbbb);
		builder->nextBlock(_PREHASH_Test0);
		builder->addU32(_PREHASH_Test0, 0xaaaa);
		bufferSize2 = builder->buildMessage(buffer2, MAX_BUFFER_SIZE, 0);
		delete builder;

		ensure_equals("Ensure Buffer Sizes Equal", bufferSize1, bufferSize2);
		ensure_equals("Ensure Buffer Contents Equal", memcmp(buffer1, buffer2, bufferSize1), 0);
	}
开发者ID:AlericInglewood,项目名称:SingularityViewer,代码行数:33,代码来源:lltemplatemessagebuilder_tut.cpp


示例2: defaultTemplate

	void LLTemplateMessageBuilderTestObject::test<44>()
		// read variable block past end of message -> 0 repeats
	{
		// build message with single block
		LLMessageTemplate messageTemplate = defaultTemplate();
		messageTemplate.addBlock(defaultBlock(MVT_U32, 4, MBT_SINGLE));
		U32 outValue, outValue2, inValue = 0xbbbbbbbb;
		LLTemplateMessageBuilder* builder = defaultBuilder(messageTemplate);
		builder->addU32(_PREHASH_Test0, inValue);
		const U32 bufferSize = 1024;
		U8 buffer[bufferSize];
		memset(buffer, 0xaa, bufferSize);
		memset(buffer, 0, LL_PACKET_ID_SIZE);
		U32 builtSize = builder->buildMessage(buffer, bufferSize, 0);
		delete builder;

		// add variable block to reader template
		messageTemplate.addBlock(createBlock(const_cast<char*>(_PREHASH_Test1), MVT_U32, 4));

		// read message value and check block repeat count
		numberMap[1] = &messageTemplate;
		LLTemplateMessageReader* reader = 
			new LLTemplateMessageReader(numberMap);
		reader->validateMessage(buffer, builtSize, LLHost());
		reader->readMessage(buffer, LLHost());
		reader->getU32(_PREHASH_Test0, _PREHASH_Test0, outValue);
		outValue2 = reader->getNumberOfBlocks(_PREHASH_Test1);
		ensure_equals("Ensure present value ", outValue, inValue);
		ensure_equals("Ensure 0 repeats ", outValue2, 0);
		delete reader;
	}
开发者ID:AlericInglewood,项目名称:SingularityViewer,代码行数:31,代码来源:lltemplatemessagebuilder_tut.cpp


示例3: defaultTemplate

	void LLTemplateMessageBuilderTestObject::test<43>()
		// read past end of message -> default values (forward compatibility)
	{
		// build message with single block
		LLMessageTemplate messageTemplate = defaultTemplate();
		messageTemplate.addBlock(defaultBlock(MVT_U32, 4, MBT_SINGLE));
		U32 outValue, outValue2, inValue = 0xbbbbbbbb;
		LLTemplateMessageBuilder* builder = defaultBuilder(messageTemplate);
		builder->addU32(_PREHASH_Test0, inValue);
		const U32 bufferSize = 1024;
		U8 buffer[bufferSize];
		memset(buffer, 0xaa, bufferSize);
		memset(buffer, 0, LL_PACKET_ID_SIZE);
		U32 builtSize = builder->buildMessage(buffer, bufferSize, 0);
		delete builder;

		// add block to reader template
		messageTemplate.addBlock(createBlock(_PREHASH_Test1, MVT_U32, 4, MBT_SINGLE));

		// read message value and default value
		numberMap[1] = &messageTemplate;
		LLTemplateMessageReader* reader = 
			new LLTemplateMessageReader(numberMap);
		reader->validateMessage(buffer, builtSize, LLHost());
		reader->readMessage(buffer, LLHost());
		reader->getU32(_PREHASH_Test0, _PREHASH_Test0, outValue);
		reader->getU32(_PREHASH_Test1, _PREHASH_Test0, outValue2);
		ensure_equals("Ensure present value ", outValue, inValue);
		ensure_equals("Ensure default value ", outValue2, 0);
		delete reader;
	}
开发者ID:AlexRa,项目名称:Kirstens-clone,代码行数:31,代码来源:lltemplatemessagebuilder_tut.cpp


示例4: defaultBuilder

	void LLSDMessageBuilderTestObject::test<5>()
		 // U16
	{
	  U16 outValue, inValue = 3;
	  LLSDMessageBuilder builder = defaultBuilder();
	  builder.addU16("var", inValue);
	  LLSDMessageReader reader = setReader(builder);
	  reader.getU16("block", "var", outValue);
	  ensure_equals("Ensure U16", inValue, outValue);
	}
开发者ID:AlexRa,项目名称:Kirstens-clone,代码行数:10,代码来源:llsdmessagebuilder_tut.cpp


示例5: LLVector3d

	void LLSDMessageBuilderTestObject::test<13>()
		 // Vector3d
	{
	  LLVector3d outValue, inValue = LLVector3d(1,2,3);
	  LLSDMessageBuilder builder = defaultBuilder();
	  builder.addVector3d("var", inValue);
	  LLSDMessageReader reader = setReader(builder);
	  reader.getVector3d("block", "var", outValue);
	  ensure_equals("Ensure Vector3d", inValue, outValue);
	}
开发者ID:AlexRa,项目名称:Kirstens-clone,代码行数:10,代码来源:llsdmessagebuilder_tut.cpp


示例6: LLQuaternion

	void LLSDMessageBuilderTestObject::test<14>()
		 // Quaternion
	{
	  LLQuaternion outValue, inValue = LLQuaternion(1,2,3,4);
	  LLSDMessageBuilder builder = defaultBuilder();
	  builder.addQuat("var", inValue);
	  LLSDMessageReader reader = setReader(builder);
	  reader.getQuat("block", "var", outValue);
	  ensure_equals("Ensure Quaternion", inValue, outValue);
	}
开发者ID:AlexRa,项目名称:Kirstens-clone,代码行数:10,代码来源:llsdmessagebuilder_tut.cpp



注:本文中的defaultBuilder函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ defaultConnection函数代码示例发布时间:2022-05-30
下一篇:
C++ defaultBlock函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap