1 // Generated by gmmproc 2.64.2 -- DO NOT MODIFY!
2 #ifndef _GLIBMM_BYTES_H
3 #define _GLIBMM_BYTES_H
4 
5 
6 /* Copyright (C) 2012 The glibmm Development Team
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 
23 #include <glibmmconfig.h>
24 #include <glibmm/refptr.h>
25 #include <glibmm/ustring.h>
26 #include <glibmm/error.h>
27 #include <glibmm/arrayhandle.h>
28 #include <glib.h>
29 
30 #ifndef DOXYGEN_SHOULD_SKIP_THIS
31 typedef struct _GBytes GBytes;
32 #endif
33 
34 namespace Glib
35 {
36 //Note: The documentation is a reduced version of the C documentation,
37 //because this class is only really useful with other C types that we don't bother to wrap.
38 //We only wrap it because it is used in the InputStream, OutputStream and Resource APIs.
39 
40 /** A simple refcounted data type representing an immutable byte sequence
41  * from an unspecified origin.
42  *
43  * The purpose of the Bytes class is to keep the memory region that it holds
44  * alive for as long as anyone holds a reference to the bytes.  When
45  * the last reference count is dropped, the memory is released. Multiple
46  * unrelated callers can use byte data in the Bytes object without coordinating
47  * their activities, resting assured that the byte data will not change or
48  * move while they hold a reference.
49  *
50  * A Bytes object can come from many different origins that may have
51  * different procedures for freeing the memory region.  Examples are
52  * memory from g_malloc(), from memory slices, from a GMappedFile or
53  * memory from other allocators.
54  *
55  * @newin{2,34}
56  */
57 class GLIBMM_API Bytes final
58 {
59   public:
60 #ifndef DOXYGEN_SHOULD_SKIP_THIS
61   using CppObjectType = Bytes;
62   using BaseObjectType = GBytes;
63 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
64 
65 
66   /** Increment the reference count for this object.
67    * You should never need to do this manually - use the object via a RefPtr instead.
68    */
69   void reference()   const;
70 
71   /** Decrement the reference count for this object.
72    * You should never need to do this manually - use the object via a RefPtr instead.
73    */
74   void unreference() const;
75 
76   ///Provides access to the underlying C instance.
77   GBytes*       gobj();
78 
79   ///Provides access to the underlying C instance.
80   const GBytes* gobj() const;
81 
82   ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
83   GBytes* gobj_copy() const;
84 
85   Bytes() = delete;
86 
87   // noncopyable
88   Bytes(const Bytes&) = delete;
89   Bytes& operator=(const Bytes&) = delete;
90 
91 protected:
92   // Do not derive this.  Glib::Bytes can neither be constructed nor deleted.
93 
94   void operator delete(void*, std::size_t);
95 
96 private:
97 
98 
99 public:
100 
101   static Glib::RefPtr<Glib::Bytes> create(gconstpointer data, gsize size);
102 
103 
104   /** Get the byte data in the Bytes. This data should not be modified.
105    *
106    * This function will always return the same pointer for a given Bytes.
107    *
108    * <tt>nullptr</tt> may be returned if @a size is 0. This is not guaranteed, as the Bytes
109    * may represent an empty string with @a data non-<tt>nullptr</tt> and @a size as 0. <tt>nullptr</tt> will
110    * not be returned if @a size is non-zero.
111    *
112    * @newin{2,32}
113    *
114    * @param size Location to return size of byte data.
115    * @return A pointer to the byte data, or <tt>nullptr</tt>.
116    */
117   gconstpointer get_data(gsize& size) const;
118 
119   /** Get the size of the byte data in the Bytes.
120    *
121    * This function will always return the same value for a given Bytes.
122    *
123    * @newin{2,32}
124    *
125    * @return The size.
126    */
127   gsize get_size() const;
128 
129 
130   /** Creates an integer hash code for the byte data in the Bytes.
131    *
132    * This function can be passed to g_hash_table_new() as the @a key_hash_func
133    * parameter, when using non-<tt>nullptr</tt> Bytes pointers as keys in a HashTable.
134    *
135    * @newin{2,32}
136    *
137    * @param bytes A pointer to a Bytes key.
138    * @return A hash value corresponding to the key.
139    */
140   static guint hash(gconstpointer bytes);
141 
142   /** Compares the two Bytes values being pointed to and returns
143    * <tt>true</tt> if they are equal.
144    *
145    * This function can be passed to g_hash_table_new() as the @a key_equal_func
146    * parameter, when using non-<tt>nullptr</tt> Bytes pointers as keys in a HashTable.
147    *
148    * @newin{2,32}
149    *
150    * @param bytes1 A pointer to a Bytes.
151    * @param bytes2 A pointer to a Bytes to compare with @a bytes1.
152    * @return <tt>true</tt> if the two keys match.
153    */
154   static bool equal(gconstpointer bytes1, gconstpointer bytes2);
155 
156   /** Compares the two Bytes values.
157    *
158    * This function can be used to sort GBytes instances in lexicographical order.
159    *
160    * If @a bytes1 and @a bytes2 have different length but the shorter one is a
161    * prefix of the longer one then the shorter one is considered to be less than
162    * the longer one. Otherwise the first byte where both differ is used for
163    * comparison. If @a bytes1 has a smaller value at that position it is
164    * considered less, otherwise greater than @a bytes2.
165    *
166    * @newin{2,32}
167    *
168    * @param bytes1 A pointer to a Bytes.
169    * @param bytes2 A pointer to a Bytes to compare with @a bytes1.
170    * @return A negative value if @a bytes1 is less than @a bytes2, a positive value
171    * if @a bytes1 is greater than @a bytes2, and zero if @a bytes1 is equal to
172    *  @a bytes2.
173    */
174   static gint compare(gconstpointer bytes1, gconstpointer bytes2);
175 
176 
177 };
178 
179 } // namespace Glib
180 
181 
182 namespace Glib
183 {
184 
185 /** A Glib::wrap() method for this object.
186  *
187  * @param object The C instance.
188  * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
189  * @result A C++ instance that wraps this C instance.
190  *
191  * @relates Glib::Bytes
192  */
193 GLIBMM_API
194 Glib::RefPtr<Glib::Bytes> wrap(GBytes* object, bool take_copy = false);
195 
196 } // namespace Glib
197 
198 
199 #endif /* _GLIBMM_BYTES_H */
200 
201