xref: /trunk/main/codemaker/inc/codemaker/options.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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 INCLUDED_CODEMAKER_OPTIONS_HXX
25 #define INCLUDED_CODEMAKER_OPTIONS_HXX
26 
27 #include <hash_map>
28 
29 #include <codemaker/global.hxx>
30 
31 #if defined( _MSC_VER ) && ( _MSC_VER < 1200 )
32 typedef ::std::__hash_map__
33 <
34     ::rtl::OString,
35     ::rtl::OString,
36     HashString,
37     EqualString,
38     NewAlloc
39 > OptionMap;
40 #else
41 typedef ::std::hash_map
42 <
43     ::rtl::OString,
44     ::rtl::OString,
45     HashString,
46     EqualString
47 > OptionMap;
48 #endif
49 
50 class IllegalArgument
51 {
52 public:
IllegalArgument(const::rtl::OString & msg)53     IllegalArgument(const ::rtl::OString& msg)
54         : m_message(msg) {}
55 
56     ::rtl::OString  m_message;
57 };
58 
59 class Options
60 {
61 public:
62     Options();
63     virtual ~Options();
64 
65     virtual sal_Bool initOptions(int ac, char* av[], sal_Bool bCmdFile=sal_False) = 0;
66 
67     virtual ::rtl::OString  prepareHelp() = 0;
68 
69     const ::rtl::OString&   getProgramName() const;
70     sal_Bool                isValid(const ::rtl::OString& option);
71     const ::rtl::OString    getOption(const ::rtl::OString& option);
72     const OptionMap&        getOptions();
73 
74     const ::rtl::OString    getInputFile(sal_uInt16 index);
75 
76     const StringVector& getInputFiles();
77 
78     ::rtl::OString getExtraInputFile(sal_uInt16 index) const;
getNumberOfExtraInputFiles() const79     inline sal_uInt16 getNumberOfExtraInputFiles() const
80         { return (sal_uInt16)m_extra_input_files.size(); }
getExtraInputFiles() const81     inline const StringVector& getExtraInputFiles() const
82         { return m_extra_input_files; }
83 protected:
84     ::rtl::OString  m_program;
85     StringVector    m_inputFiles;
86     StringVector    m_extra_input_files;
87     OptionMap       m_options;
88 };
89 
90 #endif // INCLUDED_CODEMAKER_OPTIONS_HXX
91