1/* 2 * Copyright 2011 Google Inc. All Rights Reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#ifndef TYPOGRAPHY_FONT_SFNTLY_SRC_SAMPLE_SUBTLY_CHARACTER_PREDICATE_H_ 18#define TYPOGRAPHY_FONT_SFNTLY_SRC_SAMPLE_SUBTLY_CHARACTER_PREDICATE_H_ 19 20#include "sfntly/port/refcount.h" 21#include "sfntly/port/type.h" 22 23namespace subtly { 24class CharacterPredicate : virtual public sfntly::RefCount { 25 public: 26 CharacterPredicate() {} 27 virtual ~CharacterPredicate() {} 28 virtual bool operator()(int32_t character) const = 0; 29}; 30 31// All characters except for those between [start, end] are rejected 32class AcceptRange : public CharacterPredicate, 33 public sfntly::RefCounted<AcceptRange> { 34 public: 35 AcceptRange(int32_t start, int32_t end); 36 ~AcceptRange(); 37 virtual bool operator()(int32_t character) const; 38 39 private: 40 int32_t start_; 41 int32_t end_; 42}; 43 44// All characters in IntegerSet 45// The set is OWNED by the predicate! Do not modify it. 46// It will be freed when the predicate is destroyed. 47class AcceptSet : public CharacterPredicate, 48 public sfntly::RefCounted<AcceptSet> { 49 public: 50 explicit AcceptSet(sfntly::IntegerSet* characters); 51 ~AcceptSet(); 52 virtual bool operator()(int32_t character) const; 53 54 private: 55 sfntly::IntegerSet* characters_; 56}; 57 58// All characters 59class AcceptAll : public CharacterPredicate, 60 public sfntly::RefCounted<AcceptAll> { 61 public: 62 AcceptAll() {} 63 ~AcceptAll() {} 64 virtual bool operator()(int32_t character) const; 65}; 66} 67 68#endif // TYPOGRAPHY_FONT_SFNTLY_SRC_SAMPLE_SUBTLY_CHARACTER_PREDICATE_H_ 69