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


C++ DayTime::setToString方法代码示例

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


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

示例1: checkArguments

   string CommandOptionWithTimeArg :: checkArguments()
   {
      string errstr = CommandOptionWithAnyArg::checkArguments();

      if (errstr != string())
         return errstr;

      vector<string>::size_type vecindex;
      for(vecindex = 0; vecindex < value.size(); vecindex++)
      {
         string thisTimeSpec = getTimeSpec(vecindex);
         if (thisTimeSpec != string())
         {
            try {
               DayTime dt;
               dt.setToString(value[vecindex], thisTimeSpec);
               times.push_back(dt);
            }
            catch (...)
            {
               errstr += "\"" + value[vecindex] + "\" is not a valid time.";
            }
         }
         else
            errstr += "\"" + value[vecindex] + "\" is not a valid time.";
      }

      return errstr;
   }
开发者ID:ianmartin,项目名称:GPSTk,代码行数:29,代码来源:CommandOptionWithTimeArg.cpp

示例2: main

/// returns 0 if all tests pass
int main()
{
   using gpstk::DayTime;
   
   try
   {
      cout << "BOT:" << DayTime(gpstk::DayTime::BEGINNING_OF_TIME) << endl;
      cout << "EOT:" << DayTime(gpstk::DayTime::END_OF_TIME) << endl;
     
      DayTime dt;
      dt.setSystemTime();
      cout << "Check that the output matches the current UTC time." << endl
           << "string                         printf()" << endl;

      dtft(cout, dt, "mjd:  %Q (%.0Q)");
      dtft(cout, dt, "mjd:  %5.3Q");
      dtft(cout, dt, "mdy:  %02m/%02d/%04Y");
      dtft(cout, dt, "hms:  %02H:%02M:%02S");
      dtft(cout, dt, "hms:  %02H:%02M:%06.3f");
      dtft(cout, dt, "cal:  %A, %B %d, %Y");
      dtft(cout, dt, "week: %F(%G)");
      dtft(cout, dt, "sow:  %g");
      dtft(cout, dt, "sow:  %06.3g");
      dtft(cout, dt, "doy:  %j:%s");
      dtft(cout, dt, "dow:  %w");
      dtft(cout, dt, "z:    %Z (%z)");
      dtft(cout, dt, "unix: %U.%06u");

      cout << endl
           << "The following functions use DayTime::setToString()" << endl;

      string format = "%02m/%02d/%04Y %02H:%02M:%02S";
      string st = dt.printf(format);

      DayTime q;
      q.setToString(st, format);
      dtft(cout, q, format);

      cout << "Tests complete." << endl;
      return 0;
   }
   catch(gpstk::Exception& e)
   {
      cout << e << endl;
   }
   catch(...)
   {
      cout << "Some other exception thrown..." << endl;
   }

   cout << "Exiting with exceptions." << endl;
   return -1;
}
开发者ID:ianmartin,项目名称:GPSTk,代码行数:54,代码来源:daytimetest.cpp

示例3: parseDate

gpstk::DayTime ConstellationSet::parseDate(string date)
  throw(InvalidDateString)
{
   string whitespace = " \t\r\n";
   string::size_type end  = date.find_last_not_of(whitespace);
   string::size_type front = date.find("STATUS");
   front = date.find_first_not_of(whitespace, front+6);
   string dateString = date.substr(front, end-front+1);
   DayTime dt;
   try
   {
      //cout << dateString << endl;
      dt.setToString(dateString, "%d %b %Y");
      dt.setSecOfDay(  (DayTime::SEC_DAY/2) );
      return dt;
   }
   catch(DayTime::DayTimeException exc)
   {
      string s = "Invalid date: '" + dateString + "'";
      //cout << s << endl;
      ConstellationSet::InvalidDateString excids(s);
      GPSTK_THROW(excids);
   }
}
开发者ID:ianmartin,项目名称:GPSTk,代码行数:24,代码来源:ConstellationSet.cpp

示例4: addFile


//.........这里部分代码省略.........
               {
                  readFailCount++;
                  string failString = buildFailString(
                     "PRN ID out of range",
                     lineCount,
                     filename);
                  readFailList.push_back( failString );
                  continue;
               }
               temps = lineIn.substr((c1+1),(c2-c1-1));
               string::size_type nonWhiteBeg = temps.find_first_not_of(whiteSpace);
               string::size_type nonWhiteEnd = temps.find_last_not_of(whiteSpace);
               //cout << "Before trimming.  temps, Beg, End = '" << temps << "', " << nonWhiteBeg << ", " << nonWhiteEnd << "." << endl;
               if (nonWhiteEnd!=string::npos)
                   temps = temps.substr(nonWhiteBeg,nonWhiteEnd-nonWhiteBeg+1);
               else
                   temps = temps.substr(nonWhiteBeg);
               
               //cout << "c3, string::npos = " << c3 << ", " << string::npos << endl;
               if (c3!=string::npos)
               {
                  tempe = lineIn.substr(c2+1, (c3-c2-1) );
                  comment = lineIn.substr(c3+1);
                  nonWhiteBeg = comment.find_first_not_of(whiteSpace);
                  comment = comment.substr(nonWhiteBeg);
               }
               else
                  tempe = lineIn.substr(c2+1);

               nonWhiteBeg = tempe.find_first_not_of(whiteSpace);
               nonWhiteEnd = tempe.find_last_not_of(whiteSpace);
               //cout << "Before trimming.  tempe, Beg, End = '" << tempe << "', " << nonWhiteBeg << ", " << nonWhiteEnd << "." << endl;
               if (nonWhiteEnd!=string::npos)
                   tempe = tempe.substr(nonWhiteBeg,nonWhiteEnd-nonWhiteBeg+1);
               else
                   tempe = tempe.substr(nonWhiteBeg);
               try
               {
                  //cout << "Input start string: '" << temps << "'." << endl;
                  tempDTs.setToString( temps, timeSpecString );
                  //cout << "Input   end string: '" << tempe << "'." << endl;
                  tempDTe.setToString( tempe, timeSpecString );
                  if (tempDTs<=tempDTe)
                  {
                     SVExclusion svEx( tempDTs, tempDTe, PRNID, comment );
       
                        // Add exclusion to the multimap
                     addExclusion( svEx );
                  }
                  else
                  {
                     readFailCount++;
                     string failString = buildFailString(
                        "Start time after end time",
                        lineCount,
                        filename);
                     readFailList.push_back( failString );
                  }
               }
               catch (DayTime::DayTimeException& dte)
               {
                  readFailCount++;
                  string failString = buildFailString(
                     dte.getText(),
                     lineCount,
                     filename);
                  readFailList.push_back( failString );
               }
               catch (DayTime::FormatException& fe) 
               {
                  readFailCount++;
                  string failString = buildFailString(
                     fe.getText(),
                     lineCount,
                     filename);
                  readFailList.push_back( failString );
               }
               catch (gpstk::StringUtils::StringException& se)
               {
                  readFailCount++;
                  string failString = buildFailString(
                     se.getText(),
                     lineCount,
                     filename);
                     readFailList.push_back( failString );
               }
            }
            else
            {
               readFailCount++;
               string failString = buildFailString(
                  "Invalid EX line format at",
                  lineCount,
                  filename);
               readFailList.push_back( failString );
            }
         }
      }
      fclose(inf);
   }
开发者ID:ianmartin,项目名称:GPSTk,代码行数:101,代码来源:SVExclusionList.cpp


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