1*8b851043SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*8b851043SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*8b851043SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*8b851043SAndrew Rist * distributed with this work for additional information
6*8b851043SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*8b851043SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*8b851043SAndrew Rist * "License"); you may not use this file except in compliance
9*8b851043SAndrew Rist * with the License. You may obtain a copy of the License at
10*8b851043SAndrew Rist *
11*8b851043SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*8b851043SAndrew Rist *
13*8b851043SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*8b851043SAndrew Rist * software distributed under the License is distributed on an
15*8b851043SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*8b851043SAndrew Rist * KIND, either express or implied. See the License for the
17*8b851043SAndrew Rist * specific language governing permissions and limitations
18*8b851043SAndrew Rist * under the License.
19*8b851043SAndrew Rist *
20*8b851043SAndrew Rist *************************************************************/
21*8b851043SAndrew Rist
22*8b851043SAndrew Rist
23cdf0e10cSrcweir #ifndef _WLDCRD_HXX
24cdf0e10cSrcweir #define _WLDCRD_HXX
25cdf0e10cSrcweir
26cdf0e10cSrcweir #include "tools/toolsdllapi.h"
27cdf0e10cSrcweir #include <tools/solar.h>
28cdf0e10cSrcweir #include <tools/string.hxx>
29cdf0e10cSrcweir #include <osl/thread.h>
30cdf0e10cSrcweir
31cdf0e10cSrcweir // ------------
32cdf0e10cSrcweir // - WildCard -
33cdf0e10cSrcweir // ------------
34cdf0e10cSrcweir
35cdf0e10cSrcweir class TOOLS_DLLPUBLIC WildCard
36cdf0e10cSrcweir {
37cdf0e10cSrcweir private:
38cdf0e10cSrcweir ByteString aWildString;
39cdf0e10cSrcweir char cSepSymbol;
40cdf0e10cSrcweir
41cdf0e10cSrcweir sal_uInt16 ImpMatch( const char *pWild, const char *pStr ) const;
42cdf0e10cSrcweir
43cdf0e10cSrcweir public:
44cdf0e10cSrcweir WildCard();
45cdf0e10cSrcweir WildCard( const String& rWildCards,
46cdf0e10cSrcweir const char cSeparator = '\0' );
47cdf0e10cSrcweir
GetWildCard() const48cdf0e10cSrcweir const String GetWildCard() const { return UniString( aWildString, osl_getThreadTextEncoding()); }
operator ()() const49cdf0e10cSrcweir const String operator ()() const { return UniString( aWildString, osl_getThreadTextEncoding()); }
50cdf0e10cSrcweir
51cdf0e10cSrcweir sal_Bool Matches( const String& rStr ) const;
52cdf0e10cSrcweir
operator ==(const String & rString) const53cdf0e10cSrcweir sal_Bool operator ==( const String& rString ) const
54cdf0e10cSrcweir { return Matches( rString ); }
operator !=(const String & rString) const55cdf0e10cSrcweir sal_Bool operator !=( const String& rString ) const
56cdf0e10cSrcweir { return !( Matches( rString ) ); }
57cdf0e10cSrcweir
58cdf0e10cSrcweir WildCard& operator =( const String& rString );
59cdf0e10cSrcweir WildCard& operator =( const WildCard& rWildCard );
60cdf0e10cSrcweir };
61cdf0e10cSrcweir
WildCard()62cdf0e10cSrcweir inline WildCard::WildCard() :
63cdf0e10cSrcweir aWildString( '*' )
64cdf0e10cSrcweir {
65cdf0e10cSrcweir cSepSymbol = '\0';
66cdf0e10cSrcweir }
67cdf0e10cSrcweir
WildCard(const String & rWildCard,const char cSeparator)68cdf0e10cSrcweir inline WildCard::WildCard( const String& rWildCard, const char cSeparator ) :
69cdf0e10cSrcweir aWildString( rWildCard, osl_getThreadTextEncoding())
70cdf0e10cSrcweir {
71cdf0e10cSrcweir cSepSymbol = cSeparator;
72cdf0e10cSrcweir }
73cdf0e10cSrcweir
operator =(const String & rString)74cdf0e10cSrcweir inline WildCard& WildCard::operator=( const String& rString )
75cdf0e10cSrcweir {
76cdf0e10cSrcweir aWildString = ByteString(rString, osl_getThreadTextEncoding());
77cdf0e10cSrcweir return *this;
78cdf0e10cSrcweir }
79cdf0e10cSrcweir
operator =(const WildCard & rWildCard)80cdf0e10cSrcweir inline WildCard& WildCard::operator=( const WildCard& rWildCard )
81cdf0e10cSrcweir {
82cdf0e10cSrcweir aWildString = rWildCard.aWildString;
83cdf0e10cSrcweir cSepSymbol = rWildCard.cSepSymbol;
84cdf0e10cSrcweir return *this;
85cdf0e10cSrcweir }
86cdf0e10cSrcweir
87cdf0e10cSrcweir #endif
88