コード例 #1
0
ファイル: commandline_processing.C プロジェクト: Sciumo/rose
Rose_STL_Container<string>
CommandlineProcessing::generateOptionWithNameParameterList ( Rose_STL_Container<string> & argList, string inputPrefix , string newPrefix )
   {
  // This function returns a list of options using the inputPrefix (with the 
  // inputPrefix stripped off and replaced if new Prefix is provided.
  // It also modified the input argList to remove matched options.

     Rose_STL_Container<string> optionList;
     Rose_STL_Container<string> deleteList;
     int prefixLength = inputPrefix.length();
     Rose_STL_Container<string>::iterator it = argList.begin();
     while (it != argList.end())
        {
         if ( it->substr(0,prefixLength) == inputPrefix )
            {
           // get the rest of the string as the option
              optionList.push_back( (newPrefix == "") ? it->substr(prefixLength) : newPrefix + it->substr(prefixLength));
              it = argList.erase(it);
           // That sounds real buggy as to detect if an option has parameters it
           // assumes inputPrefix-ed options are consecutive.
              if ( it->substr(0,prefixLength) != inputPrefix )
                 {
                   optionList.push_back(*it);
                   it = argList.erase(it);
                 }
                else
                 {
                   printf ("Error: missing parameter in option with parameter \n");
                   ROSE_ABORT();
                 }
            } else {
                ++it;
            }
        }

     return optionList;
   }
コード例 #2
0
Rose_STL_Container<string>
CommandlineProcessing::generateOptionList ( Rose_STL_Container<string> & argList, string inputPrefix )
   {
  // This function returns a list of options using the inputPrefix (with the 
  // inputPrefix stripped off). It also modified the input argList to remove
  // those options from the argList returned by reference (modified).

  // printf ("Input argList = \n%s \n",StringUtility::listToString(argList).c_str());

     Rose_STL_Container<string> optionList;
  // Rose_STL_Container<string> deleteList;
     unsigned int prefixLength = inputPrefix.length();
     for (Rose_STL_Container<string>::iterator i = argList.begin(); i != argList.end(); i++)
        {
          if ( (*i).substr(0,prefixLength) == inputPrefix )
             {
            // get the rest of the string as the option
               optionList.push_back((*i).substr(prefixLength));

            // keep track of elements so that they can be deleted later (after exit from loop over the eleents)
            // deleteList.push_back(*i);
             }
        }
#if 0
  // remove the elements identified in the previous loop
     for (Rose_STL_Container<string>::iterator i = deleteList.begin(); i != deleteList.end(); i++)
        {
       // DQ (9/25/2007): Moved to use of std::vector instead of std::list
       // argList.remove(*i);
          argList.erase(i);
        }
#else
  // DQ (9/25/2007): Moved to use of std::vector instead of std::list
  // argList.erase(deleteList.begin(),deleteList.end());
  // argList.clear();
#endif

  // printf ("return value: optionList = \n%s \n",StringUtility::listToString(optionList).c_str());

     return optionList;
   }
コード例 #3
0
Rose_STL_Container<string>
CommandlineProcessing::generateOptionWithNameParameterList ( Rose_STL_Container<string> & argList, string inputPrefix , string newPrefix )
   {
  // This function returns a list of options using the inputPrefix (with the
  // inputPrefix stripped off and replaced if new Prefix is provided.
  // It also modified the input argList to remove matched options.

     Rose_STL_Container<string> optionList;
     Rose_STL_Container<string> deleteList;
     int prefixLength = inputPrefix.length();
     Rose_STL_Container<string>::iterator it = argList.begin();
     while (it != argList.end())
        {
         if ( it->substr(0,prefixLength) == inputPrefix )
            {
           // get the rest of the string as the option
              optionList.push_back( (newPrefix == "") ? it->substr(prefixLength) : newPrefix + it->substr(prefixLength));
              it = argList.erase(it);

           // That sounds real buggy as to detect if an option has parameters it
           // assumes inputPrefix-ed options are consecutive.
              if ( it->substr(0,prefixLength) != inputPrefix )
                 {
                   optionList.push_back(*it);
                   it = argList.erase(it);

#if 0
                // DQ (1/25/2017): Comment this out as a test of C file command line generation to EDG.

                // DQ (1/21/2017): Adding support for options taking more than one paramter.
                   if (isOptionTakingThirdParameter(inputPrefix) == true)
                      {
                        if ( it->substr(0,prefixLength) != inputPrefix )
                           {
                             optionList.push_back(*it);
                             it = argList.erase(it);
                           }
                          else
                           {
                             printf ("Error: missing 2nd parameter in option with two parameters \n");
                             ROSE_ABORT();
                           }
#if 0
                        printf ("Need to handle options taking more than one parameter (e.g. --edg_parameter:): inputPrefix = %s \n",inputPrefix.c_str());
                        ROSE_ASSERT(false);
#endif
                      }
#endif
                 }
                else
                 {
                   printf ("Error: missing parameter in option with parameter \n");
                   ROSE_ABORT();
                 }
            } else {
                ++it;
            }
        }

     return optionList;
   }