ROSE  0.9.10.69
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 
9 //Rama (12/22/2006): changing the class to a namespace and removing the "static"ness of the "member" functions
11 // therefore are unable to call other functions in the ROSE library. See also, Rose::CommandLine for higher-level functions.
13  {
15  ROSE_UTIL_API Rose_STL_Container<std::string> generateArgListFromString ( std::string commandline );
16 
18  // std::string generateStringFromArgList( Rose_STL_Container<std::string> & argList);
19  ROSE_UTIL_API std::string generateStringFromArgList( const Rose_STL_Container<std::string> & argList);
20 
22  ROSE_UTIL_API Rose_STL_Container<std::string> generateArgListFromArgcArgv ( int argc, const char* argv[] );
23 
24  inline Rose_STL_Container<std::string> generateArgListFromArgcArgv ( int argc, char* argv[] )
25  {return generateArgListFromArgcArgv(argc, (const char**)argv);}
26 
28  ROSE_UTIL_API void generateArgcArgvFromList ( Rose_STL_Container<std::string> argList, int & argc, char** & argv );
29 
32  ROSE_UTIL_API Rose_STL_Container<std::string> generateOptionList (const Rose_STL_Container<std::string> & argList, std::string inputPrefix );
33 
36  ROSE_UTIL_API Rose_STL_Container<std::string> generateOptionListWithDeclaredParameters (const Rose_STL_Container<std::string> & argList, std::string inputPrefix );
37 
41  ROSE_UTIL_API Rose_STL_Container<std::string> generateOptionWithNameParameterList ( Rose_STL_Container<std::string> & argList, std::string inputPrefix, std::string newPrefix = "");
42 
43  extern Rose_STL_Container<std::string> extraCppSourceFileSuffixes;
44 
46 
51  ROSE_UTIL_API bool isOption ( std::vector<std::string> & argv, std::string optionPrefix, std::string Option, bool removeOption );
52 
55  ROSE_UTIL_API bool isOptionWithParameter ( std::vector<std::string> & argv, std::string optionPrefix, std::string Option, int & optionParameter, bool removeOption );
56 
58  ROSE_UTIL_API bool isOptionWithParameter ( std::vector<std::string> & argv, std::string optionPrefix, std::string Option, float & optionParameter, bool removeOption );
59 
61  ROSE_DLL_API bool isOptionWithParameter ( std::vector<std::string> & argv, std::string optionPrefix, std::string Option, std::string & optionParameter, bool removeOption );
62 
64  ROSE_UTIL_API void addListToCommandLine ( std::vector<std::string> & argv , std::string prefix, Rose_STL_Container<std::string> argList );
66  ROSE_UTIL_API void removeArgs ( std::vector<std::string> & argv, std::string prefix );
68  ROSE_UTIL_API void removeArgsWithParameters ( std::vector<std::string> & argv, std::string prefix );
70  ROSE_UTIL_API void removeAllFileNamesExcept ( std::vector<std::string> & argv, Rose_STL_Container<std::string> filenameList, std::string exceptFilename );
71 
73  ROSE_UTIL_API std::string generateStringFromArgList ( Rose_STL_Container<std::string> argList, bool skipInitialEntry, bool skipSourceFiles );
74 
76  ROSE_DLL_API Rose_STL_Container<std::string> generateSourceFilenames ( Rose_STL_Container<std::string> argList, bool binaryMode );
77 
78  // DQ and PC (6/1/2006): Added Peter's suggested fixes to support auto-documentation.
80  ROSE_UTIL_API void addSourceFileSuffix ( const std::string &suffix );
81  ROSE_UTIL_API void addCppSourceFileSuffix ( const std::string &suffix );
82 
83  ROSE_UTIL_API bool isSourceFilename ( std::string name );
84 
85  ROSE_UTIL_API bool isObjectFilename ( std::string name );
86  ROSE_DLL_API bool isExecutableFilename ( std::string name );
87 
88  // DQ (8/20/2008): Added test that will allow bogus exececutable files (marked as .exe but not executable) to pass
89  ROSE_DLL_API bool isValidFileWithExecutableFileSuffixes ( std::string name );
90 
91  ROSE_UTIL_API bool isCFileNameSuffix ( const std::string & suffix );
92 
93  // Liao (6/6/2008): Added support for UPC file suffix name
94  ROSE_UTIL_API bool isUPCFileNameSuffix ( const std::string & suffix );
95 
96  ROSE_UTIL_API bool isCppFileNameSuffix ( const std::string & suffix );
97 
98  // DQ (8/7/2007): Added support for Fortran file suffix names.
99  ROSE_UTIL_API bool isFortranFileNameSuffix ( const std::string & suffix );
100 
101  // DQ (5/18/2008): Support to marking when C preprocessing is required for
102  // Fortran files, default is true for C and C++.
103  ROSE_UTIL_API bool isFortranFileNameSuffixRequiringCPP ( const std::string & suffix );
104 
105  // DQ (11/17/2007): Added fortran mode specific suffix checking
106  ROSE_UTIL_API bool isFortran77FileNameSuffix ( const std::string & suffix );
107  ROSE_UTIL_API bool isFortran90FileNameSuffix ( const std::string & suffix );
108  ROSE_UTIL_API bool isFortran95FileNameSuffix ( const std::string & suffix );
109  ROSE_UTIL_API bool isFortran2003FileNameSuffix ( const std::string & suffix );
110  ROSE_UTIL_API bool isFortran2008FileNameSuffix ( const std::string & suffix );
111 
112  // DQ (1/23/2009): Added support for Co-Array Fortran file extension.
113  ROSE_UTIL_API bool isCoArrayFortranFileNameSuffix ( const std::string & suffix );
114 
115  ROSE_UTIL_API bool isPHPFileNameSuffix ( const std::string & suffix );
116 
117  ROSE_UTIL_API bool isPythonFileNameSuffix ( const std::string & suffix );
118 
119  // DQ (28/8/2017): Adding language support.
120  ROSE_UTIL_API bool isCsharpFileNameSuffix ( const std::string & suffix );
121  ROSE_UTIL_API bool isAdaFileNameSuffix ( const std::string & suffix );
122  ROSE_UTIL_API bool isJovialFileNameSuffix ( const std::string & suffix );
123  ROSE_UTIL_API bool isCobolFileNameSuffix ( const std::string & suffix );
124 
125  // TV (05/17/2010) Support for CUDA
126  ROSE_UTIL_API bool isCudaFileNameSuffix ( const std::string & suffix );
127  // TV (05/17/2010) Support for OpenCL
128  ROSE_UTIL_API bool isOpenCLFileNameSuffix ( const std::string & suffix );
129 
130  // DQ (10/11/2010): Adding Java support.
131  ROSE_UTIL_API bool isJavaFileNameSuffix ( const std::string & suffix );
132  ROSE_UTIL_API bool isX10FileNameSuffix (const std::string& suffix);
133 
134  ROSE_UTIL_API void initSourceFileSuffixList();
135  static Rose_STL_Container<std::string> validSourceFileSuffixes;
136 
137  ROSE_UTIL_API void initObjectFileSuffixList();
138  static Rose_STL_Container<std::string> validObjectFileSuffixes;
139 
140  ROSE_DLL_API void initExecutableFileSuffixList();
141  static Rose_STL_Container<std::string> validExecutableFileSuffixes;
142 
143  // bool isOptionTakingFileName( std::string argument );
144  ROSE_DLL_API bool isOptionTakingSecondParameter( std::string argument );
145  ROSE_DLL_API bool isOptionTakingThirdParameter ( std::string argument );
146  };
147 
148 // DQ (4/5/2010): This are defined in sage_support.cpp
153 ROSE_DLL_API std::string
154 findRoseSupportPathFromSource(const std::string& sourceTreeLocation,
155  const std::string& installTreeLocation);
156 
157 // DQ (4/5/2010): This are defined in sage_support.cpp
162 ROSE_DLL_API std::string
163 findRoseSupportPathFromBuild(const std::string& buildTreeLocation,
164  const std::string& installTreeLocation);
165 
166 // DQ (4/5/2010): This are defined in sage_support.cpp
173 ROSE_DLL_API bool
174 roseInstallPrefix(std::string& result);
175 
176 // endif associated with define ROSE_COMMANDLINE_UTILITY_H
177 #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 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 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 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 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. Functions in this namespace are in the ROSE Utilities libr...
ROSE_UTIL_API std::vector< std::string > generateArgListFromString(std::string commandline)
Separate a string into individual parameters and store them into a string vector. ...
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 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'.