本文整理汇总了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();
}
示例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;
}
示例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);
}
示例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");
}
示例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);
}
}