xref: /aoo4110/main/tools/inc/tools/wldcrd.hxx (revision b1cdbd2c)
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 #ifndef _WLDCRD_HXX
24 #define _WLDCRD_HXX
25 
26 #include "tools/toolsdllapi.h"
27 #include <tools/solar.h>
28 #include <tools/string.hxx>
29 #include <osl/thread.h>
30 
31 // ------------
32 // - WildCard -
33 // ------------
34 
35 class TOOLS_DLLPUBLIC WildCard
36 {
37 private:
38     ByteString      aWildString;
39     char            cSepSymbol;
40 
41     sal_uInt16          ImpMatch( const char *pWild, const char *pStr ) const;
42 
43 public:
44                     WildCard();
45                     WildCard( const String& rWildCards,
46                               const char cSeparator = '\0' );
47 
GetWildCard() const48 	const String    GetWildCard() const     { return UniString( aWildString, osl_getThreadTextEncoding()); }
operator ()() const49     const String    operator ()() const     { return UniString( aWildString, osl_getThreadTextEncoding()); }
50 
51     sal_Bool            Matches( const String& rStr ) const;
52 
operator ==(const String & rString) const53     sal_Bool            operator ==( const String& rString ) const
54                         { return Matches( rString ); }
operator !=(const String & rString) const55     sal_Bool            operator !=( const String& rString ) const
56                         { return !( Matches( rString ) ); }
57 
58     WildCard&       operator =( const String& rString );
59     WildCard&       operator =( const WildCard& rWildCard );
60 };
61 
WildCard()62 inline WildCard::WildCard() :
63                     aWildString( '*' )
64 {
65     cSepSymbol  = '\0';
66 }
67 
WildCard(const String & rWildCard,const char cSeparator)68 inline WildCard::WildCard( const String& rWildCard, const char cSeparator ) :
69                     aWildString( rWildCard, osl_getThreadTextEncoding())
70 {
71     cSepSymbol  = cSeparator;
72 }
73 
operator =(const String & rString)74 inline WildCard& WildCard::operator=( const String& rString )
75 {
76     aWildString = ByteString(rString, osl_getThreadTextEncoding());
77     return *this;
78 }
79 
operator =(const WildCard & rWildCard)80 inline WildCard& WildCard::operator=( const WildCard& rWildCard )
81 {
82     aWildString = rWildCard.aWildString;
83     cSepSymbol = rWildCard.cSepSymbol;
84     return *this;
85 }
86 
87 #endif
88