ROSE  0.9.9.109
commandline_processing.h
1 #ifndef ROSE_COMMANDLINE_UTILITY_H
2 #define ROSE_COMMANDLINE_UTILITY_H
3 #include "setup.h"
4 //#include "rosedefs.h"
5 #include "rosedll.h"
6 #include <list>
7 #define Rose_STL_Container std::vector
8 #include <Sawyer/CommandLine.h>
9 
10 //Rama (12/22/2006): changing the class to a namespace and removing the "static"ness of the "member" functions
13  {
22  ROSE_UTIL_API Sawyer::CommandLine::Parser createEmptyParser(const std::string &purpose,
23  const std::string &description);
24 
38  ROSE_UTIL_API Sawyer::CommandLine::Parser createEmptyParserStage(const std::string &purpose,
39  const std::string &description);
66 
71  unsigned int threads;
75  : threads(0) {}
76  };
77 
83  ROSE_UTIL_API extern GenericSwitchArgs genericSwitchArgs;
84 
94  ROSE_UTIL_API void insertBooleanSwitch(Sawyer::CommandLine::SwitchGroup&, const std::string &switchName,
95  bool &storageLocation, const std::string &documentation);
96 
98  ROSE_UTIL_API Rose_STL_Container<std::string> generateArgListFromString ( std::string commandline );
99 
101  // std::string generateStringFromArgList( Rose_STL_Container<std::string> & argList);
102  ROSE_UTIL_API std::string generateStringFromArgList( const Rose_STL_Container<std::string> & argList);
103 
105  ROSE_UTIL_API Rose_STL_Container<std::string> generateArgListFromArgcArgv ( int argc, const char* argv[] );
106 
107  inline Rose_STL_Container<std::string> generateArgListFromArgcArgv ( int argc, char* argv[] )
108  {return generateArgListFromArgcArgv(argc, (const char**)argv);}
109 
111  ROSE_UTIL_API void generateArgcArgvFromList ( Rose_STL_Container<std::string> argList, int & argc, char** & argv );
112 
115  ROSE_UTIL_API Rose_STL_Container<std::string> generateOptionList (const Rose_STL_Container<std::string> & argList, std::string inputPrefix );
116 
119  ROSE_UTIL_API Rose_STL_Container<std::string> generateOptionListWithDeclaredParameters (const Rose_STL_Container<std::string> & argList, std::string inputPrefix );
120 
124  ROSE_UTIL_API Rose_STL_Container<std::string> generateOptionWithNameParameterList ( Rose_STL_Container<std::string> & argList, std::string inputPrefix, std::string newPrefix = "");
125 
126  extern Rose_STL_Container<std::string> extraCppSourceFileSuffixes;
127 
129 
134  ROSE_UTIL_API bool isOption ( std::vector<std::string> & argv, std::string optionPrefix, std::string Option, bool removeOption );
135 
138  ROSE_UTIL_API bool isOptionWithParameter ( std::vector<std::string> & argv, std::string optionPrefix, std::string Option, int & optionParameter, bool removeOption );
139 
141  ROSE_UTIL_API bool isOptionWithParameter ( std::vector<std::string> & argv, std::string optionPrefix, std::string Option, float & optionParameter, bool removeOption );
142 
144  ROSE_DLL_API bool isOptionWithParameter ( std::vector<std::string> & argv, std::string optionPrefix, std::string Option, std::string & optionParameter, bool removeOption );
145 
147  ROSE_UTIL_API void addListToCommandLine ( std::vector<std::string> & argv , std::string prefix, Rose_STL_Container<std::string> argList );
149  ROSE_UTIL_API void removeArgs ( std::vector<std::string> & argv, std::string prefix );
151  ROSE_UTIL_API void removeArgsWithParameters ( std::vector<std::string> & argv, std::string prefix );
153  ROSE_UTIL_API void removeAllFileNamesExcept ( std::vector<std::string> & argv, Rose_STL_Container<std::string> filenameList, std::string exceptFilename );
154 
156  ROSE_UTIL_API std::string generateStringFromArgList ( Rose_STL_Container<std::string> argList, bool skipInitialEntry, bool skipSourceFiles );
157 
159  ROSE_DLL_API Rose_STL_Container<std::string> generateSourceFilenames ( Rose_STL_Container<std::string> argList, bool binaryMode );
160 
161  // DQ and PC (6/1/2006): Added Peter's suggested fixes to support auto-documentation.
163  ROSE_UTIL_API void addSourceFileSuffix ( const std::string &suffix );
164  ROSE_UTIL_API void addCppSourceFileSuffix ( const std::string &suffix );
165 
166  ROSE_UTIL_API bool isSourceFilename ( std::string name );
167 
168  ROSE_UTIL_API bool isObjectFilename ( std::string name );
169  ROSE_DLL_API bool isExecutableFilename ( std::string name );
170 
171  // DQ (8/20/2008): Added test that will allow bogus exececutable files (marked as .exe but not executable) to pass
172  ROSE_DLL_API bool isValidFileWithExecutableFileSuffixes ( std::string name );
173 
174  ROSE_UTIL_API bool isCFileNameSuffix ( const std::string & suffix );
175 
176  // Liao (6/6/2008): Added support for UPC file suffix name
177  ROSE_UTIL_API bool isUPCFileNameSuffix ( const std::string & suffix );
178 
179  ROSE_UTIL_API bool isCppFileNameSuffix ( const std::string & suffix );
180 
181  // DQ (8/7/2007): Added support for Fortran file suffix names.
182  ROSE_UTIL_API bool isFortranFileNameSuffix ( const std::string & suffix );
183 
184  // DQ (5/18/2008): Support to marking when C preprocessing is required for
185  // Fortran files, default is true for C and C++.
186  ROSE_UTIL_API bool isFortranFileNameSuffixRequiringCPP ( const std::string & suffix );
187 
188  // DQ (11/17/2007): Added fortran mode specific suffix checking
189  ROSE_UTIL_API bool isFortran77FileNameSuffix ( const std::string & suffix );
190  ROSE_UTIL_API bool isFortran90FileNameSuffix ( const std::string & suffix );
191  ROSE_UTIL_API bool isFortran95FileNameSuffix ( const std::string & suffix );
192  ROSE_UTIL_API bool isFortran2003FileNameSuffix ( const std::string & suffix );
193  ROSE_UTIL_API bool isFortran2008FileNameSuffix ( const std::string & suffix );
194 
195  // DQ (1/23/2009): Added support for Co-Array Fortran file extension.
196  ROSE_UTIL_API bool isCoArrayFortranFileNameSuffix ( const std::string & suffix );
197 
198  ROSE_UTIL_API bool isPHPFileNameSuffix ( const std::string & suffix );
199 
200  ROSE_UTIL_API bool isPythonFileNameSuffix ( const std::string & suffix );
201 
202  // TV (05/17/2010) Support for CUDA
203  ROSE_UTIL_API bool isCudaFileNameSuffix ( const std::string & suffix );
204  // TV (05/17/2010) Support for OpenCL
205  ROSE_UTIL_API bool isOpenCLFileNameSuffix ( const std::string & suffix );
206 
207  // DQ (10/11/2010): Adding Java support.
208  ROSE_UTIL_API bool isJavaFileNameSuffix ( const std::string & suffix );
209  ROSE_UTIL_API bool isX10FileNameSuffix (const std::string& suffix);
210 
211  ROSE_UTIL_API void initSourceFileSuffixList();
212  static Rose_STL_Container<std::string> validSourceFileSuffixes;
213 
214  ROSE_UTIL_API void initObjectFileSuffixList();
215  static Rose_STL_Container<std::string> validObjectFileSuffixes;
216 
217  ROSE_DLL_API void initExecutableFileSuffixList();
218  static Rose_STL_Container<std::string> validExecutableFileSuffixes;
219 
220  // bool isOptionTakingFileName( std::string argument );
221  ROSE_DLL_API bool isOptionTakingSecondParameter( std::string argument );
222  ROSE_DLL_API bool isOptionTakingThirdParameter ( std::string argument );
223  };
224 
225 // DQ (4/5/2010): This are defined in sage_support.cpp
230 ROSE_DLL_API std::string
231 findRoseSupportPathFromSource(const std::string& sourceTreeLocation,
232  const std::string& installTreeLocation);
233 
234 // DQ (4/5/2010): This are defined in sage_support.cpp
239 ROSE_DLL_API std::string
240 findRoseSupportPathFromBuild(const std::string& buildTreeLocation,
241  const std::string& installTreeLocation);
242 
243 // DQ (4/5/2010): This are defined in sage_support.cpp
250 ROSE_DLL_API bool
251 roseInstallPrefix(std::string& result);
252 
253 // endif associated with define ROSE_COMMANDLINE_UTILITY_H
254 #endif
ROSE_UTIL_API std::vector< std::string > generateOptionListWithDeclaredParameters(const std::vector< std::string > &argList, std::string inputPrefix)
Looks for inputPrefix-prefixed options.
ROSE_DLL_API std::vector< std::string > generateSourceFilenames(std::vector< std::string > argList, bool binaryMode)
Build the list of isolated file names from the command line.
ROSE_UTIL_API std::vector< std::string > generateOptionList(const std::vector< std::string > &argList, std::string inputPrefix)
Looks for inputPrefix prefixed options.
ROSE_UTIL_API void insertBooleanSwitch(Sawyer::CommandLine::SwitchGroup &, const std::string &switchName, bool &storageLocation, const std::string &documentation)
Convenience for for adding Boolean switches.
ROSE_UTIL_API bool isOption(std::vector< std::string > &argv, std::string optionPrefix, std::string Option, bool removeOption)
Search 'argv' for an option like optionPrefixOption, remove the option if 'removeOption' is true...
ROSE_UTIL_API Sawyer::CommandLine::SwitchGroup genericSwitches()
Generic command-line components.
A collection of related switch declarations.
Definition: CommandLine.h:2488
ROSE_UTIL_API std::vector< std::string > generateOptionWithNameParameterList(std::vector< std::string > &argList, std::string inputPrefix, std::string newPrefix="")
Find all options matching 'inputPrefix:optionName' || 'inputPrefix:optionName optionValue' from argLi...
ROSE_UTIL_API GenericSwitchArgs genericSwitchArgs
Global location for parsed generic command-line switches.
ROSE_UTIL_API void removeArgsWithParameters(std::vector< std::string > &argv, std::string prefix)
Remove all options matching a specified prefix 'prefix' from the argument list 'argv', as well as the option values following them.
ROSE_UTIL_API Sawyer::CommandLine::Parser createEmptyParserStage(const std::string &purpose, const std::string &description)
Empty command-line parser suitable for use with other parsers.
unsigned int threads
Number of threads analyses should use.
ROSE_UTIL_API void removeAllFileNamesExcept(std::vector< std::string > &argv, std::vector< std::string > filenameList, std::string exceptFilename)
Remove file names specified in filenameList from argv, except for 'exceptFilename'.
Command line processing utility functions.
ROSE_UTIL_API std::vector< std::string > generateArgListFromString(std::string commandline)
Separate a string into individual parameters and store them into a string vector. ...
The parser for a program command line.
Definition: CommandLine.h:2674
ROSE_UTIL_API void generateArgcArgvFromList(std::vector< std::string > argList, int &argc, char **&argv)
Convert a string vector back to an argc-argv pair.
ROSE_UTIL_API void addListToCommandLine(std::vector< std::string > &argv, std::string prefix, std::vector< std::string > argList)
Add the strings in argList to the command line represented by argc and argv, prepend 'prefix' to each...
ROSE_UTIL_API std::string generateStringFromArgList(const std::vector< std::string > &argList)
Convert a vector of string to a single string.
ROSE_UTIL_API void addSourceFileSuffix(const std::string &suffix)
Add another valid source file suffix.
ROSE_UTIL_API std::vector< std::string > generateArgListFromArgcArgv(int argc, const char *argv[])
Convert an argc-argv pair into a string vector.
ROSE_UTIL_API Sawyer::CommandLine::Parser createEmptyParser(const std::string &purpose, const std::string &description)
Empty command-line parser.
ROSE_UTIL_API void removeArgs(std::vector< std::string > &argv, std::string prefix)
Remove all options matching a specified prefix 'prefix' from the argument list 'argv'.
ROSE_UTIL_API bool isOptionWithParameter(std::vector< std::string > &argv, std::string optionPrefix, std::string Option, int &optionParameter, bool removeOption)
Search 'argv' for 'optionPrefixOption value', store the integer value into 'optionParameter'.
Type for storing generic switch arguments.