1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _IDLC_OPTIONS_HXX_ 25 #define _IDLC_OPTIONS_HXX_ 26 27 #ifndef _IDLC_IDLCTYPEs_HXX_ 28 #include <idlc/idlctypes.hxx> 29 #endif 30 31 typedef ::std::hash_map< ::rtl::OString, 32 ::rtl::OString, 33 HashString, 34 EqualString > OptionMap; 35 36 class IllegalArgument 37 { 38 public: IllegalArgument(const::rtl::OString & msg)39 IllegalArgument(const ::rtl::OString& msg) 40 : m_message(msg) {} 41 42 ::rtl::OString m_message; 43 }; 44 45 46 class Options 47 { 48 public: 49 explicit Options(char const * progname); 50 ~Options(); 51 52 static bool checkArgument(std::vector< std::string > & rArgs, char const * arg, size_t len); 53 static bool checkCommandFile(std::vector< std::string > & rArgs, char const * filename); 54 55 bool initOptions(std::vector< std::string > & rArgs) 56 throw(IllegalArgument); 57 bool badOption(char const * reason, std::string const & rArg) 58 throw(IllegalArgument); 59 bool setOption(char const * option, std::string const & rArg); 60 61 #if 0 /* @@@ */ 62 sal_Bool initOptions(int ac, char* av[], sal_Bool bCmdFile=sal_False) 63 throw( IllegalArgument ); 64 #endif /* @@@ */ 65 66 ::rtl::OString prepareHelp(); 67 ::rtl::OString prepareVersion(); 68 69 const ::rtl::OString& getProgramName() const; 70 bool isValid(const ::rtl::OString& option); 71 const ::rtl::OString& getOption(const ::rtl::OString& option) 72 throw( IllegalArgument ); 73 getInputFiles() const74 const StringVector& getInputFiles() const { return m_inputFiles; } readStdin() const75 bool readStdin() const { return m_stdin; } verbose() const76 bool verbose() const { return m_verbose; } quiet() const77 bool quiet() const { return m_quiet; } 78 79 protected: 80 ::rtl::OString m_program; 81 StringVector m_inputFiles; 82 bool m_stdin; 83 bool m_verbose; 84 bool m_quiet; 85 OptionMap m_options; 86 }; 87 88 #endif // _IDLC_OPTIONS_HXX_ 89 90