xref: /aoo41x/main/tools/inc/tools/wldcrd.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _WLDCRD_HXX
28 #define _WLDCRD_HXX
29 
30 #include "tools/toolsdllapi.h"
31 #include <tools/solar.h>
32 #include <tools/string.hxx>
33 #include <osl/thread.h>
34 
35 // ------------
36 // - WildCard -
37 // ------------
38 
39 class TOOLS_DLLPUBLIC WildCard
40 {
41 private:
42     ByteString      aWildString;
43     char            cSepSymbol;
44 
45     sal_uInt16          ImpMatch( const char *pWild, const char *pStr ) const;
46 
47 public:
48                     WildCard();
49                     WildCard( const String& rWildCards,
50                               const char cSeparator = '\0' );
51 
52 	const String    GetWildCard() const     { return UniString( aWildString, osl_getThreadTextEncoding()); }
53     const String    operator ()() const     { return UniString( aWildString, osl_getThreadTextEncoding()); }
54 
55     sal_Bool            Matches( const String& rStr ) const;
56 
57     sal_Bool            operator ==( const String& rString ) const
58                         { return Matches( rString ); }
59     sal_Bool            operator !=( const String& rString ) const
60                         { return !( Matches( rString ) ); }
61 
62     WildCard&       operator =( const String& rString );
63     WildCard&       operator =( const WildCard& rWildCard );
64 };
65 
66 inline WildCard::WildCard() :
67                     aWildString( '*' )
68 {
69     cSepSymbol  = '\0';
70 }
71 
72 inline WildCard::WildCard( const String& rWildCard, const char cSeparator ) :
73                     aWildString( rWildCard, osl_getThreadTextEncoding())
74 {
75     cSepSymbol  = cSeparator;
76 }
77 
78 inline WildCard& WildCard::operator=( const String& rString )
79 {
80     aWildString = ByteString(rString, osl_getThreadTextEncoding());
81     return *this;
82 }
83 
84 inline WildCard& WildCard::operator=( const WildCard& rWildCard )
85 {
86     aWildString = rWildCard.aWildString;
87     cSepSymbol = rWildCard.cSepSymbol;
88     return *this;
89 }
90 
91 #endif
92