InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TextCharFilter.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Florin Trofin
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //========================================================================================
23 
24 #ifndef __TextCharFilter__
25 #define __TextCharFilter__
26 
27 #include "AnsiBasedTypes.h"
28 #include <functional>
29 #include <set>
30 
35 class TextCharFilter : public std::function<bool (UTF32TextChar) >
36 {
37 public:
38  typedef std::set<UTF32TextChar> CharSet;
39 
40 
41  TextCharFilter() { }
42 
48  TextCharFilter( textchar const* pFilteredChars, size_t count )
49  {
50  size_t i(0);
51  for (; i < count; ++i)
52  {
53  Add(pFilteredChars[i]);
54  }
55  }
56 
62  bool Add( textchar ch )
63  {
64  return fFilter.insert( ch ).second;
65  }
66 
72  bool Remove( textchar ch )
73  {
74  return (fFilter.erase( ch ) != 0);
75  }
76 
81  CharSet const& GetFilter( void ) const
82  {
83  return fFilter;
84  }
85 
92  bool operator()( UTF32TextChar const& ch ) const
93  {
94  return (fFilter.find(ch) != fFilter.end());
95  }
96 
97 private:
98  CharSet fFilter;
99 };
100 
101 
113 #endif // __TextCharFilter__ //