EXPORT_C void RMobileCall::NotifyAlternatingCallSwitch(TRequestStatus& aReqStatus) const /** * This notification completes when an alternating call successfully switches call mode */ { Blank(EMobileCallNotifyAlternatingCallSwitch,aReqStatus); }
GRSurface* MinuiBackendAdf::Init() { #if defined(RECOVERY_ABGR) format = DRM_FORMAT_ABGR8888; #elif defined(RECOVERY_BGRA) format = DRM_FORMAT_BGRA8888; #elif defined(RECOVERY_RGBX) format = DRM_FORMAT_RGBX8888; #else format = DRM_FORMAT_RGB565; #endif adf_id_t* dev_ids = nullptr; ssize_t n_dev_ids = adf_devices(&dev_ids); if (n_dev_ids == 0) { return nullptr; } else if (n_dev_ids < 0) { fprintf(stderr, "enumerating adf devices failed: %s\n", strerror(-n_dev_ids)); return nullptr; } intf_fd = -1; for (ssize_t i = 0; i < n_dev_ids && intf_fd < 0; i++) { int err = adf_device_open(dev_ids[i], O_RDWR, &dev); if (err < 0) { fprintf(stderr, "opening adf device %u failed: %s\n", dev_ids[i], strerror(-err)); continue; } err = DeviceInit(&dev); if (err < 0) { fprintf(stderr, "initializing adf device %u failed: %s\n", dev_ids[i], strerror(-err)); adf_device_close(&dev); } } free(dev_ids); if (intf_fd < 0) return nullptr; GRSurface* ret = Flip(); Blank(true); Blank(false); return ret; }
EXPORT_C void RMobileCall::DeactivateCCBS(TRequestStatus& aReqStatus) const /** * This method deactivates a CCBS request that is still waiting for the remote party to become free * It will complete once the deactivate request has been confirmed by the network */ { Blank(EMobileCallDeactivateCCBS,aReqStatus); }
EXPORT_C void RMobileCall::ActivateCCBS(TRequestStatus& aReqStatus) const /** * This method activates a CCBS request on a call that has failed due to remote user busy * It will complete once the activate request has been confirmed by the network */ { Blank(EMobileCallActivateCCBS,aReqStatus); }
EXPORT_C void RMobileCall::GoOneToOne(TRequestStatus& aReqStatus) const /** * This method enables this single call to become a private conversation within a multiparty call * It will complete when the network confirms that the "one-to-one" is either successful or failed */ { Blank(EMobileCallGoOneToOne,aReqStatus); }
EXPORT_C void RMobileCall::Transfer(TRequestStatus& aReqStatus) const /** * This method transfers an ongoing call to a third party, while this party drops out of the call * It will complete when the network confirms that the transfer was either successful or failed */ { Blank(EMobileCallTransfer,aReqStatus); }
EXPORT_C void RMobileCall::Swap(TRequestStatus& aReqStatus) const /** * This method swaps a connected call to its opposite state, either active or on hold * It will complete when the network confirms that the call has changed state */ { Blank(EMobileCallSwap, aReqStatus); }
EXPORT_C void RMobileCall::Resume(TRequestStatus& aReqStatus) const /** * This method resumes a call that is on hold * It will complete when the network confirms that the call is in the active state */ { Blank(EMobileCallResume, aReqStatus); }
EXPORT_C void RMobileCall::Hold(TRequestStatus& aReqStatus) const /** * This method puts a call on hold * It will complete when the network confirms that the call is in the hold state */ { Blank(EMobileCallHold,aReqStatus); }
EXPORT_C void RMobileCall::SwitchAlternatingCall(TRequestStatus& aReqStatus) const /** * This method switches an alternating call to its opposite call mode * It will complete once the call switch has either succeeded or failed */ { Blank(EMobileCallSwitchAlternatingCall,aReqStatus); }
EXPORT_C void RMobileCall::AcceptCCBSRecall(TRequestStatus& aReqStatus) const /** * This method accepts the CCBS recall so that the MO call is set-up to the remote party * It will complete once the call is connected to the remote party */ { Blank(EMobileCallAcceptCCBSRecall,aReqStatus); }
const char* TiXmlElement::ReadValue(const char* p, TiXmlParsingData* data, TiXmlEncoding encoding) { TiXmlDocument* document = GetDocument(); // Read in text and elements in any order. const char* pWithWhiteSpace = p; p = SkipWhiteSpace(p, encoding); while (p && *p) { if (*p != '<') { // Take what we have, make a text element. auto textNode = new TiXmlText(""); if (!textNode) { if (document) document->SetError(TIXML_ERROR_OUT_OF_MEMORY, nullptr, nullptr, encoding); return nullptr; } if (TiXmlBase::IsWhiteSpaceCondensed()) { p = textNode->Parse(p, data, encoding); } else { // Special case: we want to keep the white space // so that leading spaces aren't removed. p = textNode->Parse(pWithWhiteSpace, data, encoding); } if (!textNode->Blank()) LinkEndChild(textNode); else delete textNode; } else { // We hit a '<' // Have we hit a new element or an end tag? This could also be // a TiXmlText in the "CDATA" style. if (StringEqual(p, "</", false, encoding)) { return p; } else { TiXmlNode* node = Identify(p, encoding); if (node) { p = node->Parse(p, data, encoding); LinkEndChild(node); } else { return nullptr; } } } pWithWhiteSpace = p; p = SkipWhiteSpace(p, encoding); } if (!p) { if (document) document->SetError(TIXML_ERROR_READING_ELEMENT_VALUE, nullptr, nullptr, encoding); } return p; }
EXPORT_C TInt RMobileCall::RejectCCBS() const /** * This method rejects the possibility of activating a CCBS request * * \return KErrNone * \exception KErrNotReady if call is not expecting a CCBS rejection */ { return Blank(EMobileCallRejectCCBS); }
void Chintz_base::control(){ QString S=CONTROLFILENAMELine->text(); QFileInfo q(S); QDir d=q.dir(); if(!d.exists()){ QString M="Directory z Does not Exist"; M.replace(QRegExp("z"),d.path()); QMessageBox *b=new QMessageBox("Error:No Directory", M, QMessageBox::Warning, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton,this); b->exec(); CONTROLFILENAMELine->setText(CONTROLFILENAME); return; } if (q.exists()){ QString M="File z Exists:What Now?"; M.replace(QRegExp("z"),CONTROLFILENAME); QMessageBox *q=new QMessageBox("File Exists", M, QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel,this); q->setButtonText( QMessageBox::Yes, "Load" ); q->setButtonText( QMessageBox::No, "OverWrite" ); switch(q->exec()){ case QMessageBox::Yes: Blank(); CONTROLFILENAME=S; ReadChildControlFile(S); altered_state=false; Status->setText("");break; case QMessageBox::No: CONTROLFILENAME=S; WriteTheOutput(); altered_state=false; Status->setText("");break; case QMessageBox::Cancel: CONTROLFILENAMELine->setText(CONTROLFILENAME); } }else{ CONTROLFILENAME=S; WriteTheOutput(); altered_state=false; Status->setText(""); } }
/* ----> Create an alarm <---- */ dbref create_alarm(CONTEXT) { dbref alarm,owner = (!in_command && (Uid(player) != player)) ? Uid(player):Owner(player); setreturn(ERROR,COMMAND_FAIL); if(Level3(Owner(player))) { if(!Blank(arg1)) { if(strlen(arg1) <= 128) { if(ok_name(arg1)) { if(adjustquota(player,owner,ALARM_QUOTA)) { /* ----> Create and initialise alarm <---- */ alarm = new_object(); db[alarm].destination = NOTHING; db[alarm].location = player; db[alarm].flags = OBJECT; db[alarm].owner = owner; db[alarm].type = TYPE_ALARM; if(!in_command && (Uid(player) == owner) && friendflags_set(owner,player,NOTHING,FRIEND_SHARABLE)) db[alarm].flags |= SHARABLE; ansi_code_filter((char *) arg1,arg1,1); initialise_data(alarm); setfield(alarm,NAME,arg1,1); setfield(alarm,DESC,arg2,0); stats_tcz_update_record(0,0,0,1,0,0,0); PUSH(alarm,db[player].fuses); if(!in_command) output(getdsc(player),player,0,1,0,ANSI_LGREEN"Alarm "ANSI_LWHITE"%s"ANSI_LGREEN" created with ID "ANSI_LYELLOW"#%d"ANSI_LGREEN".",getfield(alarm,NAME),alarm); else writelog(HACK_LOG,1,"HACK","Alarm %s(%d) created within compound command %s(%d) owned by %s(%d).",getname(alarm),alarm,getname(current_command),current_command,getname(Owner(current_command)),Owner(current_command)); setreturn(getnameid(player,alarm,NULL),COMMAND_SUCC); return(alarm); } else warnquota(player,owner,"to build an alarm"); } else output(getdsc(player),player,0,1,0,ANSI_LGREEN"Sorry, an alarm can't have that name."); } else output(getdsc(player),player,0,1,0,ANSI_LGREEN"Sorry, the maximum length of an alarm's name is 128 characters."); } else output(getdsc(player),player,0,1,0,ANSI_LGREEN"Please specify a name for the new alarm."); } else output(getdsc(player),player,0,1,0,ANSI_LGREEN"Sorry, only Wizards/Druids and above can create an alarm."); return(NOTHING); }
/** Relinquishes ownership of the DF_EAP, to allow other clients to use it. Although the request completes relatively quickly, it will set the server's process running to attempt a deactivate on the sub-session's corresponding application. The deactivate will allow future clients to initialise the application, which should reset all its DF_EAP states. The initial state change of the sub-session will be EEapMethodUnableToInitialise, as the request completes without waiting for the application's deactivation. After the sub-session is able to deactivate the app, the state will change to EEapMethodAvailable. The server will make a decision on deactivating the application based on whether there are other sub-session open to the same application (but different EAP types/ DF_EAP). Only when the application is no longer in use, that the server will deactivate it. Notifications can be posted using RMobileSmartCardEap::NotifyEapMethodAccessStatusChange() to observe such state changes. @return If an error is returned, this object will maintain lock on the UICC application's DF_EAP. @see RMobileSmartCardEap::NotifyEapMethodAccessStatusChange() @capability ReadDeviceData @publishedPartner @released */ EXPORT_C TInt RMobileSmartCardEap::ReleaseEapMethod() { if (iSemaphore.Handle() == 0) { return KErrBadHandle; } if (!iOwnsEapMethodLock) { return KErrInUse; } TInt ret = Blank(EMobileSmartCardEapReleaseEapMethod); if (ret == KErrNone) { iSemaphore.Signal(); iOwnsEapMethodLock = EFalse; } return ret; }
void Chintz_base::OpenChildControlFile() { if (altered_state) { QMessageBox *q=new QMessageBox("Altered state!", "Save the current values?", QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel,this); q->setButtonText( QMessageBox::Yes, "Save" ); q->setButtonText( QMessageBox::No, "Don't Save" ); switch(q->exec()){ case QMessageBox::Yes:WriteTheOutput();if (CONTROLFILENAME.length() ==0)return;break; case QMessageBox::No:break; case QMessageBox::Cancel:return; } } QString S=QFileDialog::getOpenFileName(QString::null,"",this); if (!S.isEmpty()) {set_CONTROLFILENAME(S);CONTROLFILENAMELine->setText(S);} if (!S.isEmpty()){Blank();ReadChildControlFile(CONTROLFILENAME);altered_state=false;Status->setText("");} }
void Progress::Smash(BOOL ForceSmash) { if (ActiveDisplays > 0 || ForceSmash) { #if DELAY_THREAD ThreadAlive = FALSE; // Stop the delay thread (if any) #endif // --- Tell the node subsystem that we're turning off the hourglass Node::StopHourglass(); // --- Blank the status line text String_256 Blank(""); GetApplication()->UpdateStatusBarText(&Blank); // --- Remove any active progress bar if (StatusLine::Get()) { StatusLine::Get()->ShowProgress(FALSE); } // --- And reset all variables to suitable defaults ActiveDisplays = 0; JobCancelled = FALSE; JobDelayed = TRUE; FinalCount = 0; CurrentPercent = 0; HourglassShown = FALSE; JobDescription.MakeMsg(_R(IDS_BUSYMSG)); } // --- And ensure no busy cursors are left active SmashBusyCursor(); }
bool Chintz_base::Clear(){ if (altered_state) { QMessageBox *q=new QMessageBox("Altered state!", "Save the current values?", QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel,this); q->setButtonText( QMessageBox::Yes, "Save" ); q->setButtonText( QMessageBox::No, "Don't Save" ); switch(q->exec()){ case QMessageBox::Yes:WriteTheOutput();if (CONTROLFILENAME.length() ==0)return false;break; case QMessageBox::No:break; case QMessageBox::Cancel:return false; } } CONTROLFILENAME="";CONTROLFILENAMELine->setText(""); Blank(); altered_state=false; Status->setText(""); return true; }
int main( void ) { struct Process *Proc = ( struct Process * )FindTask( 0L ); BlankMsg *FreeMsg; LONG ReturnVal = 0; if( Proc->pr_CLI ) { STRPTR Str = BADDR((( struct CommandLineInterface * ) BADDR( Proc->pr_CLI ))->cli_CommandName ); CopyMem( Str + 1, PrefsPath, *Str ); PrefsPath[*Str] = '\0'; strcat( PrefsPath, ".prefs" ); } IntuitionBase = OpenLibrary( "intuition.library", 37L ); GfxBase = OpenLibrary( GRAPHICSNAME, 37L ); GarshnelibBase = OpenLibrary( "Garshnelib.library", 37L ); if( IntuitionBase && GfxBase && GarshnelibBase ) { ClientPort = CreateMsgPort(); TimerPort = CreateMsgPort(); if( ClientPort && TimerPort ) { TimeOutIO = ( struct timerequest * ) CreateExtIO( TimerPort, sizeof( struct timerequest )); if( TimeOutIO && !OpenDevice( "timer.device", UNIT_VBLANK, ( struct IORequest * )TimeOutIO, 0L )) { ClientPort->mp_Node.ln_Name = PortName; ClientPort->mp_Node.ln_Pri = 0L; AddPort( ClientPort ); CurPrefs = LoadPrefs( PrefsPath ); CurrentTime( &InitSecs, &InitMicros ); RangeSeed = InitSecs + InitMicros; Blank( CurPrefs ); while( FreeMsg = ( BlankMsg * )GetMsg( ClientPort )) { if( FreeMsg->bm_Type & BF_REPLY ) FreeVec( FreeMsg ); else { FreeMsg->bm_Type |= BF_REPLY; ReplyMsg(( struct Message * )FreeMsg ); } } if( CurPrefs ) FreeVec( CurPrefs ); if( !PortRemoved ) RemPort( ClientPort ); } if( TimeOutIO ) { if( TimeOutIO->tr_node.io_Device ) CloseDevice(( struct IORequest * )TimeOutIO ); DeleteExtIO(( struct IORequest * )TimeOutIO ); } } else { Complain( "ClientPort or TimerPort failed to open." ); ReturnVal = 2; } if( ClientPort ) { BlankMsg *TmpMsg; while( TmpMsg = ( BlankMsg * )GetMsg( ClientPort )) { TmpMsg->bm_Flags |= BF_REPLY; ReplyMsg(( struct Message * )TmpMsg ); } DeleteMsgPort( ClientPort ); } if( TimerPort ) DeleteMsgPort( TimerPort ); } else { Complain( "A library failed to open." ); ReturnVal = 1; } if( GarshnelibBase ) CloseLibrary( GarshnelibBase ); if( GfxBase ) CloseLibrary( GfxBase ); if( IntuitionBase ) CloseLibrary( IntuitionBase ); return ReturnVal; }
LONG HandleSignal( LONG Signal ) { BlankMsg *CurMsg; LONG RetVal = OK; if( Signal & SIG_TIMER ) { MessageServer( BM_FAILED ); RetVal = UNBLANK; } if( Signal & SIG_PORT ) { while( CurMsg = ( BlankMsg * )GetMsg( ClientPort )) { LONG Type = CurMsg->bm_Type; LONG Flags = CurMsg->bm_Flags; if( Type != BM_PING ) ServerBlanking = ( LONG * )CurMsg->bm_Mess.mn_Node.ln_Name; if( Flags & BF_REPLY ) FreeVec( CurMsg ); else { CurMsg->bm_Flags |= BF_REPLY; ReplyMsg(( struct Message * )CurMsg ); } switch( Type ) { case BM_DOBLANK: case BM_DOTESTBLANK: if( !Blanking ) { PrefObject *TmpPrefs; Blanking = TRUE; CurrentTime( &InitSecs, &InitMicros ); if( Type == BM_DOTESTBLANK ) TmpPrefs = LoadPrefs( "T:GBlankerTmpPrefs" ); switch( Blank( Type == BM_DOBLANK ? CurPrefs : TmpPrefs )) { case FAILED: /* In this case the Blank() function failed to init */ /* (ie. no memory or something). So we yell. */ MessageServer( BM_FAILED ); break; case DELAYEDQUIT: case QUIT: RetVal = QUIT; break; } Blanking = FALSE; if( Type == BM_DOTESTBLANK ) FreeVec( TmpPrefs ); } break; case BM_RELOADPREFS: if( CurPrefs ) FreeVec( CurPrefs ); CurPrefs = LoadPrefs( PrefsPath ); break; case BM_DELAYEDQUIT: RemPort( ClientPort ); PortRemoved = TRUE; RetVal = DELAYEDQUIT; break; case BM_DOQUIT: RetVal = QUIT; break; case BM_UNBLANK: break; } } } if( Signal & SIGBREAKF_CTRL_C ) RetVal = QUIT; return RetVal; }
// Please note isSingular, Solution, Degreem N and Solve were tested inderectly here //========================================================================================================================== int resetTest(void) { TestUtil testFramework( "PolyFit", "Reset", __FILE__, __LINE__ ); bool covMatDiffBool = true; bool solnDiffBool = true; //Polynomial will be reset without user inputed parameter gpstk::PolyFit<double> resetPolyD(2); //Poly will be reset with a parameter gpstk::PolyFit<double> resetPolyP(2); double data[4] = {0.,2.,4.,-1.}; double time[4] = {3.,3.,4.,2.,}; for (int i =0;i<4;i++) { resetPolyD.Add(time[i],data[i]); resetPolyP.Add(time[i],data[i]); } //--------------------------------------------------------------------- //Test Reset() //--------------------------------------------------------------------- resetPolyD.Reset(); gpstk::Matrix<double> Blank(2,2,0.); gpstk::Vector<double> Zero(2,0.); gpstk::Vector<double> resetPolyDSolution = resetPolyD.Solution(); gpstk::Matrix<double> resetPolyDCov = resetPolyD.Covariance(); testFramework.assert((unsigned) 0 == resetPolyD.N() , "Reset did not set the datapoint counter to zero" , __LINE__); testFramework.assert((unsigned) 2 == resetPolyD.Degree(), "Reset did not maintain the maximum fit degree as 2", __LINE__); testFramework.assert(resetPolyD.isSingular() , "The fit found after Reset was not singular" , __LINE__); for (int i = 0; i<2; i++) { for (int j = 0; j<2; j++) { covMatDiffBool = covMatDiffBool && (Blank[i][j] == resetPolyDCov[i][j]); } solnDiffBool = solnDiffBool && (fabs(resetPolyDSolution[i]) < eps); } testFramework.assert(covMatDiffBool, "Covariance matrix found to be nonzero after Reset", __LINE__); testFramework.assert(solnDiffBool , "Solution vector found to be nonzero after Reset" , __LINE__); //--------------------------------------------------------------------- //Test Reset(int) //--------------------------------------------------------------------- resetPolyP.Reset((unsigned) 3); covMatDiffBool = true; solnDiffBool = true; gpstk::Matrix<double> BlankP(3,3,0.); gpstk::Vector<double> ZeroP(3,0.); gpstk::Vector<double> resetPolyPSolution = resetPolyP.Solution(); gpstk::Matrix<double> resetPolyPCov = resetPolyP.Covariance(); testFramework.assert((unsigned) 0 == resetPolyP.N() , "Reset(int) did not set the datapoint counter to zero" , __LINE__); testFramework.assert((unsigned) 3 == resetPolyP.Degree(), "Reset(int) did not change the maximum fit degree to 3", __LINE__); testFramework.assert(resetPolyP.isSingular() , "The fit found after Reset(int) was not singular" , __LINE__); for (int i = 0; i<3; i++) { for (int j = 0; j<3; j++) { covMatDiffBool = covMatDiffBool && (fabs(resetPolyPCov[i][j]) < eps); } solnDiffBool = solnDiffBool && (fabs(resetPolyPSolution[i]) < eps); } testFramework.assert(covMatDiffBool, "Covariance matrix found to be nonzero after Reset(int)", __LINE__); testFramework.assert(solnDiffBool , "Solution vector found to be nonzero after Reset(int)" , __LINE__); return testFramework.countFails(); }
void RSpecialCall::RecoverDataPortAsync(TRequestStatus& aStatus) { Blank(EEtelCallRecoverDataPort,aStatus); }
/* **** This test is designed to test the validity of the reset member of the PolyFit class **** Reset is tested by first adding data to a blank PolyFit object and then clearing **** that data (Please note this dad was already tested in the previous test) **** Please note isSingular, Solution, Degreem N and Solve were tested inderectly here */ void xPolyFit :: resetTest (void) { //Polynomial will be reset without user inputed parameter gpstk::PolyFit<double> resetPolyD(2); //Poly will be reset with a parameter gpstk::PolyFit<double> resetPolyP(2); double data[4] = {0.,2.,4.,-1.}; double time[4] = {3.,3.,4.,2.,}; for (int i =0;i<4;i++) { resetPolyD.Add(time[i],data[i]); resetPolyP.Add(time[i],data[i]); } resetPolyD.Reset(); gpstk::Matrix<double> Blank(2,2,0.); gpstk::Vector<double> Zero(2,0.); gpstk::Vector<double> resetPolyDSolution = resetPolyD.Solution(); gpstk::Matrix<double> resetPolyDCov = resetPolyD.Covariance(); CPPUNIT_ASSERT_EQUAL((unsigned) 0, resetPolyD.N()); CPPUNIT_ASSERT_EQUAL((unsigned) 2, resetPolyD.Degree()); CPPUNIT_ASSERT_EQUAL(true, resetPolyD.isSingular()); CPPUNIT_ASSERT_EQUAL(Blank[0][0],resetPolyDCov[0][0]); CPPUNIT_ASSERT_EQUAL(Blank[0][1],resetPolyDCov[0][1]); CPPUNIT_ASSERT_EQUAL(Blank[1][0],resetPolyDCov[1][0]); CPPUNIT_ASSERT_EQUAL(Blank[1][1],resetPolyDCov[1][1]); CPPUNIT_ASSERT_DOUBLES_EQUAL(Zero[0],resetPolyDSolution[0],1e-6); CPPUNIT_ASSERT_DOUBLES_EQUAL(Zero[1],resetPolyDSolution[1],1e-6); resetPolyP.Reset((unsigned) 3); gpstk::Matrix<double> BlankP(3,3,0.); gpstk::Vector<double> ZeroP(3,0.); gpstk::Vector<double> resetPolyPSolution = resetPolyP.Solution(); gpstk::Matrix<double> resetPolyPCov = resetPolyP.Covariance(); CPPUNIT_ASSERT_EQUAL((unsigned) 0, resetPolyP.N()); CPPUNIT_ASSERT_EQUAL((unsigned) 3, resetPolyP.Degree()); CPPUNIT_ASSERT_EQUAL(true, resetPolyP.isSingular()); CPPUNIT_ASSERT_EQUAL(BlankP[0][0],resetPolyPCov[0][0]); CPPUNIT_ASSERT_EQUAL(BlankP[0][1],resetPolyPCov[0][1]); CPPUNIT_ASSERT_EQUAL(BlankP[0][2],resetPolyPCov[0][2]); CPPUNIT_ASSERT_EQUAL(BlankP[1][0],resetPolyPCov[1][0]); CPPUNIT_ASSERT_EQUAL(BlankP[1][1],resetPolyPCov[1][1]); CPPUNIT_ASSERT_EQUAL(BlankP[1][2],resetPolyPCov[1][2]); CPPUNIT_ASSERT_EQUAL(BlankP[2][0],resetPolyPCov[2][0]); CPPUNIT_ASSERT_EQUAL(BlankP[2][1],resetPolyPCov[2][1]); CPPUNIT_ASSERT_EQUAL(BlankP[2][2],resetPolyPCov[2][2]); CPPUNIT_ASSERT_DOUBLES_EQUAL(ZeroP[0],resetPolyPSolution[0],1e-6); CPPUNIT_ASSERT_DOUBLES_EQUAL(ZeroP[1],resetPolyPSolution[1],1e-6); CPPUNIT_ASSERT_DOUBLES_EQUAL(ZeroP[2],resetPolyPSolution[2],1e-6); }
void FormatWithCurrentFlags(const LOKI_SAFEFORMAT_UNSIGNED_LONG i) { // look at the format character Char formatChar = *format_; bool isSigned = formatChar == _T('d') || formatChar == _T('i'); if (formatChar == _T('p')) { formatChar = _T('x'); // pointers go to hex SetAlternateForm(); // printed with '0x' in front isSigned = true; // that's what gcc does } if (!JQ_STRCHR(_T("cdiuoxX"), formatChar)) { result_ = -1; return; } Char buf[ sizeof(LOKI_SAFEFORMAT_UNSIGNED_LONG) * 3 // digits + 1 // sign or ' ' + 2 // 0x or 0X + 1]; // terminating zero const Char *const bufEnd = buf + (sizeof(buf) / sizeof(Char)); Char * bufLast = buf + (sizeof(buf) / sizeof(Char) - 1); Char signChar = 0; unsigned int base = 10; if (formatChar == _T('c')) { // Format only one character // The 'fill with zeros' flag is ignored ResetFillZeros(); *bufLast = static_cast<char_type>(i); } else { // TODO: inefficient code, refactor const bool negative = isSigned && static_cast<LOKI_SAFEFORMAT_SIGNED_LONG>(i) < 0; if (formatChar == _T('o')) base = 8; else if (formatChar == _T('x') || formatChar == _T('X')) base = 16; bufLast = isSigned ? RenderWithoutSign(static_cast<LOKI_SAFEFORMAT_SIGNED_LONG>(i), bufLast, base, formatChar == _T('X')) : RenderWithoutSign(i, bufLast, base, formatChar == _T('X')); // Add the sign if (isSigned) { negative ? signChar = _T('-') : ShowSignAlways() ? signChar = _T('+') : Blank() ? signChar = _T(' ') : 0; } } // precision size_t countDigits = bufEnd - bufLast, countZeros = prec_ != size_t(-1) && countDigits < prec_ && formatChar != _T('c') ? prec_ - countDigits : 0, countBase = base != 10 && AlternateForm() && i != 0 ? (base == 16 ? 2 : countZeros > 0 ? 0 : 1) : 0, countSign = (signChar != 0), totalPrintable = countDigits + countZeros + countBase + countSign; size_t countPadLeft = 0, countPadRight = 0; if (width_ > totalPrintable) { if (LeftJustify()) { countPadRight = width_ - totalPrintable; countPadLeft = 0; } else { countPadLeft = width_ - totalPrintable; countPadRight = 0; } } if (FillZeros() && prec_ == size_t(-1)) { // pad with zeros and no precision - transfer padding to precision countZeros = countPadLeft; countPadLeft = 0; } // ok, all computed, ready to print to device Fill(' ', countPadLeft); if (signChar != 0) Write(&signChar, &signChar + 1); if (countBase > 0) Fill(_T('0'), 1); if (countBase == 2) Fill(formatChar, 1); Fill(_T('0'), countZeros); Write(bufLast, bufEnd); Fill(_T(' '), countPadRight); // done, advance Next(); }