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


C++ String::AppendFormat方法代码示例

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


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

示例1:

ECode CInstrumentationTestRunner::WatcherResultPrinter::AddFailure(
    /* [in] */ ITest* test,
    /* [in] */ ITestFailure* failure)
{
    String message;
    failure->ExceptionMessage(&message);
    String trace;
    failure->Trace(&trace);
    message.Append("\n");
    message.Append(trace);
    trace = message;
    String prevTrace;
    mTestResult->GetString(REPORT_KEY_STACK, &prevTrace);
    if (!prevTrace.IsNull()) {
        prevTrace.Append("\n");
        prevTrace.Append(trace);
        trace = prevTrace;
    }
    mTestResult->PutString(REPORT_KEY_STACK, trace);
    mTestResultCode = IInstrumentationTestRunner::REPORT_VALUE_RESULT_FAILURE;
    // pretty printing
    String name;
    ITestCase::Probe(test)->GetName(&name);
    String result;
    result.AppendFormat("\nFailure in %s:\n%s", name.string(), trace.string());
    mTestResult->PutString(IInstrumentation::REPORT_KEY_STREAMRESULT, result);
    return NOERROR;
}
开发者ID:TheTypoMaster,项目名称:ElastosRDK5_0,代码行数:28,代码来源:CInstrumentationTestRunner.cpp

示例2: HttpFailure

Boolean Connection::HttpFailure(
    /* [in] */ IRequest* req,
    /* [in] */ Int32 errorId,
    /* [in] */ ECode e)
{
    Boolean ret = TRUE;

    if (HttpLog::LOGV)
        HttpLog::V("httpFailure() ******* %d count %d %s %s", e, ((Request*)req)->mFailCount,
            TO_CSTR(mHost), Ptr(((Request*)req))->Func(((Request*)req)->GetUri).string());

    if (++((Request*)req)->mFailCount >= RETRY_REQUEST_LIMIT) {
        ret = FALSE;
        String error;
        if (errorId < 0) {
            ErrorStrings::GetString(errorId, mContext, &error);
        } else {
            error.AppendFormat("%d", e);
        }
        ((Request*)req)->mEventHandler->Error(errorId, error);
        ((Request*)req)->Complete();
    }

    CloseConnection();
    AutoPtr<IInterface> tmpObj;
    mHttpContext->RemoveAttribute(HTTP_CONNECTION, (IInterface**)&tmpObj);

    return ret;
}
开发者ID:XilongPei,项目名称:Elastos5,代码行数:29,代码来源:Connection.cpp

示例3: TryParseDescription

String CountdownConditionProvider::TryParseDescription(
    /* [in] */ IUri* conditionUri)
{
    AutoPtr<IZenModeConfigHelper> helper;
    CZenModeConfigHelper::AcquireSingleton((IZenModeConfigHelper**)&helper);
    Int64 time;
    helper->TryParseCountdownConditionId(conditionUri, &time);
    if (time == 0) return String(NULL);

    AutoPtr<ISystem> sys;
    CSystem::AcquireSingleton((ISystem**)&sys);
    Int64 now;
    sys->GetCurrentTimeMillis(&now);

    AutoPtr<ICharSequence> span =
            DateUtils::GetRelativeTimeSpanString(time, now, IDateUtils::MINUTE_IN_MILLIS);

    String spanStr;
    span->ToString(&spanStr);

    String str;
    str = "";
    str.AppendFormat("Scheduled for %s, %s in the future (%s), now=%s",
            Ts(time).string(),
            StringUtils::ToString(time - now).string(),
            spanStr.string(),
            Ts(now).string());

    return str;
}
开发者ID:XilongPei,项目名称:Elastos5,代码行数:30,代码来源:CountdownConditionProvider.cpp

示例4: ParseComposedIconComponent

Boolean IconPackHelper::ParseComposedIconComponent(
    /* [in] */ IXmlPullParser* parser,
    /* [in] */ IMap* iconPackResources)
{
    String icon;
    String tag;
    parser->GetName(&tag);
    if (!IsComposedIconComponent(tag)) {
        return FALSE;
    }

    Int32 count;
    if (parser->GetAttributeCount(&count), count >= 1) {
        if (tag.EqualsIgnoreCase(ICON_BACK_TAG)) {
            parser->GetAttributeCount(&mIconBackCount);
            for (Int32 i = 0; i < mIconBackCount; i++) {
                tag = "";
                tag.AppendFormat(ICON_BACK_FORMAT.string(), i);
                parser->GetAttributeValue(i, &icon);
                AutoPtr<IComponentName> component;
                CComponentName::New(tag, String(""), (IComponentName**)&component);
                iconPackResources->Put(component, CoreUtils::Convert(icon));
            }
        }
        else {
            parser->GetAttributeValue(0, &icon);
            AutoPtr<IComponentName> component;
            CComponentName::New(tag, String(""), (IComponentName**)&component);
            iconPackResources->Put(component, CoreUtils::Convert(icon));
        }
        return TRUE;
    }

    return FALSE;
}
开发者ID:elastos,项目名称:Elastos5,代码行数:35,代码来源:IconPackHelper.cpp

示例5: VectorAsString

String FileDataCacheItem::VectorAsString( const DVector& v )
{
   String s = String().Format( "\n%d", v.Length() );
   for ( int i = 0; i < v.Length(); ++i )
      s.AppendFormat( "\n%.8e", v[i] );
   return s;
}
开发者ID:SunGong1993,项目名称:PCL,代码行数:7,代码来源:FileDataCache.cpp

示例6: OnSubscribe

ECode CountdownConditionProvider::OnSubscribe(
    /* [in] */ IUri* conditionId)
{
    if (DEBUG) Slogger::D(TAG, "onSubscribe %p", conditionId);
    AutoPtr<IZenModeConfigHelper> helper;
    CZenModeConfigHelper::AcquireSingleton((IZenModeConfigHelper**)&helper);
    helper->TryParseCountdownConditionId(conditionId, &mTime);

    AutoPtr<IInterface> obj;
    mContext->GetSystemService(IContext::ALARM_SERVICE, (IInterface**)&obj);
    AutoPtr<IAlarmManager> alarms = IAlarmManager::Probe(obj);
    String str;
    IObject::Probe(conditionId)->ToString(&str);
    AutoPtr<IIntent> intent;
    CIntent::New(ACTION, (IIntent**)&intent);
    intent->PutExtra(EXTRA_CONDITION_ID, str);
    intent->SetFlags(IIntent::FLAG_RECEIVER_REGISTERED_ONLY);

    AutoPtr<IPendingIntentHelper> pendingIntentHelper;
    CPendingIntentHelper::AcquireSingleton((IPendingIntentHelper**)&pendingIntentHelper);
    AutoPtr<IPendingIntent> pendingIntent;
    pendingIntentHelper->GetBroadcast(mContext, REQUEST_CODE,
            intent, IPendingIntent::FLAG_UPDATE_CURRENT, (IPendingIntent**)&pendingIntent);
    alarms->Cancel(pendingIntent);
    if (mTime > 0) {
        AutoPtr<ISystem> sys;
        CSystem::AcquireSingleton((ISystem**)&sys);
        Int64 now;
        sys->GetCurrentTimeMillis(&now);

        AutoPtr<ICharSequence> span =
                DateUtils::GetRelativeTimeSpanString(mTime, now, IDateUtils::MINUTE_IN_MILLIS);
        if (mTime <= now) {
            // in the past, already false
            NotifyCondition(NewCondition(mTime, ICondition::STATE_FALSE));
        }
        else {
            // in the future, set an alarm
            alarms->SetExact(IAlarmManager::RTC_WAKEUP, mTime, pendingIntent);
        }

        String spanStr;
        span->ToString(&spanStr);

        str = "";
        str.AppendFormat("%s %s for %s, %s in the future (%s), now=%s",
                (mTime <= now ? "Not scheduling" : "Scheduling"),
                ACTION.string(),
                Ts(mTime).string(),
                StringUtils::ToString(mTime - now).string(),
                spanStr.string(),
                Ts(now).string());
        if (DEBUG) Slogger::D(TAG, str);
    }
    return NOERROR;
}
开发者ID:XilongPei,项目名称:Elastos5,代码行数:56,代码来源:CountdownConditionProvider.cpp

示例7: Join

String File::Join(
    /* [in] */ const String& prefix,
    /* [in] */ const String& suffix)
{
    Int32 prefixLength = prefix.GetLength();
    Boolean haveSlash = (prefixLength > 0 && prefix.GetChar(prefixLength - 1) == sSeparatorChar);
    if (!haveSlash) {
        haveSlash = (suffix.GetLength() > 0 && suffix.GetChar(0) == sSeparatorChar);
    }
    String joinStr = prefix;
    if (!haveSlash) joinStr.AppendFormat("%c", sSeparatorChar);
    joinStr += suffix;
    return joinStr;
}
开发者ID:TheTypoMaster,项目名称:ElastosRDK5_0,代码行数:14,代码来源:File.cpp

示例8: Message

String SourceCodeError::Message() const
{
   String s = m_message;

   if ( m_lineNumber >= 0 || m_columnNumber >= 0 )
   {
      s += " (";

      if ( m_lineNumber >= 0 )
      {
         s.AppendFormat( "line=%d", m_lineNumber );
         if ( m_columnNumber >= 0 )
            s += ',';
      }

      if ( m_columnNumber >= 0 )
         s.AppendFormat( "column=%d", m_columnNumber );

      s += ")";
   }

   return s;
}
开发者ID:SunGong1993,项目名称:PCL,代码行数:23,代码来源:Exception.cpp

示例9: GetDataDirForUser

String PackageManager::GetDataDirForUser(
    /* [in] */ Int32 userId,
    /* [in] */ const String& packageName)
{
    // TODO: This should be shared with Installer's knowledge of user directory
    AutoPtr<IEnvironment> env;
    CEnvironment::AcquireSingleton((IEnvironment**)&env);
    AutoPtr<IFile> file;
    env->GetDataDirectory((IFile**)&file);
    String strFile;
    file->ToString(&strFile);
    strFile.AppendFormat("/user/%d/%s", userId, packageName.string());
    return strFile;
}
开发者ID:XilongPei,项目名称:Elastos5,代码行数:14,代码来源:PackageManager.cpp

示例10: WaitControllerLocked

ECode MyActivityController::WaitControllerLocked(
    /* [in] */ Int32 pid,
    /* [in] */ Int32 state,
    /* [out] */ Int32* result)
{
    VALIDATE_NOT_NULL(result);
    if (!mGdbPort.IsNull()) {
        KillGdbLocked();

        PFL_EX("Starting gdbserver on port %s", mGdbPort.string());
        PFL_EX("Do the following:");
        PFL_EX("  adb forward tcp:%s tcp:%s", mGdbPort.string(), mGdbPort.string());
        PFL_EX("  gdbclient app_process :%s", mGdbPort.string());

        String cmd;
        cmd.AppendFormat("gdbserver :%s --attach %d", mGdbPort.string(), pid);
        mFile = popen(cmd.string(), "r");

        mGdbThread = NULL;
        AutoPtr<GdbThreadRunnable> runable = new GdbThreadRunnable(this);
        CThread::New(runable, (IThread**)&mGdbThread);
        mGdbThread->Start();
        mLock.Wait(500);
    }

    mState = state;
    PFL_EX("");
    PrintMessageForState();

    while (mState != STATE_NORMAL) {
        mLock.Wait(500);
    }
    KillGdbLocked();
    *result = mResult;
    return NOERROR;
}
开发者ID:XilongPei,项目名称:Elastos5,代码行数:36,代码来源:MyActivityController.cpp

示例11: Apply

   template <class P> inline
   static void Apply( GenericImage<P>& image, const IntegerResample& Z )
   {
      int width = image.Width();
      int w0 = width;
      int height = image.Height();
      int h0 = height;

      Z.GetNewSizes( width, height );

      if ( width == w0 && height == h0 )
         return;

      if ( width == 0 || height == 0 )
      {
         image.FreeData();
         return;
      }

      image.EnsureUnique();

      typename P::sample* f = 0;
      typename P::sample** f0 = 0;

      int n = image.NumberOfChannels();
      size_type N = image.NumberOfPixels();
      typename GenericImage<P>::color_space cs0 = image.ColorSpace();

      StatusMonitor status = image.Status();

      int z = pcl::Abs( Z.ZoomFactor() );
      int z2 = z*z;
      int n2 = z2 >> 1;

      try
      {
         if ( status.IsInitializationEnabled() )
         {
            String info = (Z.ZoomFactor() > 0) ? "Upsampling" : "Downsampling";

            info.AppendFormat( " %d:%d, %dx%d",
               (Z.ZoomFactor() > 0) ? z : 1, (Z.ZoomFactor() > 0) ? 1 : z, width, height );

            if ( Z.ZoomFactor() < 0 )
            {
               info += ", ";
               switch ( Z.DownsampleMode() )
               {
               default:
               case IntegerDownsampleMode::Average: info += "average"; break;
               case IntegerDownsampleMode::Median:  info += "median"; break;
               case IntegerDownsampleMode::Maximum: info += "maximum"; break;
               case IntegerDownsampleMode::Minimum: info += "minimum"; break;
               }
            }

            status.Initialize( info, n*N );
         }

         GenericVector<typename P::sample> fm;
         if ( Z.ZoomFactor() < 0 && Z.DownsampleMode() == IntegerDownsampleMode::Median )
            fm = GenericVector<typename P::sample>( z2 );

         f0 = image.ReleaseData();

         for ( int c = 0; c < n; ++c, status += N )
         {
            f = image.Allocator().AllocatePixels( width, height );

            if ( Z.ZoomFactor() > 0 )
            {
               const typename P::sample* f0c = f0[c];

               for ( int y = 0; y < h0; ++y )
               {
                  int yz = y*z;

                  for ( int x = 0; x < w0; ++x )
                  {
                     int xz = x*z;
                     typename P::sample v = *f0c++;

                     for ( int i = 0; i < z; ++i )
                     {
                        typename P::sample* fi = f + (size_type( yz + i )*width + xz);

                        for ( int j = 0; j < z; ++j )
                           *fi++ = v;
                     }
                  }
               }
            }
            else
            {
               typename P::sample* fz = f;

               for ( int y = 0; y < height; ++y )
               {
                  const typename P::sample* fy = f0[c] + size_type( y )*z*w0;

//.........这里部分代码省略.........
开发者ID:SunGong1993,项目名称:PCL,代码行数:101,代码来源:IntegerResample.cpp

示例12: guard

   void
   Messages::Refresh(bool update_recent_flags)
   {
      boost::lock_guard<boost::recursive_mutex> guard(_mutex);

	  // int startTime = GetTickCount();

      bool retrieveQueue = account_id_ == -1;

      if (retrieveQueue && last_refreshed_uid_ > 0)
      {
         /*
            We can't do partial refreshes of messages in the queue. Why? 
            Because we use the message UID to determine which part of the
            queue we need to read from the database, and UID's aren't given
            to messages before they are inserted into the queue.
         */
         ErrorManager::Instance()->ReportError(ErrorManager::Medium, 5204, "Messages::Refresh", "Refresh not supported on the current collection.");
         return;

      }

      SQLCommand command;

      // Build SQL statement that will be used to fetch list of messages.
      String sSQL;
      sSQL = "select * from hm_messages where "; 

      if (retrieveQueue)
         sSQL += " messagetype = 1 ";
      else
      {
         // Messages connected to a specific account
         sSQL += _T(" messageaccountid = @MESSAGEACCOUNTID ");
         command.AddParameter("@MESSAGEACCOUNTID", account_id_); 
      }
  
      // Should we fetch a specific folder?
      if (folder_id_ != -1)
      {
         sSQL.AppendFormat(_T(" and messagefolderid = @MESSAGEFOLDERID "));
         command.AddParameter("@MESSAGEFOLDERID", folder_id_); 
      }

      // Should we do an incremental refresh?
      if (last_refreshed_uid_ > 0)
      {
         sSQL.AppendFormat(_T(" and messageuid > @MESSAGEUID "));
         command.AddParameter("@MESSAGEUID", last_refreshed_uid_); 
      }

      if (retrieveQueue)
         sSQL += " order by messageid asc";
      else
         sSQL += " order by messageuid asc";


      command.SetQueryString(sSQL);

      std::shared_ptr<DALRecordset> pRS = Application::Instance()->GetDBManager()->OpenRecordset(command);
      if (!pRS)
         return;

      AddToCollection(pRS);

     
   }
开发者ID:hmailserver,项目名称:hmailserver,代码行数:67,代码来源:Messages.cpp

示例13: ConvertMessageToMap

ECode Media_Utils::ConvertMessageToMap(
   /* [in] */ android::sp<android::AMessage>& msg,
   /* [out] */ IObjectStringMap** mymap)
{
    VALIDATE_NOT_NULL(mymap);
    *mymap = NULL;

    AutoPtr<IObjectStringMap> returnMap;
    CObjectStringMap::New( (IObjectStringMap**)&returnMap);

    for (Int32 i = 0; i < msg->countEntries(); i++) {
        android::AMessage::Type valueType;
        const char *key = msg->getEntryNameAt(i,&valueType);

        AutoPtr<IInterface> valueObj;
        switch (valueType){
            case android::AMessage::kTypeInt32: {
                Int32 val;
                msg->findInt32(key, &val);
                AutoPtr<IInteger32> value;
                CInteger32::New(val, (IInteger32**)&value);
                valueObj = value->Probe(EIID_IInterface);
                break;
            }
            case android::AMessage::kTypeInt64: {
                Int64 val;
                msg->findInt64(key, &val);
                AutoPtr<IInteger64> value;
                CInteger64::New(val, (IInteger64**)&value);
                valueObj = value->Probe(EIID_IInterface);
                break;
            }
            case android::AMessage::kTypeFloat: {
                Float val;
                msg->findFloat(key, &val);
                AutoPtr<IFloat> value;
                CFloat::New(val, (IFloat**)&value);
                valueObj = value->Probe(EIID_IInterface);
                break;
            }
            case android::AMessage::kTypeString: {
                android::AString val;
                msg->findString(key, &val);
                AutoPtr<ICharSequence> value;
                CString::New(String(val.c_str()), (ICharSequence**)&value);
                valueObj = value->Probe(EIID_IInterface);
                break;
            }
            case android::AMessage::kTypeBuffer: {
                android::sp<android::ABuffer> val;
                msg->findBuffer(key, &val);
                Int32 size = val->size();
                ArrayOf<Byte> bytes((Byte*)val->data(), size);

                AutoPtr<IByteBufferHelper> helper;
                CByteBufferHelper::AcquireSingleton((IByteBufferHelper**)&helper);
                AutoPtr<IByteBuffer> buffer;
                helper->Allocate(size, (IByteBuffer**)&buffer);
                buffer->PutBytes(bytes);
                valueObj = buffer->Probe(EIID_IInterface);
                break;
            }
            case android::AMessage::kTypeRect: {
                Int32 left, top, right, bottom;
                msg->findRect(key, &left, &top, &right, &bottom);

                AutoPtr<IInteger32> tmpInt;

                String strLeft;
                strLeft.AppendFormat("%s-left", key);
                CInteger32::New(left, (IInteger32**)&tmpInt);
                returnMap->Put(strLeft ,tmpInt->Probe(EIID_IInterface));

                String strTop;
                strLeft.AppendFormat("%s-top", key);
                tmpInt = NULL;
                CInteger32::New(top, (IInteger32**)&tmpInt);
                returnMap->Put(strTop ,tmpInt->Probe(EIID_IInterface));

                String strRight;
                strLeft.AppendFormat("%s-right", key);
                tmpInt = NULL;
                CInteger32::New(right, (IInteger32**)&tmpInt);
                returnMap->Put(strRight ,tmpInt->Probe(EIID_IInterface));

                String strBottom;
                strLeft.AppendFormat("%s-bottom", key);
                tmpInt = NULL;
                CInteger32::New(bottom, (IInteger32**)&tmpInt);
                returnMap->Put(strBottom ,tmpInt->Probe(EIID_IInterface));
                break;
            }

            default:
                break;
        }//end switch

        if (valueObj != NULL)  {
            String keyObj(key);
            returnMap->Put(keyObj ,valueObj);
//.........这里部分代码省略.........
开发者ID:TheTypoMaster,项目名称:ElastosRDK5_0,代码行数:101,代码来源:Media_Utils.cpp

示例14: testClass

ECode CInstrumentationTestRunner::WatcherResultPrinter::StartTest(
    /* [in] */ ITest* test)
{
    AutoPtr<IClassInfo> clsInfo;
    _CObject_ReflectClassInfo(test, (IClassInfo**)&clsInfo);
    StringBuf_<512> nameBuf;
    clsInfo->GetName(&nameBuf);
    String testClass((const char*)nameBuf);
    String testName;
    ITestCase::Probe(test)->GetName(&testName);
    mTestResult = NULL;
    CBundle::New(mResultTemplate, (IBundle**)&mTestResult);
    mTestResult->PutString(IInstrumentationTestRunner::REPORT_KEY_NAME_CLASS, testClass);
    mTestResult->PutString(IInstrumentationTestRunner::REPORT_KEY_NAME_TEST, testName);
    mTestResult->PutInt32(IInstrumentationTestRunner::REPORT_KEY_NUM_CURRENT, ++mTestNum);
    // pretty printing
    if (!testClass.IsNull() && !testClass.Equals(mTestClass)) {
        String formatStr;
        formatStr.AppendFormat("\n%s:", testClass.string());
        mTestResult->PutString(IInstrumentation::REPORT_KEY_STREAMRESULT,
                formatStr);
        mTestClass = testClass;
    }
    else {
        mTestResult->PutString(IInstrumentation::REPORT_KEY_STREAMRESULT, String(""));
    }

//    Method testMethod = null;
//    try {
//        testMethod = test.getClass().getMethod(testName);
//        // Report total number of iterations, if test is repetitive
//        if (testMethod.isAnnotationPresent(RepetitiveTest.class)) {
//            int numIterations = testMethod.getAnnotation(
//                RepetitiveTest.class).numIterations();
//            mTestResult.putInt(REPORT_KEY_NUM_ITERATIONS, numIterations);
//        }
//    } catch (NoSuchMethodException e) {
//        // ignore- the test with given name does not exist. Will be handled during test
//        // execution
//    }

    AutoPtr<ITestAnnotation> annotation;
    test->GetTestAnnotation((ITestAnnotation**)&annotation);
    if (annotation != NULL) {
        Int32 numIterations;
        annotation->GetNumIterations(testName, &numIterations);
        mTestResult->PutInt32(REPORT_KEY_NUM_ITERATIONS, numIterations);
    }

    // The delay_msec parameter is normally used to provide buffers of idle time
    // for power measurement purposes. To make sure there is a delay before and after
    // every test in a suite, we delay *after* every test (see endTest below) and also
    // delay *before* the first test. So, delay test1 delay test2 delay.

    // try {
    if (mTestNum == 1) {
        ECode ec = Thread::Sleep(mHost->mDelayMsec);
        if (ec == (ECode)E_INTERRUPTED_EXCEPTION) return E_ILLEGAL_STATE_EXCEPTION;
    }
    // } catch (InterruptedException e) {
    //     throw new IllegalStateException(e);
    // }

    mHost->SendStatus(IInstrumentationTestRunner::REPORT_VALUE_RESULT_START, mTestResult);
    mTestResultCode = 0;

    mIsTimedTest = FALSE;
    mIncludeDetailedStats = FALSE;
    if (annotation != NULL) {
        annotation->IsTimedTest(testName, &mIsTimedTest);
        annotation->IsIncludeDetailedStats(testName, &mIncludeDetailedStats);
    }
//    try {
//        // Look for TimedTest annotation on both test class and test method
//        if (testMethod != null && testMethod.isAnnotationPresent(TimedTest.class)) {
//            mIsTimedTest = true;
//            mIncludeDetailedStats = testMethod.getAnnotation(
//                    TimedTest.class).includeDetailedStats();
//        } else if (test.getClass().isAnnotationPresent(TimedTest.class)) {
//            mIsTimedTest = true;
//            mIncludeDetailedStats = test.getClass().getAnnotation(
//                    TimedTest.class).includeDetailedStats();
//        }
//    } catch (SecurityException e) {
//        // ignore - the test with given name cannot be accessed. Will be handled during
//        // test execution
//    }

    // TODO
    // if (mIsTimedTest && mIncludeDetailedStats) {
    //     mPerfCollector.beginSnapshot("");
    // }
    // else if (mIsTimedTest) {
    //     mPerfCollector.startTiming("");
    // }

    return NOERROR;
}
开发者ID:TheTypoMaster,项目名称:ElastosRDK5_0,代码行数:98,代码来源:CInstrumentationTestRunner.cpp

示例15: if

AutoPtr<ICharSequence> DateUtils::GetRelativeTimeSpanString(
    /* [in] */ Int64 time,
    /* [in] */ Int64 now,
    /* [in] */ Int64 minResolution,
    /* [in] */ Int32 flags)
{
    AutoPtr<IResources> r = CResources::GetSystem();
    Boolean abbrevRelative = ( (flags & (IDateUtils::FORMAT_ABBREV_RELATIVE | IDateUtils::FORMAT_ABBREV_ALL)) != 0 );

    Boolean past = (now >= time);
    Int64 duration = Elastos::Core::Math::Abs(now - time);

    Int32 resId;
    Int64 count;
    if ( (duration < IDateUtils::MINUTE_IN_MILLIS) && (minResolution < IDateUtils::MINUTE_IN_MILLIS) ) {
        count = duration / IDateUtils::SECOND_IN_MILLIS;
        if (past) {
            if (abbrevRelative) {
                resId = R::plurals::abbrev_num_seconds_ago;
            }
            else {
                resId = R::plurals::num_seconds_ago;
            }
        }
        else {
            if (abbrevRelative) {
                resId = R::plurals::abbrev_in_num_seconds;
            }
            else {
                resId = R::plurals::in_num_seconds;
            }
        }
    }
    else if ( (duration < IDateUtils::HOUR_IN_MILLIS) && (minResolution < IDateUtils::HOUR_IN_MILLIS) ) {
        count = duration / IDateUtils::MINUTE_IN_MILLIS;
        if (past) {
            if (abbrevRelative) {
                resId = R::plurals::abbrev_num_minutes_ago;
            }
            else {
                resId = R::plurals::num_minutes_ago;
            }
        }
        else {
            if (abbrevRelative) {
                resId = R::plurals::abbrev_in_num_minutes;
            }
            else {
                resId = R::plurals::in_num_minutes;
            }
        }
    }
    else if (duration < IDateUtils::DAY_IN_MILLIS && minResolution < IDateUtils::DAY_IN_MILLIS) {
        count = duration / IDateUtils::HOUR_IN_MILLIS;
        if (past) {
            if (abbrevRelative) {
                resId = R::plurals::abbrev_num_hours_ago;
            }
            else {
                resId = R::plurals::num_hours_ago;
            }
        }
        else {
            if (abbrevRelative) {
                resId = R::plurals::abbrev_in_num_hours;
            }
            else {
                resId = R::plurals::in_num_hours;
            }
        }
    }
    else if (duration < IDateUtils::WEEK_IN_MILLIS && minResolution < IDateUtils::WEEK_IN_MILLIS) {
        return GetRelativeDayString(r, time, now);
    } else {
        // We know that we won't be showing the time, so it is safe to pass
        // in a null context.
        String fdrRet = FormatDateRange(NULL, time, time, flags);
        AutoPtr<ICharSequence> cs;
        CString::New(fdrRet, (ICharSequence**)&cs);
        return cs;
    }

    String format;
    r->GetQuantityString(resId, (Int32) count, &format);

    String retVal;
    retVal.AppendFormat(format.string(), count);

    AutoPtr<ICharSequence> cs;
    CString::New(retVal, (ICharSequence**)&cs);
    return cs;
}
开发者ID:TheTypoMaster,项目名称:ElastosRDK5_0,代码行数:92,代码来源:DateUtils.cpp


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