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


C++ stringarray::iterator类代码示例

本文整理汇总了C++中stringarray::iterator的典型用法代码示例。如果您正苦于以下问题:C++ iterator类的具体用法?C++ iterator怎么用?C++ iterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: HandleAllMsgs

void Group::HandleAllMsgs( HOBJECT hSender, const CParsedMsg &crParsedMsg )
{
	char szMsgArgs[256];
	crParsedMsg.ReCreateMsg( szMsgArgs, ARRAY_LEN(szMsgArgs), 0 );

	if( !szMsgArgs[0] )
		return;
		
	for( StringArray::iterator iter = m_saObjectNames.begin(); iter != m_saObjectNames.end(); ++iter )
	{
		if( !(*iter).empty() )
		{
			const char* pszObjectName = iter->c_str();

			// This needs to be format string characters +
			// LTARRAYSIZE(szMsgArgs) + MaxObjectName characters long.
			char szMsg[10 + LTARRAYSIZE(szMsgArgs) + MAX_CS_FILENAME_LEN]; 
			LTSNPrintF(szMsg, LTARRAYSIZE(szMsg), "msg %s (%s);", pszObjectName, szMsgArgs );
			g_pCmdMgr->QueueCommand( szMsg, hSender, NULL );
		}
	}
}
开发者ID:Arc0re,项目名称:lithtech,代码行数:22,代码来源:Group.cpp

示例2: InterpretAction

//------------------------------------------------------------------------------
bool Minimize::InterpretAction()
{
   #ifdef DEBUG_MINIMIZE // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug ~~~~
      MessageInterface::ShowMessage("Interpreting Minimize command ...\n");
      MessageInterface::ShowMessage("generatingString = %s",
         generatingString.c_str());
   #endif // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ end debug ~~~~
   /// @todo: Clean up this hack for the Minimize::InterpretAction method
   // Sample string:  "Minimize myDC(Sat1.SMA = 21545.0, {Tolerance = 0.1});"
   /// @todo clean that up - because that's not even right ^^^^^
   
      // Clean out any old data
   wrapperObjectNames.clear();
   ClearWrappers();

   StringArray chunks = InterpretPreface();

   #ifdef DEBUG_MINIMIZE_PARSING
      MessageInterface::ShowMessage("Preface chunks as\n");
      for (StringArray::iterator i = chunks.begin(); i != chunks.end(); ++i)
         MessageInterface::ShowMessage("   \"%s\"\n", i->c_str());
      MessageInterface::ShowMessage("\n");
   #endif
   
   // Find and set the solver object name
   // This is the only setting in Vary that is not in a wrapper
   StringArray currentChunks = parser.Decompose(chunks[1], "()", false);
   if (!GmatStringUtil::HasNoBrackets(currentChunks.at(0), false))
      throw CommandException(
            "Solver name for Minimize command may not contain brackets, braces, or parentheses."); 
      
   SetStringParameter(OPTIMIZER_NAME, currentChunks[0]);
   if (currentChunks.size() < 2)
      throw CommandException("Missing field or value for Minimize command.");
 
    // The remaining text in the instruction is the variable definition and 
   // parameters, all contained in currentChunks[1].  Deal with those next.
   std::string cc = GmatStringUtil::Strip(currentChunks[1]);
   Integer ccEnd = cc.size() - 1;
   if ((cc.at(0) != '(') || (cc.at(ccEnd) != ')'))
      throw CommandException(
           "Missing parentheses, or unexpected characters found, around argument to Minimize command.");
   if (!GmatStringUtil::IsBracketBalanced(cc, "()"))
      throw CommandException("Parentheses unbalanced in Minimize command.");
   if ((cc.find('[') != cc.npos) || (cc.find(']') != cc.npos) ||
       (cc.find('{') != cc.npos) || (cc.find('}') != cc.npos) )
      throw CommandException("Minimize command may not contain brackets or braces.");

   std::string noSpaces     = GmatStringUtil::RemoveAll(cc,' ');
   currentChunks = parser.Decompose(noSpaces, "()", true, true);
   
   #ifdef DEBUG_MINIMIZE_PARSING
      MessageInterface::ShowMessage(
         "Minimize: after Decompose, current chunks = \n");
      for (Integer jj = 0; jj < (Integer) currentChunks.size(); jj++)
         MessageInterface::ShowMessage("   %s\n",
                                       currentChunks[jj].c_str());
   #endif

   if (currentChunks.size() == 0)
      throw CommandException("The objective function name is missing in the "
               "Minimize command\n");

   // First chunk is the objectiveName
   objectiveName = currentChunks[0];
      
   #ifdef DEBUG_MINIMIZE_PARSE // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug ~~~~
      MessageInterface::ShowMessage("Minimize::InterpretAction() exiting\n");
   #endif // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ end debug ~~~~
      
   interpreted   = true;

   return true;
}
开发者ID:rockstorm101,项目名称:GMAT,代码行数:75,代码来源:Minimize.cpp

示例3: Create

//------------------------------------------------------------------------------
// void Create()
//------------------------------------------------------------------------------
void TargetPanel::Create()
{    
   Integer bsize = 5;

   //-------------------------------------------------------
   // Solver ComboBox
   //-------------------------------------------------------
   wxStaticText *solverNameStaticText =
      new wxStaticText(this, ID_TEXT, wxT("Solver Name"), wxDefaultPosition,
                       wxDefaultSize, 0);
   
   wxStaticText *solverModeStaticText =
      new wxStaticText(this, ID_TEXT, wxT("Solver Mode"), wxDefaultPosition,
                       wxDefaultSize, 0);
   
   wxStaticText *exitModeStaticText =
      new wxStaticText(this, ID_TEXT, wxT("Exit Mode"), wxDefaultPosition,
                       wxDefaultSize, 0);
   
   mSolverComboBox =
      theGuiManager->GetBoundarySolverComboBox(this, ID_COMBO, wxSize(180,-1));
   
   StringArray options = theCommand->GetStringArrayParameter("SolveModeOptions");
   wxArrayString theOptions;
   
   for (StringArray::iterator i = options.begin(); i != options.end(); ++i)
      theOptions.Add(i->c_str());
   
   mSolverModeComboBox =
      new wxComboBox(this, ID_COMBO, wxT(""), wxDefaultPosition, wxSize(180,-1),
                     theOptions, wxCB_READONLY);

   options = theCommand->GetStringArrayParameter("ExitModeOptions");
   theOptions.Clear();
   
   for (StringArray::iterator i = options.begin(); i != options.end(); ++i)
      theOptions.Add(i->c_str());
   
   mExitModeComboBox = 
      new wxComboBox(this, ID_COMBO, wxT(""), wxDefaultPosition, wxSize(180,-1),
            theOptions, wxCB_READONLY);;
   
   //----------------------------------------------------------------------
   // ShowProgressWindow flag
   //----------------------------------------------------------------------
   mProgressWindowCheckBox =
      new wxCheckBox(this, ID_PROGRESS_CHECKBOX, gmatwxT(GUI_ACCEL_KEY"Show Progress Window"),
      wxDefaultPosition, wxDefaultSize);
   mProgressWindowCheckBox->SetToolTip(_T("Show Progress Window during targeting"));

   mApplyCorrectionsButton = new wxButton(this, ID_APPLYBUTTON, 
         wxT("Apply Corrections"));
   
   
   wxFlexGridSizer *pageSizer = new wxFlexGridSizer(2);
   
   pageSizer->Add(solverNameStaticText, 0, wxALIGN_CENTER|wxALL, bsize);
   pageSizer->Add(mSolverComboBox, 0, wxALIGN_CENTER|wxALL, bsize);

   pageSizer->Add(solverModeStaticText, 0, wxALIGN_CENTER|wxALL, bsize);
   pageSizer->Add(mSolverModeComboBox, 0, wxALIGN_CENTER|wxALL, bsize);

   pageSizer->Add(exitModeStaticText, 0, wxALIGN_CENTER|wxALL, bsize);
   pageSizer->Add(mExitModeComboBox, 0, wxALIGN_CENTER|wxALL, bsize);
//   pageSizer->Add(NULL, 0, wxALIGN_CENTER|wxALL, bsize);
   pageSizer->Add(20,20);
   pageSizer->Add(mProgressWindowCheckBox, 0, wxALIGN_LEFT|wxALL, bsize);
   pageSizer->Add(mApplyCorrectionsButton, 0, wxALIGN_CENTER|wxALL, bsize);

   theMiddleSizer->Add(pageSizer, 0, wxGROW, bsize);
}
开发者ID:rockstorm101,项目名称:GMAT,代码行数:74,代码来源:TargetPanel.cpp

示例4: InterpretAction

//------------------------------------------------------------------------------
bool Set::InterpretAction()
{
   #ifdef DEBUG_PARSING
      MessageInterface::ShowMessage("%s::InterpretAction for \"%s\" entered, "
         "type = %s\n", typeName.c_str(), generatingString.c_str(), 
         typeName.c_str());
   #endif

   std::string mainString = generatingString;

   // Remove trailing semicolons
   // Note: Cannot use UnsignedInt here because return is really a size_t
   size_t loc = mainString.find_last_of(';');
   while (loc != std::string::npos)
   {
      #ifdef DEBUG_PARSING
         MessageInterface::ShowMessage("Went from '%s' to ",
               mainString.c_str());
      #endif
      mainString = mainString.substr(0, loc);
      #ifdef DEBUG_PARSING
         MessageInterface::ShowMessage("'%s'\n", mainString.c_str());
      #endif
      loc = mainString.find_last_of(';');
   }

   StringArray blocks = parser.DecomposeBlock(mainString);

   #ifdef DEBUG_PARSING
      MessageInterface::ShowMessage("Top level blocks from \"%s\":\n",
            generatingString.c_str());
      for (StringArray::iterator i = blocks.begin(); i != blocks.end(); ++i)
         MessageInterface::ShowMessage("   \"%s\"\n", i->c_str());
   #endif

   // Check for paren matching
   loc = blocks[0].find('(');
   if (loc != std::string::npos)
   {
      size_t loc2 = blocks[0].find('(', loc+1);
      if (loc2 != std::string::npos)
      {
         throw CommandException("Too many opening parens in the Set command");
      }

      loc2 = blocks[0].find(')');
      if (loc2 == std::string::npos)
      {
         throw CommandException("Missing closing parens in the Set command");
      }

      if (loc > loc2)
      {
         throw CommandException("Closing paren found before opening paren in the Set command");
      }

      size_t loc3 = blocks[0].find(')', loc2+1);
      if (loc3 != std::string::npos)
      {
         throw CommandException("Too many closing parens in the Set command");
      }

   }

   StringArray chunks = parser.SeparateBy(blocks[0], "()");

   #ifdef DEBUG_PARSING
      MessageInterface::ShowMessage("Chunks from block \"%s\":\n",
            blocks[0].c_str());
      for (StringArray::iterator i = chunks.begin(); i != chunks.end(); ++i)
         MessageInterface::ShowMessage("   \"%s\"\n", i->c_str());
   #endif

   StringArray subchunks = parser.SeparateBy(chunks[0], " ");
   if (subchunks.size() < 3)
      throw CommandException(typeName + "::InterpretAction() cannot identify "
            "either the target or the data source -- is one missing? -- in "
            "line\n" + generatingString);
   if (subchunks.size() > 3)
      throw CommandException(typeName + "::InterpretAction() has too many "
               "component strings in the line\n" + generatingString);

   // Parse the main part of the command
   if (subchunks[0] != typeName)
      throw CommandException(typeName + "::InterpretAction() does not identify "
            "the correct command type in line\n" + generatingString);
   targetName = subchunks[1];
   interfaceName = subchunks[2];

   #ifdef DEBUG_PARSING
      MessageInterface::ShowMessage("Identified the target \"%s\" and the "
         "data source \"%s\"\n", targetName.c_str(), interfaceName.c_str());
   #endif

   if (chunks.size() > 2)
      throw CommandException(typeName +
            "::InterpretAction() found too many components to parse in the "
            "line\n" + generatingString);

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


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