ROSE 0.11.145.147
commandline_processing.h
1#ifndef ROSE_COMMANDLINE_UTILITY_H
2#define ROSE_COMMANDLINE_UTILITY_H
3#include <RoseFirst.h>
4#include "setup.h"
5//#include "rosedefs.h"
6#include "rosedll.h"
7#include <list>
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 addCppSourceFileSuffix ( const std::string &suffix );
81
82 ROSE_UTIL_API bool isSourceFilename ( std::string name );
83
84 ROSE_UTIL_API bool isObjectFilename ( std::string name );
85 ROSE_DLL_API bool isExecutableFilename ( std::string name );
86
87 // DQ (8/20/2008): Added test that will allow bogus executable files (marked as .exe but not executable) to pass
88 ROSE_DLL_API bool isValidFileWithExecutableFileSuffix ( std::string name );
89
90 ROSE_UTIL_API bool isCFileNameSuffix ( const std::string & suffix );
91
92 // Liao (6/6/2008): Added support for UPC file suffix name
93 ROSE_UTIL_API bool isUPCFileNameSuffix ( const std::string & suffix );
94
95 ROSE_UTIL_API bool isCppFileNameSuffix ( const std::string & suffix );
96
97 // DQ (8/7/2007): Added support for Fortran file suffix names.
98 ROSE_UTIL_API bool isFortranFileNameSuffix ( const std::string & suffix );
99
100 // DQ (5/18/2008): Support to marking when C preprocessing is required for
101 // Fortran files, default is true for C and C++.
102 ROSE_UTIL_API bool isFortranFileNameSuffixRequiringCPP ( const std::string & suffix );
103
104 // DQ (11/17/2007): Added fortran mode specific suffix checking
105 ROSE_UTIL_API bool isFortran77FileNameSuffix ( const std::string & suffix );
106 ROSE_UTIL_API bool isFortran90FileNameSuffix ( const std::string & suffix );
107 ROSE_UTIL_API bool isFortran95FileNameSuffix ( const std::string & suffix );
108 ROSE_UTIL_API bool isFortran2003FileNameSuffix ( const std::string & suffix );
109 ROSE_UTIL_API bool isFortran2008FileNameSuffix ( const std::string & suffix );
110
111 // DQ (1/23/2009): Added support for Co-Array Fortran file extension.
112 ROSE_UTIL_API bool isCoArrayFortranFileNameSuffix ( const std::string & suffix );
113
114 ROSE_UTIL_API bool isPHPFileNameSuffix ( const std::string & suffix );
115
116 ROSE_UTIL_API bool isPythonFileNameSuffix ( const std::string & suffix );
117
118 // DQ (28/8/2017): Adding language support.
119 ROSE_UTIL_API bool isCsharpFileNameSuffix ( const std::string & suffix );
120 ROSE_UTIL_API bool isAdaFileNameSuffix ( const std::string & suffix );
121 ROSE_UTIL_API bool isJovialFileNameSuffix ( const std::string & suffix );
122
123 // TV (05/17/2010) Support for CUDA
124 ROSE_UTIL_API bool isCudaFileNameSuffix ( const std::string & suffix );
125 // TV (05/17/2010) Support for OpenCL
126 ROSE_UTIL_API bool isOpenCLFileNameSuffix ( const std::string & suffix );
127
128 // DQ (10/11/2010): Adding Java support.
129 // Modified API to use C++17 std::filesystem for portability [Rasmussen 2022.02.05]
130 ROSE_UTIL_API bool isJavaFile(const std::string &fileName);
131 ROSE_UTIL_API bool isJavaClassFile(const std::string &fileName);
132 ROSE_UTIL_API bool isJavaJarFile(const std::string &fileName);
133 ROSE_UTIL_API bool isJavaJvmFile(const std::string &fileName);
134
135 ROSE_UTIL_API void initSourceFileSuffixList();
136 static Rose_STL_Container<std::string> validSourceFileSuffixes;
137
138 ROSE_UTIL_API void initObjectFileSuffixList();
139 static Rose_STL_Container<std::string> validObjectFileSuffixes;
140
141 ROSE_DLL_API void initExecutableFileSuffixList();
142 static Rose_STL_Container<std::string> validExecutableFileSuffixes;
143
144 // bool isOptionTakingFileName( std::string argument );
145 ROSE_DLL_API bool isOptionTakingSecondParameter( std::string argument );
146 ROSE_DLL_API bool isOptionTakingThirdParameter ( std::string argument );
147 };
148
149// DQ (4/5/2010): This are defined in sage_support.C
154ROSE_DLL_API std::string
155findRoseSupportPathFromSource(const std::string& sourceTreeLocation,
156 const std::string& installTreeLocation);
157
158// DQ (4/5/2010): This are defined in sage_support.C
163ROSE_DLL_API std::string
164findRoseSupportPathFromBuild(const std::string& buildTreeLocation,
165 const std::string& installTreeLocation);
166
167// DQ (4/5/2010): This are defined in sage_support.C
174ROSE_DLL_API bool
175roseInstallPrefix(std::string& result);
176
177// endif associated with define ROSE_COMMANDLINE_UTILITY_H
178#endif
Command line processing utility functions. Functions in this namespace are in the ROSE Utilities libr...
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'.
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 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 removeArgs(std::vector< std::string > &argv, std::string prefix)
Remove all options matching a specified prefix 'prefix' from the argument list 'argv'.
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 > generateArgListFromString(std::string commandline)
Separate a string into individual parameters and store them into a string vector.
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',...
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'.
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 void addCppSourceFileSuffix(const std::string &suffix)
Add another valid source file suffix (warning deprecated as it is not consistently used)
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 > generateOptionList(const std::vector< std::string > &argList, std::string inputPrefix)
Looks for inputPrefix prefixed options.
ROSE_UTIL_API std::string generateStringFromArgList(const std::vector< std::string > &argList)
Convert a vector of string to a single string.
ROSE_UTIL_API std::vector< std::string > generateOptionListWithDeclaredParameters(const std::vector< std::string > &argList, std::string inputPrefix)
Looks for inputPrefix-prefixed options.
ROSE_UTIL_API void generateArgcArgvFromList(std::vector< std::string > argList, int &argc, char **&argv)
Convert a string vector back to an argc-argv pair.