00001 #ifndef ROSE_COMMANDLINE_UTILITY_H
00002 #define ROSE_COMMANDLINE_UTILITY_H
00003 #include "setup.h"
00004
00005 #include <list>
00006 #define Rose_STL_Container std::vector
00007
00008
00009
00010 namespace CommandlineProcessing
00011 {
00013 Rose_STL_Container<std::string> generateArgListFromString ( std::string commandline );
00014
00016
00017 std::string generateStringFromArgList( const Rose_STL_Container<std::string> & argList);
00018
00020 Rose_STL_Container<std::string> generateArgListFromArgcArgv ( int argc, const char* argv[] );
00021
00022 inline Rose_STL_Container<std::string> generateArgListFromArgcArgv ( int argc, char* argv[] )
00023 {return generateArgListFromArgcArgv(argc, (const char**)argv);}
00024
00026 void generateArgcArgvFromList ( Rose_STL_Container<std::string> argList, int & argc, char** & argv );
00027
00028 Rose_STL_Container<std::string> generateOptionList ( Rose_STL_Container<std::string> & argList, std::string inputPrefix );
00029
00032 Rose_STL_Container<std::string> generateOptionWithNameParameterList ( Rose_STL_Container<std::string> & argList, std::string inputPrefix );
00033
00034 extern Rose_STL_Container<std::string> extraCppSourceFileSuffixes;
00035
00037
00042 bool isOption ( std::vector<std::string> & argv, std::string optionPrefix, std::string Option, bool removeOption );
00043
00046 bool isOptionWithParameter ( std::vector<std::string> & argv, std::string optionPrefix, std::string Option, int & optionParameter, bool removeOption );
00047
00049 bool isOptionWithParameter ( std::vector<std::string> & argv, std::string optionPrefix, std::string Option, float & optionParameter, bool removeOption );
00050
00052 bool isOptionWithParameter ( std::vector<std::string> & argv, std::string optionPrefix, std::string Option, std::string & optionParameter, bool removeOption );
00053
00055 void addListToCommandLine ( std::vector<std::string> & argv , std::string prefix, Rose_STL_Container<std::string> argList );
00057 void removeArgs ( std::vector<std::string> & argv, std::string prefix );
00059 void removeArgsWithParameters ( std::vector<std::string> & argv, std::string prefix );
00061 void removeAllFileNamesExcept ( std::vector<std::string> & argv, Rose_STL_Container<std::string> filenameList, std::string exceptFilename );
00062
00064 std::string generateStringFromArgList ( Rose_STL_Container<std::string> argList, bool skipInitialEntry, bool skipSourceFiles );
00065
00067 Rose_STL_Container<std::string> generateSourceFilenames ( Rose_STL_Container<std::string> argList, bool binaryMode );
00068
00069
00071 void addSourceFileSuffix ( const std::string &suffix );
00072 void addCppSourceFileSuffix ( const std::string &suffix );
00073
00074 bool isSourceFilename ( std::string name );
00075
00076 bool isObjectFilename ( std::string name );
00077 bool isExecutableFilename ( std::string name );
00078
00079
00080 bool isValidFileWithExecutableFileSuffixes ( std::string name );
00081
00082 bool isCFileNameSuffix ( const std::string & suffix );
00083
00084
00085 bool isUPCFileNameSuffix ( const std::string & suffix );
00086
00087 bool isCppFileNameSuffix ( const std::string & suffix );
00088
00089
00090 bool isFortranFileNameSuffix ( const std::string & suffix );
00091
00092
00093
00094 bool isFortranFileNameSuffixRequiringCPP ( const std::string & suffix );
00095
00096
00097 bool isFortran77FileNameSuffix ( const std::string & suffix );
00098 bool isFortran90FileNameSuffix ( const std::string & suffix );
00099 bool isFortran95FileNameSuffix ( const std::string & suffix );
00100 bool isFortran2003FileNameSuffix ( const std::string & suffix );
00101 bool isFortran2008FileNameSuffix ( const std::string & suffix );
00102
00103
00104 bool isCoArrayFortranFileNameSuffix ( const std::string & suffix );
00105
00106 bool isPHPFileNameSuffix ( const std::string & suffix );
00107
00108 bool isPythonFileNameSuffix ( const std::string & suffix );
00109
00110
00111 bool isCudaFileNameSuffix ( const std::string & suffix );
00112
00113 bool isOpenCLFileNameSuffix ( const std::string & suffix );
00114
00115
00116 bool isJavaFileNameSuffix ( const std::string & suffix );
00117
00118 void initSourceFileSuffixList();
00119 static Rose_STL_Container<std::string> validSourceFileSuffixes;
00120
00121 void initObjectFileSuffixList();
00122 static Rose_STL_Container<std::string> validObjectFileSuffixes;
00123
00124 void initExecutableFileSuffixList();
00125 static Rose_STL_Container<std::string> validExecutableFileSuffixes;
00126
00127
00128 bool isOptionTakingSecondParameter( std::string argument );
00129 bool isOptionTakingThirdParameter ( std::string argument );
00130 };
00131
00132
00137 std::string
00138 findRoseSupportPathFromSource(const std::string& sourceTreeLocation,
00139 const std::string& installTreeLocation);
00140
00141
00146 std::string
00147 findRoseSupportPathFromBuild(const std::string& buildTreeLocation,
00148 const std::string& installTreeLocation);
00149
00150
00157 bool
00158 roseInstallPrefix(std::string& result);
00159
00160
00161 #endif