xref: /trunk/main/ucb/source/inc/regexp.hxx (revision 6df1ea1f)
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 _UCB_REGEXP_HXX_
25 #define _UCB_REGEXP_HXX_
26 
27 #include <rtl/ustring.hxx>
28 
29 //============================================================================
30 namespace ucb_impl {
31 
32 class Regexp
33 {
34 public:
35 	enum Kind
36 	{
37 		KIND_PREFIX,
38 		KIND_AUTHORITY,
39 		KIND_DOMAIN
40 	};
41 
42 	inline bool operator ==(Regexp const & rOther) const;
43 
isDefault() const44 	inline bool isDefault() const
45 	{ return m_eKind == KIND_PREFIX && m_aPrefix.getLength() == 0; }
46 
getKind() const47 	inline Kind getKind() const { return m_eKind; }
48 
49 	bool matches(rtl::OUString const & rString, rtl::OUString * pTranslation,
50 				 bool * pTranslated) const;
51 
52 	rtl::OUString getRegexp(bool bReverse) const;
53 
54 	static Regexp parse(rtl::OUString const & rRegexp);
55 
56 private:
57 	Kind m_eKind;
58 	rtl::OUString m_aPrefix;
59 	rtl::OUString m_aInfix;
60 	rtl::OUString m_aReversePrefix;
61 	bool m_bEmptyDomain;
62 	bool m_bTranslation;
63 
64 	inline Regexp(Kind eTheKind, rtl::OUString const & rThePrefix,
65 				  bool bTheEmptyDomain, rtl::OUString const & rTheInfix,
66 				  bool bTheTranslation,
67 				  rtl::OUString const & rTheReversePrefix);
68 };
69 
operator ==(Regexp const & rOther) const70 inline bool Regexp::operator ==(Regexp const & rOther) const
71 {
72 	return m_eKind == rOther.m_eKind
73 		   && m_aPrefix == rOther.m_aPrefix
74 		   && m_aInfix == rOther.m_aInfix;
75 }
76 
77 }
78 
79 #endif // _UCB_REGEXP_HXX_
80 
81