w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

hb-blob.hh
Go to the documentation of this file.
1 /*
2  * Copyright © 2009 Red Hat, Inc.
3  * Copyright © 2018 Google, Inc.
4  *
5  * This is part of HarfBuzz, a text shaping library.
6  *
7  * Permission is hereby granted, without written agreement and without
8  * license or royalty fees, to use, copy, modify, and distribute this
9  * software and its documentation for any purpose, provided that the
10  * above copyright notice and the following two paragraphs appear in
11  * all copies of this software.
12  *
13  * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
14  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
15  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
16  * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
17  * DAMAGE.
18  *
19  * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
20  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
22  * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
23  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24  *
25  * Red Hat Author(s): Behdad Esfahbod
26  * Google Author(s): Behdad Esfahbod
27  */
28 
29 #ifndef HB_BLOB_HH
30 #define HB_BLOB_HH
31 
32 #include "hb.hh"
33 
34 
35 /*
36  * hb_blob_t
37  */
38 
39 struct hb_blob_t
40 {
42 
44  {
45  if (destroy)
46  {
48  user_data = nullptr;
49  destroy = nullptr;
50  }
51  }
52 
56 
57  hb_bytes_t as_bytes () const { return hb_bytes_t (data, length); }
58  template <typename Type>
59  const Type* as () const { return as_bytes ().as<Type> (); }
60 
61  public:
63 
64  const char *data;
65  unsigned int length;
67 
68  void *user_data;
70 };
71 
72 
73 /*
74  * hb_blob_ptr_t
75  */
76 
77 template <typename P>
79 {
81 
82  hb_blob_ptr_t (hb_blob_t *b_ = nullptr) : b (b_) {}
83  hb_blob_t * operator = (hb_blob_t *b_) { return b = b_; }
84  const T * operator -> () const { return get (); }
85  const T & operator * () const { return *get (); }
86  template <typename C> operator const C * () const { return get (); }
87  operator const char * () const { return (const char *) get (); }
88  const T * get () const { return b->as<T> (); }
89  hb_blob_t * get_blob () const { return b.get_raw (); }
90  unsigned int get_length () const { return b.get ()->length; }
91  void destroy () { hb_blob_destroy (b.get ()); b = nullptr; }
92 
93  private:
95 };
96 
97 
98 #endif /* HB_BLOB_HH */
#define C
Definition: afm2pl.c:546
hb_array_t< const char > hb_bytes_t
Definition: hb-array.hh:403
void hb_blob_destroy(hb_blob_t *blob)
Definition: hb-blob.cc:226
hb_memory_mode_t
Definition: hb-blob.h:67
void(* hb_destroy_func_t)(void *user_data)
Definition: hb-common.h:690
typename hb_match_pointer< T >::type hb_remove_pointer
Definition: hb-meta.hh:118
#define HB_INTERNAL
Definition: hb.hh:265
const T * as() const
Definition: hb-array.hh:221
const T & operator*() const
Definition: hb-blob.hh:85
void destroy()
Definition: hb-blob.hh:91
hb_remove_pointer< P > T
Definition: hb-blob.hh:80
unsigned int get_length() const
Definition: hb-blob.hh:90
const T * operator->() const
Definition: hb-blob.hh:84
hb_blob_t * get_blob() const
Definition: hb-blob.hh:89
hb_nonnull_ptr_t< hb_blob_t > b
Definition: hb-blob.hh:94
const T * get() const
Definition: hb-blob.hh:88
hb_blob_t * operator=(hb_blob_t *b_)
Definition: hb-blob.hh:83
hb_blob_ptr_t(hb_blob_t *b_=nullptr)
Definition: hb-blob.hh:82
const Type * as() const
Definition: hb-blob.hh:59
hb_object_header_t header
Definition: hb-blob.hh:62
unsigned int length
Definition: hb-blob.hh:65
bool try_make_writable_inplace_unix()
Definition: hb-blob.cc:383
hb_destroy_func_t destroy
Definition: hb-blob.hh:69
hb_bytes_t as_bytes() const
Definition: hb-blob.hh:57
void destroy_user_data()
Definition: hb-blob.hh:43
bool try_make_writable_inplace()
Definition: hb-blob.cc:426
bool try_make_writable()
Definition: hb-blob.cc:441
hb_memory_mode_t mode
Definition: hb-blob.hh:66
void * user_data
Definition: hb-blob.hh:68
const char * data
Definition: hb-blob.hh:64
void fini_shallow()
Definition: hb-blob.hh:41