1cb93a386Sopenharmony_ci/*
2cb93a386Sopenharmony_ci * Copyright © 2018  Google, Inc.
3cb93a386Sopenharmony_ci *
4cb93a386Sopenharmony_ci *  This is part of HarfBuzz, a text shaping library.
5cb93a386Sopenharmony_ci *
6cb93a386Sopenharmony_ci * Permission is hereby granted, without written agreement and without
7cb93a386Sopenharmony_ci * license or royalty fees, to use, copy, modify, and distribute this
8cb93a386Sopenharmony_ci * software and its documentation for any purpose, provided that the
9cb93a386Sopenharmony_ci * above copyright notice and the following two paragraphs appear in
10cb93a386Sopenharmony_ci * all copies of this software.
11cb93a386Sopenharmony_ci *
12cb93a386Sopenharmony_ci * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13cb93a386Sopenharmony_ci * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14cb93a386Sopenharmony_ci * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15cb93a386Sopenharmony_ci * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
16cb93a386Sopenharmony_ci * DAMAGE.
17cb93a386Sopenharmony_ci *
18cb93a386Sopenharmony_ci * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19cb93a386Sopenharmony_ci * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20cb93a386Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
21cb93a386Sopenharmony_ci * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22cb93a386Sopenharmony_ci * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23cb93a386Sopenharmony_ci *
24cb93a386Sopenharmony_ci * Google Author(s): Garret Rieger, Roderick Sheeter
25cb93a386Sopenharmony_ci */
26cb93a386Sopenharmony_ci
27cb93a386Sopenharmony_ci#ifndef HB_SUBSET_HH
28cb93a386Sopenharmony_ci#define HB_SUBSET_HH
29cb93a386Sopenharmony_ci
30cb93a386Sopenharmony_ci
31cb93a386Sopenharmony_ci#include "hb.hh"
32cb93a386Sopenharmony_ci
33cb93a386Sopenharmony_ci#include "hb-subset.h"
34cb93a386Sopenharmony_ci
35cb93a386Sopenharmony_ci#include "hb-machinery.hh"
36cb93a386Sopenharmony_ci#include "hb-subset-input.hh"
37cb93a386Sopenharmony_ci#include "hb-subset-plan.hh"
38cb93a386Sopenharmony_ci
39cb93a386Sopenharmony_cistruct hb_subset_context_t :
40cb93a386Sopenharmony_ci       hb_dispatch_context_t<hb_subset_context_t, bool, HB_DEBUG_SUBSET>
41cb93a386Sopenharmony_ci{
42cb93a386Sopenharmony_ci  const char *get_name () { return "SUBSET"; }
43cb93a386Sopenharmony_ci  static return_t default_return_value () { return true; }
44cb93a386Sopenharmony_ci
45cb93a386Sopenharmony_ci  private:
46cb93a386Sopenharmony_ci  template <typename T, typename ...Ts> auto
47cb93a386Sopenharmony_ci  _dispatch (const T &obj, hb_priority<1>, Ts&&... ds) HB_AUTO_RETURN
48cb93a386Sopenharmony_ci  ( obj.subset (this, std::forward<Ts> (ds)...) )
49cb93a386Sopenharmony_ci  template <typename T, typename ...Ts> auto
50cb93a386Sopenharmony_ci  _dispatch (const T &obj, hb_priority<0>, Ts&&... ds) HB_AUTO_RETURN
51cb93a386Sopenharmony_ci  ( obj.dispatch (this, std::forward<Ts> (ds)...) )
52cb93a386Sopenharmony_ci  public:
53cb93a386Sopenharmony_ci  template <typename T, typename ...Ts> auto
54cb93a386Sopenharmony_ci  dispatch (const T &obj, Ts&&... ds) HB_AUTO_RETURN
55cb93a386Sopenharmony_ci  ( _dispatch (obj, hb_prioritize, std::forward<Ts> (ds)...) )
56cb93a386Sopenharmony_ci
57cb93a386Sopenharmony_ci  hb_blob_t *source_blob;
58cb93a386Sopenharmony_ci  hb_subset_plan_t *plan;
59cb93a386Sopenharmony_ci  hb_serialize_context_t *serializer;
60cb93a386Sopenharmony_ci  hb_tag_t table_tag;
61cb93a386Sopenharmony_ci
62cb93a386Sopenharmony_ci  hb_subset_context_t (hb_blob_t *source_blob_,
63cb93a386Sopenharmony_ci		       hb_subset_plan_t *plan_,
64cb93a386Sopenharmony_ci		       hb_serialize_context_t *serializer_,
65cb93a386Sopenharmony_ci		       hb_tag_t table_tag_) :
66cb93a386Sopenharmony_ci		        source_blob (source_blob_),
67cb93a386Sopenharmony_ci			plan (plan_),
68cb93a386Sopenharmony_ci			serializer (serializer_),
69cb93a386Sopenharmony_ci			table_tag (table_tag_) {}
70cb93a386Sopenharmony_ci};
71cb93a386Sopenharmony_ci
72cb93a386Sopenharmony_ci
73cb93a386Sopenharmony_ci#endif /* HB_SUBSET_HH */
74