本文整理匯總了C++中XString::Format方法的典型用法代碼示例。如果您正苦於以下問題:C++ XString::Format方法的具體用法?C++ XString::Format怎麽用?C++ XString::Format使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類XString
的用法示例。
在下文中一共展示了XString::Format方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: RetrieveStateTest
void GBLStorageManagerStateTestBB::RetrieveStateTest( CKContext *ctx )
{
XString outputStr;
XString data;
outputStr.Format( "Calling RetrieveState( %d, &<data>, %d, %d )", (int)testUserID, (int)testLAEID, componentID );
OutputTestText( ctx, outputStr );
StartTimeMeasure();
CGBLCOError res = pInterface->RetrieveState( testUserID, &data, testLAEID, componentID );
StopAndOutputTimeMeasure( ctx );
outputStr.Format( "RetrieveState result: %s", (const char*)res );
OutputTestText( ctx, outputStr );
if (res == CGBLCOError::EGBLCOErrorType::GBLCO_OK)
{
outputStr.Format( "State data retrieved: %s", data.Str() );
OutputTestText( ctx, outputStr );
if( testData == data )
OutputTestText( ctx, XString("TEST PASSED") );
else
OutputTestText( ctx, XString("Retrieved data doesn't match saved data\r\nTEST FAILED") );
}
else
OutputTestText( ctx, XString("TEST FAILED") );
}
示例2: RunUnitTests
void CGBLStorageManagerTestBBBase::RunUnitTests( CKContext *ctx, TestCase *testCases, int numTests, XString &testRunTitle )
{
XString outputString;
// Initialise the test run timer
totalExecutionTime = 0;
// Generate the current time
time_t seconds;
seconds = time (NULL);
struct tm * timeinfo;
timeinfo = localtime ( &seconds );
// Output a formatted intro to the test run
outputString = "############################################################################\r\n";
outputString << testRunTitle << "\r\n";
outputString << asctime (timeinfo) << "\r\n";
outputString << "############################################################################\r\n";
OutputTestText( ctx, outputString );
// Iterate over each test and execute it...
for( int i = 0; i < numTests; i++ )
{
XString testIntroText;
// First, write some intro text to the output
OutputTestText( ctx, XString("----------------------------------------------------------------------------") );
testIntroText.Format( "Test number %d\r\nExecuting unit test '%s'...", i+1, testCases[i].testName );
OutputTestText( ctx, testIntroText );
OutputTestText( ctx, XString("----------------------------------------------------------------------------\r\n") );
// Now execute the actual test case
testCases[i].testFunction( ctx );
// Now append some end of test text
testIntroText.Format( "End of test number %d", i+1 );
OutputTestText( ctx, testIntroText );
OutputTestText( ctx, XString("----------------------------------------------------------------------------\r\n") );
}
outputString = "";
outputString << "############################################################################\r\n";
outputString << "Total execution time = " << totalExecutionTime << " seconds\r\n";
outputString << "############################################################################\r\n";
outputString << "######################## END OF TEST ###########################";
OutputTestText( ctx, outputString );
}
示例3: _checkObjectsByAttribute
void PhysicManager::_checkObjectsByAttribute(CKScene *newScene)
{
CKAttributeManager* attman = m_Context->GetAttributeManager();
int sizeJFuncMap = ATT_FUNC_TABLE_SIZE;//(sizeof(*getRegistrationTable()) / sizeof((getRegistrationTable())[0]));
for (int fIndex = 0 ; fIndex < sizeJFuncMap ; fIndex ++)
{
std::vector<int>attributeIdList;
pFactory::Instance()->findAttributeIdentifiersByGuid(getRegistrationTable()[fIndex].guid,attributeIdList);
int attCount = attributeIdList.size();
for (int i = 0 ; i < attCount ; i++ )
{
int currentAttType = attributeIdList.at(i);
const XObjectPointerArray& Array = attman->GetAttributeListPtr( attributeIdList.at(i) );
for (CKObject** it = Array.Begin(); it != Array.End(); ++it)
{
CK3dEntity *target = static_cast<CK3dEntity*>(*it);
if (target)
{
XString error;
error.Format("Registering :%s with %s",target->GetName(),attman->GetAttributeNameByType(currentAttType));
//if(!strcmp( target->GetName(),"smutan3-3" ) ) { // xLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,"problem case" ); }
// CKScene *levelScene = GetContext()->GetCurrentLevel()->GetCurrentScene();
// we check as no scene is current in use
if ( (
GetContext()->GetCurrentLevel()->GetLevelScene() == newScene &&
!isSceneObject2(target)
)
||
( newScene && newScene->IsObjectHere(target) && newScene !=GetContext()->GetCurrentLevel()->GetLevelScene() )
||
(
newScene &&
GetContext()->GetCurrentLevel()->GetCurrentScene() &&
GetContext()->GetCurrentLevel()->GetCurrentScene() == newScene &&
newScene !=GetContext()->GetCurrentLevel()->GetLevelScene() &&
newScene->IsObjectHere(target)
)
||
(
(physicFlags & PMF_DONT_DELETE_SCENES)
)
)
{
xLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,error.CStr() );
(*getRegistrationTable()[fIndex].rFunc)(target,currentAttType,true,false);
GetPMan()->getCheckList().PushBack(target->GetID());
}
}
}
}
}
}
示例4: StoreExistingStateTest
void GBLStorageManagerStateTestBB::StoreExistingStateTest( CKContext *ctx )
{
XString outputStr;
testData = "StoreExistingStateTest test state data - updated after initial storage";
outputStr.Format( "Calling StoreState( %d, %s, %d, %d )", (int)testUserID, testData.Str(), (int)testLAEID, componentID );
OutputTestText( ctx, outputStr );
StartTimeMeasure();
CGBLCOError res = pInterface->StoreState( testUserID, testData, testLAEID, componentID );
StopAndOutputTimeMeasure( ctx );
outputStr.Format( "StoreState result: %s", (const char*)res );
OutputTestText( ctx, outputStr );
if (res == CGBLCOError::EGBLCOErrorType::GBLCO_OK)
{
OutputTestText( ctx, XString("TEST PASSED") );
}
else
OutputTestText( ctx, XString("TEST FAILED") );
}
示例5: RetrieveStateTestInvalidParameters
void GBLStorageManagerStateTestBB::RetrieveStateTestInvalidParameters( CKContext *ctx )
{
XString outputStr;
XString data;
CGBLUserID invalidUser;
outputStr.Format( "Calling RetrieveState( %d, &<data>, %d, %d )", (int)invalidUser, (int)testLAEID, componentID );
OutputTestText( ctx, outputStr );
StartTimeMeasure();
CGBLCOError res = pInterface->RetrieveState( invalidUser, &data, testLAEID, componentID );
StopAndOutputTimeMeasure( ctx );
outputStr.Format( "RetrieveState result: %s", (const char*)res );
OutputTestText( ctx, outputStr );
if( res == CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL && (int)res == GBLSM_ERROR_GENERAL_INCORRECT_PARAM )
{
OutputTestText( ctx, XString("TEST PASSED") );
}
else
OutputTestText( ctx, XString("TEST FAILED") );
}
示例6: bodyDefaultFunctionMerged
void bodyDefaultFunctionMerged(CKParameter*in)
{
CKStructHelper sHelper(in);
//if ( ==0 ) //happens when dev is being opened and loads a cmo with physic objects.
XString msg;
msg.Format("parameter members : %d",sHelper.GetMemberCount());
if(bodyCreateFuncOld!=0 )
{
bodyCreateFuncOld(in);
xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,msg.Str());
}
return;
// CKParameter
//CKAttributeManager::SetAttributeDefaultValue()
}
示例7: GetPMan
pRigidBody*pFactory::cloneRigidBody(CK3dEntity *src,CK3dEntity *dst,CKDependencies *deps,int copyFlags,int bodyFlags/* =0 */)
{
//src->Rest
pRigidBody *result = GetPMan()->getBody(dst);
pRigidBody *srcBody = GetPMan()->getBody(src);
CK3dEntity *referenceObject = dst;
XString errMsg;
pObjectDescr oDescr;
//----------------------------------------------------------------
//
// sanity checks
//
#ifdef _DEBUG
assert(src);
assert(dst);
#endif // _DEBUG
if (!(copyFlags & PB_CF_PHYSICS))
{
errMsg.Format("Nothing to copy, aborting");
xLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,errMsg.Str());
return NULL;
}
//iAssertW(!result,"","Object :%s already physicalized");
//----------------------------------------------------------------
//
// fill object description
//
if (!result && IParameter::Instance()->copyTo(oDescr,src,copyFlags))
{
pWorld *world = GetPMan()->getWorld(oDescr.worlReference) ? GetPMan()->getWorld(oDescr.worlReference) : GetPMan()->getDefaultWorld();
if(world)
{
if ( (copyFlags && PB_CF_OVRRIDE_BODY_FLAGS) )
oDescr.flags = (BodyFlags)bodyFlags;
//now create the final rigid body :
result = pFactory::Instance()->createRigidBody(dst,oDescr);
}
}
if (!result){
xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,"cloning failed");
return NULL;
}
//----------------------------------------------------------------
//
// clone joints
//
if ( (copyFlags & PB_CF_JOINTS) )
{
pFactory::cloneJoints(src,dst,copyFlags);
}
//----------------------------------------------------------------
//
// copy velocities
//
if ( (copyFlags & PB_CF_VELOCITIES) )
{
NxActor *actorSrc = srcBody->getActor();
NxActor *actorDst = result->getActor();
actorDst->setLinearVelocity( actorSrc->getLinearVelocity() );
actorDst->setAngularVelocity( actorSrc->getAngularVelocity() );
}
//----------------------------------------------------------------
//
// copy forces
//
if ( (copyFlags & PB_CF_FORCE) )
{
NxActor *actorSrc = srcBody->getActor();
NxActor *actorDst = result->getActor();
actorDst->setLinearMomentum( actorSrc->getLinearMomentum() );
actorDst->setAngularMomentum( actorSrc->getAngularMomentum() );
}
//----------------------------------------------------------------
//
// copy sub shapes if :
//
// "Copy Children In Dependencies" &&
// ( copyFlags::OverrideBodyFlags & hierarchy && newBodyFlags & hierarchy ) ||
// ( oldBodyFlags & hierarchy )
if ( ((*deps->At(CKCID_3DENTITY)) & CK_DEPENDENCIES_COPY_3DENTITY_CHILDREN) &&
( (( copyFlags & PB_CF_OVRRIDE_BODY_FLAGS ) && (bodyFlags & BF_Hierarchy)) ||
( oDescr.flags & BF_Hierarchy) )
)
{
int dCount = dst->GetChildrenCount();
CK3dEntity* subEntity = NULL;
//.........這裏部分代碼省略.........
示例8: PBPhysicalizeEx
//************************************
// Method: PBPhysicalizeEx
// FullName: PBPhysicalizeEx
// Access: public
// Returns: int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int PBPhysicalizeEx(const CKBehaviorContext& behcontext)
{
using namespace vtTools::BehaviorTools;
using namespace vtTools;
using namespace vtTools::AttributeTools;
using namespace vtTools::ParameterTools;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
//
// objects
//
CKBehavior* beh = behcontext.Behavior;
CKContext* ctx = behcontext.Context;
PhysicManager *pm = GetPMan();
pFactory *pf = pFactory::Instance();
//the object :
CK3dEntity *target = (CK3dEntity *) beh->GetTarget();
if( !target ) bbErrorME("No Reference Object specified");
//the world reference, optional used
CK3dEntity*worldRef = NULL;
//the world object, only used when reference has been specified
pWorld *world = NULL;
//final object description
pObjectDescr *oDesc = new pObjectDescr();
pRigidBody *body = NULL;
XString errMesg;
//----------------------------------------------------------------
//
// sanity checks
//
// rigid body
GetPMan()->getBody(target);
if( body){
errMesg.Format("Object %s already registered.",target->GetName());
bbErrorME(errMesg.Str());
}
//----------------------------------------------------------------
//
//
//
if (!GetPMan()->isValid())
GetPMan()->performInitialization();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
//
// Collecting data. Stores all settings in a pObjectDescr.
//
//get the parameter array
BB_DECLARE_PIMAP;
//----------------------------------------------------------------
//
// generic settings
//
oDesc->hullType = (HullType)GetInputParameterValue<int>(beh,bbI_HullType);
oDesc->flags = (BodyFlags)GetInputParameterValue<int>(beh,bbI_Flags);
oDesc->density = GetInputParameterValue<float>(beh,bbI_Density);
//----------------------------------------------------------------
// optional
// world
//
BBSParameterM(bbI_World,BB_SSTART);
if (sbbI_World)
{
worldRef = (CK3dEntity *) beh->GetInputParameterObject(BB_IP_INDEX(bbI_World));
if (worldRef)
{
world = GetPMan()->getWorld(worldRef,target);
if (!world)
{
xLogger::xLog(ELOGERROR,E_LI_MANAGER,"World reference has been specified but no valid world object found. Switching to default world");
goto errorFound;
}
}
}
//----------------------------------------------------------------
//.........這裏部分代碼省略.........
示例9: GetPMan
pWheel *pFactory::createWheelSubShape(pRigidBody *body,CK3dEntity* subEntity,CKMesh *mesh,pObjectDescr *descr,VxVector localPos, VxQuaternion localRotation,NxShape*dstShape)
{
//################################################################
//
// Sanity checks
//
#ifdef _DEBUG
assert(body && subEntity && descr ); // Should never occur !
#endif // _DEBUG
XString errorStr;
//################################################################
//
// Retrieve the wheel setting from attribute
//
int attTypeWheelSettings = GetPMan()->att_wheelDescr;
int attTypeConvexCylinderSettings = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_CONVEX_CYLDINDER_WHEEL_DESCR);
if (!subEntity->HasAttribute(attTypeWheelSettings))
{
errorStr.Format("Object %s has been set as wheel but there is no wheel attribute attached",subEntity->GetName());
xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,errorStr.CStr());
return NULL;
}
pWheelDescr *wDescr = new pWheelDescr();
CKParameterOut *par = subEntity->GetAttributeParameter(attTypeWheelSettings);
if (par)
{
int err = copyTo(wDescr,par);
if (!wDescr->isValid() )
{
xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,"Wheel Description is invalid");
SAFE_DELETE(wDescr);
return NULL;
}
}
//################################################################
//
// Construct the final wheel object basing on the type of the wheel
//
pWheel *result = NULL;
//if(wDescr->wheelFlags & WF_UseWheelShape) {
result = new pWheel2(body,wDescr,subEntity);
/*else
{
//################################################################
// Wheel type 1 specified, check there is also a override for the convex cylinder
if (!subEntity->HasAttribute(attTypeConvexCylinderSettings))
{
errorStr.Format("Object %s has been created with default settings for convex cylinder shape",subEntity->GetName());
xLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,errorStr.CStr());
}
result = new pWheel1(body,wDescr);
}*/
//################################################################
//
// Create the wheel shape
//
//if(wDescr->wheelFlags & WF_UseWheelShape){
dstShape=_createWheelShape2(body->getActor(),descr,wDescr,subEntity,mesh,localPos,localRotation);
((pWheel2*)result)->setWheelShape((NxWheelShape*)dstShape);
// }
/*else
{
dstShape=_createWheelShape1(body->getActor(),(pWheel1*)result,descr,wDescr,subEntity,mesh,localPos,localRotation);
}*/
if (!dstShape)
{
errorStr.Format("Couldn't create wheel shape for object %s",subEntity->GetName());
xLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,errorStr.CStr());
SAFE_DELETE(wDescr);
SAFE_DELETE(result);
return NULL;
}
//################################################################
//
// Finalize wheel setup
//
result->setEntID(subEntity->GetID());
//.........這裏部分代碼省略.........
示例10: GetPMan
pJoint*PhysicManager::getJoint(CK3dEntity*referenceA,CK3dEntity*referenceB/* =NULL */,JType type/* =JT_Any */)
{
pJoint *result = NULL;
pRigidBody *a = GetPMan()->getBody(referenceA);
pRigidBody *b = GetPMan()->getBody(referenceB);
pWorld *wA = a ? a->getWorld() : NULL;
pWorld *wB = b ? b->getWorld() : NULL;
pWorld *worldFinal = NULL;
bool oneBodyJoint = false;// body with world frame ?
CK3dEntity* oneBodyJointReference =NULL;
//----------------------------------------------------------------
//
// Sanity Checks
//
XString errorString;
// Reference A physicalized at all ?
if ( !referenceA && !referenceB )
{
errorString.Format("No reference specified");
xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,errorString.Str());
return result;
}
// Reference A IS NOT Reference B ?
if ( (referenceA!=NULL && referenceB!=NULL) && (a==b) )
{
errorString.Format("Reference A (%s) is the same as Reference B (%s)",referenceA->GetName());
xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,errorString.Str());
return result;
}
// Reference A physicalized at all ?
if (referenceA && !a){
errorString.Format("Reference A (%s) valid but not physicalized",referenceA->GetName());
xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,errorString.Str());
return result;
}
// Reference B physicalized at all ?
if (referenceB && !b){
errorString.Format("Reference B (%s) valid but not physicalized",referenceB->GetName());
xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,errorString.Str());
return result;
}
// world of object a valid ?
if (a && !wA){
errorString.Format("Reference A (%s) is physicalized but has no valid world object",referenceA->GetName());
xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,errorString.Str());
return result;
}
// world of object b valid ?
if (b && !wB){
errorString.Format("Reference B (%s) is physicalized but has no valid world object",referenceB->GetName());
xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,errorString.Str());
return result;
}
// rigid bodies are in the same world
if ( (wA!=NULL && wB!=NULL) && (wA!=wB) )
{
errorString.Format("Reference A (%s) and B(%s) is physicalized but are not in the same world",referenceA->GetName(),referenceB->GetName());
xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,errorString.Str());
return result;
}
//----------------------------------------------------------------
//
// Preparing lookup
//
if ( wA )
worldFinal = wA;
if ( wB )
worldFinal = wB;
// constraint is attached to world frame ?
if ( (a && !b) || (b && !a) )
oneBodyJoint = true;
// world frame constraint, track the reference
if (oneBodyJoint)
{
if ( a )
oneBodyJointReference = referenceA;
if ( b )
oneBodyJointReference = referenceB;
}
//.........這裏部分代碼省略.........
示例11: DescribeArray
void CGBLStorageManagerTestBBBase::DescribeArray( CKDataArray *fieldValues, CKContext *ctx )
{
int cols = fieldValues->GetColumnCount();
int rows = fieldValues->GetRowCount();
if (cols == 0)
{
OutputTestText( ctx, XString("Array contains no columns") );
return;
}
if (rows == 0)
{
OutputTestText( ctx, XString("Array contains no rows (no results were returned)") );
return;
}
XString opStr;
opStr.Format( "Results (%d columns, %d rows):", cols, rows );
OutputTestText( ctx, opStr );
for (int row = 0; row < rows; row++)
{
for (int i=0; i<cols; i++)
{
XString str;
str.Format( "%s (", fieldValues->GetColumnName(i) );
int type = fieldValues->GetColumnType(i);
if (type == CKARRAYTYPE_PARAMETER)
{
str << ctx->GetParameterManager()->ParameterGuidToName(fieldValues->GetColumnParameterGuid(i));
}
else
{
switch (fieldValues->GetColumnType(i))
{
case CKARRAYTYPE_INT:
str << "int";
break;
case CKARRAYTYPE_FLOAT:
str << "float";
break;
case CKARRAYTYPE_STRING:
str << "string";
break;
case CKARRAYTYPE_OBJECT:
str << "object";
break;
default:
str << "UNKNOWN TYPE";
break;
}
}
str << ") : ";
CKSTRING valueField = NULL;
int labelLength = fieldValues->GetElementStringValue(row, i, NULL);
valueField = new CKCHAR[labelLength];
fieldValues->GetElementStringValue(row, i, valueField);
str << valueField;
OutputTestText( ctx, str );
delete [] valueField;
}
//trace << endl;
}
}