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)
66 		throw( IllegalArgument ) = 0;
67 
68 	virtual ::rtl::OString	prepareHelp() = 0;
69 
70 	const ::rtl::OString&	getProgramName() const;
71 	sal_Bool				isValid(const ::rtl::OString& option);
72 	const ::rtl::OString	getOption(const ::rtl::OString& option)
73 		throw( IllegalArgument );
74 	const OptionMap& 		getOptions();
75 
76 	const ::rtl::OString 	getInputFile(sal_uInt16 index)
77 		throw( IllegalArgument );
78 
79 	const StringVector& getInputFiles();
80 
81 	::rtl::OString getExtraInputFile(sal_uInt16 index) const throw( IllegalArgument );
getNumberOfExtraInputFiles() const82 	inline sal_uInt16 getNumberOfExtraInputFiles() const
83         { return (sal_uInt16)m_extra_input_files.size(); }
getExtraInputFiles() const84 	inline const StringVector& getExtraInputFiles() const
85         { return m_extra_input_files; }
86 protected:
87 	::rtl::OString 	m_program;
88 	StringVector	m_inputFiles;
89     StringVector    m_extra_input_files;
90 	OptionMap		m_options;
91 };
92 
93 #endif // INCLUDED_CODEMAKER_OPTIONS_HXX
94 
95