当前位置: 首页>>代码示例>>C++>>正文


C++ boost::wformat方法代码示例

本文整理汇总了C++中boost::wformat方法的典型用法代码示例。如果您正苦于以下问题:C++ boost::wformat方法的具体用法?C++ boost::wformat怎么用?C++ boost::wformat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boost的用法示例。


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

示例1: main

int main(int, char* [])
{
  using boost::format;
  using boost::str;

#if !defined(BOOST_NO_STD_WSTRING) && !defined(BOOST_NO_STD_WSTREAMBUF)
  using boost::wformat;
  wformat wfmter(L"%%##%%##%%1 %1%00");
  if(str( wfmter % L"Escaped OK" ) != L"%##%##%1 Escaped OK00")
      BOOST_ERROR("Basic w-parsing Failed");
  if(str( wformat(L"%%##%#x ##%%1 %s00") % 20 % L"Escaped OK" ) != L"%##0x14 ##%1 Escaped OK00")
      BOOST_ERROR("Basic wp-parsing Failed") ;

  // testcase for https://svn.boost.org/trac10/ticket/7379 (for valgrind)
  wformat wfmt(L"%1$.1f");
  std::wstring ws = str(wfmt % 123.45f);
  BOOST_TEST_EQ(ws.compare(L"123.4"), 0);
  wformat wfmt2(L"%1$.0f %%");
  std::wstring ws2 = (wfmt2 % 123.45f).str();
  BOOST_TEST_EQ(ws2.compare(L"123 %"), 0);

#endif // wformat tests

  return boost::report_errors();
}
开发者ID:LocutusOfBorg,项目名称:poedit,代码行数:25,代码来源:format_test_wstring.cpp

示例2: test_main

int test_main(int, char* [])
{

  using boost::format;
  using boost::io::str;

#if !defined(BOOST_NO_STD_WSTRING) && !defined(BOOST_NO_STD_WSTREAMBUF)
  using boost::wformat;
  if(str( wformat(L"%%##%%##%%1 %1%00") % L"Escaped OK" ) != L"%##%##%1 Escaped OK00")
      BOOST_ERROR("Basic w-parsing Failed");
  if(str( wformat(L"%%##%#x ##%%1 %s00") % 20 % L"Escaped OK" ) != L"%##0x14 ##%1 Escaped OK00")
      BOOST_ERROR("Basic wp-parsing Failed") ;
#endif // wformat tests


  return 0;
}
开发者ID:Karlan88,项目名称:xray,代码行数:17,代码来源:format_test_wstring.cpp

示例3: getFPS

void FPSCounter::drawText(int baseX, int baseY)
{
	int fps = getFPS();
	int primitive = getPrimitive();
	int primitiveAverage = getPrimitiveAverage();
	int primitiveTotal = getPrimitiveTotal();

	video::SColor white(255, 255, 255, 255);
	
	using boost::wformat;
	auto fpsMsg = (wformat(L"FPS : %d") % fps).str();
	auto primitiveMsg = (wformat(L"Primitive : %d") % primitive).str();
	auto primitiveAvgMsg = (wformat(L"PrimitiveAvg : %d") % primitiveAverage).str();
	auto primitiveTotalMsg = (wformat(L"PrimitiveTotal : %d") % primitiveTotal).str();

	const int lineHeight = DebugDrawManager::kFont14Height;
	g_debugDrawMgr->addString(core::vector2di(baseX, baseY + lineHeight * 0), fpsMsg, white);
	g_debugDrawMgr->addString(core::vector2di(baseX, baseY + lineHeight * 1), primitiveMsg, white);
	g_debugDrawMgr->addString(core::vector2di(baseX, baseY + lineHeight * 2), primitiveAvgMsg, white);
	g_debugDrawMgr->addString(core::vector2di(baseX, baseY + lineHeight * 3), primitiveTotalMsg, white);
}
开发者ID:Perlmint,项目名称:dokuro,代码行数:21,代码来源:fps_counter.cpp

示例4: Serialization

void boost_example::Serialization()
{
	wprintf(L"*** Boost Serialization Example - Start\n");

	wprintf(L"Building property tree\n");

	wptree property_tree;
	property_tree.add<int>(L"Property_01", 1);
	property_tree.add<int>(L"Property_02", 2);
	property_tree.add<int>(L"Property_03", 3);
	property_tree.add<int>(L"Property_04", 4);
	property_tree.add<int>(L"Property_05", 5);
	property_tree.add<int>(L"Node1.Node2.Node3.Property_06", 6);

	wprintf(L"Saving to a file\n");

	path file_path(current_path().c_str());
	file_path /= L"JsonTest.txt";
	wprintf((wformat(L"File Path: %s\n") % file_path.generic_wstring()).str().c_str());

	std::wofstream file(file_path.generic_string().c_str());
	if (!file.is_open())
	{
		wprintf(L"Could not create the file\n");
		return;
	}

	try
	{
		write_json(file, property_tree);
	}
	catch (json_parser_error)
	{
		wprintf(L"Could not write Json to the file\n");
	}

	file.close();

	wprintf(L"Loading from the file\n");
	wprintf((wformat(L"File Path: %s\n") % file_path.generic_wstring()).str().c_str());

	std::wifstream read_file(file_path.generic_string().c_str());
	if (!read_file.is_open())
	{
		wprintf(L"Could not load the file\n");
		return;
	}

	std::wstringstream temp_stream;
	temp_stream << read_file.rdbuf();
	wprintf(L"Json file content:\n");
	wprintf(temp_stream.str().c_str());
	wprintf(L"\n");

	wptree read_property_tree;
	try
	{
		read_property_tree.clear();
		read_json(temp_stream, read_property_tree);
	}
	catch (json_parser_error)
	{
		wprintf(L"Could not read Json to the file\n");
		return;
	}

	wprintf(L"Read property tree content:\n");
	wprintf((wformat(L"\t Property_01 = %d\n") % read_property_tree.get<int>(L"Property_01", 0)).str().c_str());
	wprintf((wformat(L"\t Property_02 = %d\n") % read_property_tree.get<int>(L"Property_02", 0)).str().c_str());
	wprintf((wformat(L"\t Property_03 = %d\n") % read_property_tree.get<int>(L"Property_03", 0)).str().c_str());
	wprintf((wformat(L"\t Property_04 = %d\n") % read_property_tree.get<int>(L"Property_04", 0)).str().c_str());
	wprintf((wformat(L"\t Property_05 = %d\n") % read_property_tree.get<int>(L"Property_05", 0)).str().c_str());
	wprintf((wformat(L"\t Property_06 = %d\n") % read_property_tree.get<int>(L"Node1.Node2.Node3.Property_06", 0)).str().c_str());

	wprintf(L"*** Boost Serialization Example - End\n\n");
}
开发者ID:RogerioDosSantos,项目名称:Samples,代码行数:76,代码来源:serialization.cpp

示例5: update

void HeadFreeCameraEventReceiver::update(int ms)
{
	auto cam = this->getCamera();

	MoveEvent moveEvt = getMoveEvent();
	LookEvent lookEvt = getLookEvent();

	horizontalRotate_ += lookEvt.horizontalRotation * rotateSpeed * ms;
	if(horizontalRotate_ > 180.0f) {
		horizontalRotate_ -= 360.0f;
	} else if(horizontalRotate_ < -180.0f) {
		horizontalRotate_ += 360.0f;
	}

	verticalRotate_ += lookEvt.verticalRotation * rotateSpeed * ms;
	const float maxVerticalRotation = 80.0f;
	if(verticalRotate_ < -maxVerticalRotation) {
		verticalRotate_ = -maxVerticalRotation;
	} else if(verticalRotate_ > maxVerticalRotation) {
		verticalRotate_ = maxVerticalRotation;
	}

	//그냥 생각없이 카메라를 돌리자. 오큘러스 대응은 렌더리쪽에서 알아서 처리될거다
	cam->setRotation(core::vector3df(verticalRotate_, horizontalRotate_, 0));
	
	//카메라 처다보는 방향으로 로직을 구현하면 오큘러스에서 설정한 값하고 꼬인다
	//v/h 값으로 따로 계산해야될듯
	core::vector3df pos = cam->getPosition();
	core::vector3df up(0, 1, 0);
	float targetX = -cos(core::degToRad(verticalRotate_)) * sin(core::degToRad(horizontalRotate_));
	float targetY = sin(core::degToRad(verticalRotate_));
	float targetZ = -cos(core::degToRad(verticalRotate_)) * cos(core::degToRad(horizontalRotate_));
	core::vector3df target(targetX, targetY, targetZ);
	irr::core::vector3df side = up.crossProduct(target);
	up = target.crossProduct(side);
	cam->setUpVector(up);

	const float moveFactor = moveSpeed * ms;
	auto moveDelta = moveFactor * moveEvt.forwardBackward * target;
	auto sideDelta = moveFactor * moveEvt.leftRight * side;
	auto nextPos = pos + moveDelta + sideDelta;
	cam->setPosition(nextPos);

	bool displayInfo = false;
	if(displayInfo) {
		irr::video::SColor white(255, 255, 255, 255);
		auto rotateMsg = (wformat(L"rotate : h=%.2f, v=%.2f") % horizontalRotate_ % verticalRotate_).str();
		g_debugDrawMgr->addString(core::vector2di(0, 100), rotateMsg, white);

		auto evtMsg = (wformat(L"evt : fb=%.2f, lr=%.2f") % moveEvt.forwardBackward % moveEvt.leftRight).str();
		g_debugDrawMgr->addString(core::vector2di(0, 100 + 14*1), evtMsg, white);

		auto targetMsg = (wformat(L"target : %.2f, %.2f, %.2f") % targetX % targetY % targetZ).str();
		g_debugDrawMgr->addString(core::vector2di(0, 100 + 14*2), targetMsg, white);

		auto sideMsg = (wformat(L"side : %.2f, %.2f, %.2f") % side.X % side.Y % side.Z).str();
		g_debugDrawMgr->addString(core::vector2di(0, 100 + 14*3), sideMsg, white);

		auto camPos = cam->getPosition();
		auto camPosMsg = (wformat(L"CamPos : %.2f, %.2f, %.2f") % camPos.X % camPos.Y % camPos.Z).str();
		g_debugDrawMgr->addString(core::vector2di(0, 100 + 14*4), camPosMsg, white);

		auto upVecMsg = (wformat(L"UpVec : %.2f, %.2f, %.2f") % up.X % up.Y % up.Z).str();
		g_debugDrawMgr->addString(core::vector2di(0, 100 + 14*5), upVecMsg, white);

	}
}
开发者ID:shipduck,项目名称:cham-cham-cham,代码行数:67,代码来源:hmd_camera.cpp


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