1 // Generated by gmmproc 2.64.2 -- DO NOT MODIFY! 2 #ifndef _GIOMM_RESOURCE_H 3 #define _GIOMM_RESOURCE_H 4 5 6 #include <glibmm/ustring.h> 7 #include <sigc++/sigc++.h> 8 9 /* Copyright (C) 2012 The gtkmm Development Team 10 * 11 * This library is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2.1 of the License, or (at your option) any later version. 15 * 16 * This library is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 23 */ 24 25 #include <glibmm/error.h> 26 #include <glibmm/refptr.h> 27 #include <glibmm/bytes.h> 28 #include <giomm/inputstream.h> 29 #include <vector> 30 #include <string> 31 32 33 #ifndef DOXYGEN_SHOULD_SKIP_THIS 34 typedef struct _GResource GResource; 35 #endif 36 37 namespace Gio 38 { 39 40 /** %Exception class for resource file handling errors. 41 * 42 * @newin{2,34} 43 */ 44 class GIOMM_API ResourceError : public Glib::Error 45 { 46 public: 47 /** @var Code NOT_FOUND 48 * No file was found at the requested path. 49 * 50 * @var Code INTERNAL 51 * Unknown error. 52 * 53 * @enum Code 54 * 55 * An error code used with G_RESOURCE_ERROR in a Error returned 56 * from a Resource routine. 57 * 58 * @newin{2,34} 59 */ 60 enum Code 61 { 62 NOT_FOUND, 63 INTERNAL 64 }; 65 66 ResourceError(Code error_code, const Glib::ustring& error_message); 67 explicit ResourceError(GError* gobject); 68 Code code() const; 69 70 #ifndef DOXYGEN_SHOULD_SKIP_THIS 71 private: 72 73 static void throw_func(GError* gobject); 74 75 friend GIOMM_API void wrap_init(); // uses throw_func() 76 77 #endif //DOXYGEN_SHOULD_SKIP_THIS 78 }; 79 80 81 /** @addtogroup giommEnums giomm Enums and Flags */ 82 83 /** 84 * @var ResourceFlags RESOURCE_FLAGS_NONE 85 * No flags set. 86 * 87 * @var ResourceFlags RESOURCE_FLAGS_COMPRESSED 88 * The file is compressed. 89 * 90 * @enum ResourceFlags 91 * 92 * GResourceFlags give information about a particular file inside a resource 93 * bundle. 94 * 95 * @newin{2,44} 96 * 97 * @ingroup giommEnums 98 * @par Bitwise operators: 99 * <tt>%ResourceFlags operator|(ResourceFlags, ResourceFlags)</tt><br> 100 * <tt>%ResourceFlags operator&(ResourceFlags, ResourceFlags)</tt><br> 101 * <tt>%ResourceFlags operator^(ResourceFlags, ResourceFlags)</tt><br> 102 * <tt>%ResourceFlags operator~(ResourceFlags)</tt><br> 103 * <tt>%ResourceFlags& operator|=(ResourceFlags&, ResourceFlags)</tt><br> 104 * <tt>%ResourceFlags& operator&=(ResourceFlags&, ResourceFlags)</tt><br> 105 * <tt>%ResourceFlags& operator^=(ResourceFlags&, ResourceFlags)</tt><br> 106 */ 107 enum ResourceFlags 108 { 109 RESOURCE_FLAGS_NONE = 0x0, 110 RESOURCE_FLAGS_COMPRESSED = (1<<0) 111 }; 112 113 /** @ingroup giommEnums */ 114 inline ResourceFlags operator|(ResourceFlags lhs, ResourceFlags rhs) 115 { return static_cast<ResourceFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); } 116 117 /** @ingroup giommEnums */ 118 inline ResourceFlags operator&(ResourceFlags lhs, ResourceFlags rhs) 119 { return static_cast<ResourceFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); } 120 121 /** @ingroup giommEnums */ 122 inline ResourceFlags operator^(ResourceFlags lhs, ResourceFlags rhs) 123 { return static_cast<ResourceFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); } 124 125 /** @ingroup giommEnums */ 126 inline ResourceFlags operator~(ResourceFlags flags) 127 { return static_cast<ResourceFlags>(~static_cast<unsigned>(flags)); } 128 129 /** @ingroup giommEnums */ 130 inline ResourceFlags& operator|=(ResourceFlags& lhs, ResourceFlags rhs) 131 { return (lhs = static_cast<ResourceFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs))); } 132 133 /** @ingroup giommEnums */ 134 inline ResourceFlags& operator&=(ResourceFlags& lhs, ResourceFlags rhs) 135 { return (lhs = static_cast<ResourceFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs))); } 136 137 /** @ingroup giommEnums */ 138 inline ResourceFlags& operator^=(ResourceFlags& lhs, ResourceFlags rhs) 139 { return (lhs = static_cast<ResourceFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs))); } 140 141 } // namespace Gio 142 143 #ifndef DOXYGEN_SHOULD_SKIP_THIS 144 namespace Glib 145 { 146 147 template <> 148 class Value<Gio::ResourceFlags> : public Glib::Value_Flags<Gio::ResourceFlags> 149 { 150 public: 151 static GType value_type() G_GNUC_CONST; 152 }; 153 154 } // namespace Glib 155 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 156 157 namespace Gio 158 { 159 160 /** 161 * @var ResourceLookupFlags RESOURCE_LOOKUP_FLAGS_NONE 162 * No flags set. 163 * 164 * @enum ResourceLookupFlags 165 * 166 * GResourceLookupFlags determine how resource path lookups are handled. 167 * 168 * @newin{2,44} 169 * 170 * @ingroup giommEnums 171 * @par Bitwise operators: 172 * <tt>%ResourceLookupFlags operator|(ResourceLookupFlags, ResourceLookupFlags)</tt><br> 173 * <tt>%ResourceLookupFlags operator&(ResourceLookupFlags, ResourceLookupFlags)</tt><br> 174 * <tt>%ResourceLookupFlags operator^(ResourceLookupFlags, ResourceLookupFlags)</tt><br> 175 * <tt>%ResourceLookupFlags operator~(ResourceLookupFlags)</tt><br> 176 * <tt>%ResourceLookupFlags& operator|=(ResourceLookupFlags&, ResourceLookupFlags)</tt><br> 177 * <tt>%ResourceLookupFlags& operator&=(ResourceLookupFlags&, ResourceLookupFlags)</tt><br> 178 * <tt>%ResourceLookupFlags& operator^=(ResourceLookupFlags&, ResourceLookupFlags)</tt><br> 179 */ 180 enum ResourceLookupFlags 181 { 182 RESOURCE_LOOKUP_FLAGS_NONE = 0x0 183 }; 184 185 /** @ingroup giommEnums */ 186 inline ResourceLookupFlags operator|(ResourceLookupFlags lhs, ResourceLookupFlags rhs) 187 { return static_cast<ResourceLookupFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); } 188 189 /** @ingroup giommEnums */ 190 inline ResourceLookupFlags operator&(ResourceLookupFlags lhs, ResourceLookupFlags rhs) 191 { return static_cast<ResourceLookupFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); } 192 193 /** @ingroup giommEnums */ 194 inline ResourceLookupFlags operator^(ResourceLookupFlags lhs, ResourceLookupFlags rhs) 195 { return static_cast<ResourceLookupFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); } 196 197 /** @ingroup giommEnums */ 198 inline ResourceLookupFlags operator~(ResourceLookupFlags flags) 199 { return static_cast<ResourceLookupFlags>(~static_cast<unsigned>(flags)); } 200 201 /** @ingroup giommEnums */ 202 inline ResourceLookupFlags& operator|=(ResourceLookupFlags& lhs, ResourceLookupFlags rhs) 203 { return (lhs = static_cast<ResourceLookupFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs))); } 204 205 /** @ingroup giommEnums */ 206 inline ResourceLookupFlags& operator&=(ResourceLookupFlags& lhs, ResourceLookupFlags rhs) 207 { return (lhs = static_cast<ResourceLookupFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs))); } 208 209 /** @ingroup giommEnums */ 210 inline ResourceLookupFlags& operator^=(ResourceLookupFlags& lhs, ResourceLookupFlags rhs) 211 { return (lhs = static_cast<ResourceLookupFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs))); } 212 213 } // namespace Gio 214 215 #ifndef DOXYGEN_SHOULD_SKIP_THIS 216 namespace Glib 217 { 218 219 template <> 220 class Value<Gio::ResourceLookupFlags> : public Glib::Value_Flags<Gio::ResourceLookupFlags> 221 { 222 public: 223 static GType value_type() G_GNUC_CONST; 224 }; 225 226 } // namespace Glib 227 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 228 229 namespace Gio 230 { 231 232 233 /** %Resource framework. 234 * 235 * Applications and libraries often contain binary or textual data that is 236 * really part of the application, rather than user data. For instance 237 * Gtk::Builder .ui files, splashscreen images, Gio::Menu markup xml, CSS files, 238 * icons, etc. These are often shipped as files in `$datadir/appname`, or 239 * manually included as literal strings in the code. 240 * 241 * The Gio::Resource API and the <tt>glib-compile-resources</tt> program 242 * provide a convenient and efficient alternative to this which has some nice properties. You 243 * maintain the files as normal files, so it's easy to edit them, but during the build the files 244 * are combined into a binary bundle that is linked into the executable. This means that loading 245 * the resource files is efficient (as they are already in memory, shared with other instances) and 246 * simple (no need to check for things like I/O errors or locate the files in the filesystem). It 247 * also makes it easier to create relocatable applications. 248 * 249 * %Resource files can also be marked as compressed. Such files will be included in the resource bundle 250 * in a compressed form, but will be automatically uncompressed when the resource is used. This 251 * is very useful e.g. for larger text files that are parsed once (or rarely) and then thrown away. 252 * 253 * %Resource files can also be marked to be preprocessed, by setting the value of the 254 * `preprocess` attribute to a comma-separated list of preprocessing options. 255 * The only options currently supported are: 256 * 257 * <dl> 258 * <dt>xml-stripblanks</dt> 259 * <dd>which will use the <tt>xmllint</tt> command 260 * to strip ignorable whitespace from the xml file. For this to work, 261 * the `XMLLINT` environment variable must be set to the full path to 262 * the <tt>xmllint</tt> executable, or <tt>xmllint</tt> must be in the `PATH`; otherwise 263 * the preprocessing step is skipped.</dd> 264 * 265 * <dt>to-pixdata</dt> 266 * <dd>which will use the <tt>gdk-pixbuf-pixdata</tt> command to convert 267 * images to the GdkPixdata format, which allows you to create pixbufs directly using the data inside 268 * the resource file, rather than an (uncompressed) copy of it. For this, the <tt>gdk-pixbuf-pixdata</tt> 269 * program must be in the PATH, or the `GDK_PIXBUF_PIXDATA` environment variable must be 270 * set to the full path to the <tt>gdk-pixbuf-pixdata</tt> executable; otherwise the resource compiler will 271 * abort.</dd> 272 * </dl> 273 * 274 * %Resource bundles are created by the <tt>glib-compile-resources</tt> program 275 * which takes an xml file that describes the bundle, and a set of files that the xml references. These 276 * are combined into a binary resource bundle. 277 * 278 * An example resource description: 279 * @code 280 * <?xml version="1.0" encoding="UTF-8"?> 281 * <gresources> 282 * <gresource prefix="/org/gtk/Example"> 283 * <file>data/splashscreen.png</file> 284 * <file compressed="true">dialog.ui</file> 285 * <file preprocess="xml-stripblanks">menumarkup.xml</file> 286 * </gresource> 287 * </gresources> 288 * @endcode 289 * 290 * This will create a resource bundle with the following files: 291 * @code 292 * /org/gtk/Example/data/splashscreen.png 293 * /org/gtk/Example/dialog.ui 294 * /org/gtk/Example/menumarkup.xml 295 * @endcode 296 * 297 * Note that all resources in the process share the same namespace, so use java-style 298 * path prefixes (like in the above example) to avoid conflicts. 299 * 300 * You can then use <tt>glib-compile-resources</tt> to compile the xml to a binary bundle 301 * that you can load with Gio::Resource::create_from_file(). However, it's more common to use the --generate-source and 302 * --generate-header arguments to create a source file and header to link directly into your application. 303 * 304 * Once a Gio::Resource has been created and registered all the data in it can be accessed globally in the process by 305 * using API calls like Gio::Resource::open_stream_from_global_resources() to stream the data 306 * or Gio::Resource::lookup_data_in_global_resources() to get a direct pointer 307 * to the data. You can also use uris like "resource:///org/gtk/Example/data/splashscreen.png" with Gio::File to access 308 * the resource data. 309 * 310 * There are two forms of the generated source, the default version uses the compiler support for constructor 311 * and destructor functions (where available) to automatically create and register the Gio::Resource on startup 312 * or library load time. If you pass --manual-register, two functions to register/unregister the resource is instead 313 * created. This requires an explicit initialization call in your application/library, but it works on all platforms, 314 * even on the minor ones where this is not available. (Constructor support is available for at least Win32, MacOS and Linux.) 315 * 316 * Note that resource data can point directly into the data segment of e.g. a library, so if you are unloading libraries 317 * during runtime you need to be very careful with keeping around pointers to data from a resource, as this goes away 318 * when the library is unloaded. However, in practice this is not generally a problem, since most resource accesses 319 * is for your own resources, and resource data is often used once, during parsing, and then released. 320 * 321 * @newin{2,44} 322 */ 323 class GIOMM_API Resource final 324 { 325 public: 326 #ifndef DOXYGEN_SHOULD_SKIP_THIS 327 using CppObjectType = Resource; 328 using BaseObjectType = GResource; 329 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 330 331 332 /** Increment the reference count for this object. 333 * You should never need to do this manually - use the object via a RefPtr instead. 334 */ 335 void reference() const; 336 337 /** Decrement the reference count for this object. 338 * You should never need to do this manually - use the object via a RefPtr instead. 339 */ 340 void unreference() const; 341 342 ///Provides access to the underlying C instance. 343 GResource* gobj(); 344 345 ///Provides access to the underlying C instance. 346 const GResource* gobj() const; 347 348 ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. 349 GResource* gobj_copy() const; 350 351 Resource() = delete; 352 353 // noncopyable 354 Resource(const Resource&) = delete; 355 Resource& operator=(const Resource&) = delete; 356 357 protected: 358 // Do not derive this. Gio::Resource can neither be constructed nor deleted. 359 360 void operator delete(void*, std::size_t); 361 362 private: 363 364 365 public: 366 367 /** Creates a GResource from a reference to the binary resource bundle. 368 * This will keep a reference to @a data while the resource lives, so 369 * the data should not be modified or freed. 370 * 371 * If you want to use this resource in the global resource namespace you need 372 * to register it with g_resources_register(). 373 * 374 * @note @a data must be backed by memory that is at least pointer aligned. 375 * Otherwise this function will internally create a copy of the memory since 376 * GLib 2.56, or in older versions fail and exit the process. 377 * 378 * If @a data is empty or corrupt, RESOURCE_ERROR_INTERNAL will be returned. 379 * 380 * @newin{2,44} 381 * 382 * @param data A Bytes. 383 * @return A new Resource, or <tt>nullptr</tt> on error. 384 * 385 * @throws Glib::Error 386 */ 387 static Glib::RefPtr<Resource> create_from_data(const Glib::RefPtr<const Glib::Bytes>& data); 388 389 /** Loads a binary resource bundle and creates a Resource representation of it, allowing 390 * you to query it for data. 391 * 392 * If you want to use this resource in the global resource namespace you need 393 * to register it with g_resources_register(). 394 * 395 * If @a filename is empty or the data in it is corrupt, 396 * RESOURCE_ERROR_INTERNAL will be returned. If @a filename doesn’t exist, or 397 * there is an error in reading it, an error from Glib::mapped_file_new() will be 398 * returned. 399 * 400 * @newin{2,44} 401 * 402 * @param filename The path of a filename to load, in the GLib filename encoding. 403 * @return A new Resource, or <tt>nullptr</tt> on error. 404 * 405 * @throws Glib::Error 406 */ 407 static Glib::RefPtr<Resource> create_from_file(const std::string& filename); 408 409 /** Looks for a file at the specified @a path in the resource and 410 * returns a InputStream that lets you read the data. 411 * 412 * @a lookup_flags controls the behaviour of the lookup. 413 * 414 * @newin{2,44} 415 * 416 * @param path A pathname inside the resource. 417 * @param lookup_flags A ResourceLookupFlags. 418 * @return InputStream or <tt>nullptr</tt> on error. 419 * Free the returned object with Glib::object_unref(). 420 * 421 * @throws Glib::Error 422 */ 423 Glib::RefPtr<InputStream> open_stream(const std::string& path, ResourceLookupFlags lookup_flags = RESOURCE_LOOKUP_FLAGS_NONE) const; 424 425 /** Looks for a file at the specified @a path in the resource and 426 * returns a Bytes that lets you directly access the data in 427 * memory. 428 * 429 * The data is always followed by a zero byte, so you 430 * can safely use the data as a C string. However, that byte 431 * is not included in the size of the GBytes. 432 * 433 * For uncompressed resource files this is a pointer directly into 434 * the resource bundle, which is typically in some readonly data section 435 * in the program binary. For compressed files we allocate memory on 436 * the heap and automatically uncompress the data. 437 * 438 * @a lookup_flags controls the behaviour of the lookup. 439 * 440 * @newin{2,44} 441 * 442 * @param path A pathname inside the resource. 443 * @param lookup_flags A ResourceLookupFlags. 444 * @return Bytes or <tt>nullptr</tt> on error. 445 * Free the returned object with Glib::bytes_unref(). 446 * 447 * @throws Glib::Error 448 */ 449 Glib::RefPtr<const Glib::Bytes> lookup_data(const std::string& path, ResourceLookupFlags lookup_flags = RESOURCE_LOOKUP_FLAGS_NONE) const; 450 451 452 /** Returns all the names of children at the specified @a path in the resource. 453 * 454 * If @a path is invalid or does not exist in the Resource, 455 * RESOURCE_ERROR_NOT_FOUND will be returned. 456 * 457 * @a lookup_flags controls the behaviour of the lookup. 458 * 459 * @newin{2,44} 460 * 461 * @param path A pathname inside the resource. 462 * @param lookup_flags A ResourceLookupFlags. 463 * @return An array of constant strings. 464 * 465 * @throws Glib::Error 466 */ 467 std::vector<std::string> enumerate_children(const std::string& path, ResourceLookupFlags lookup_flags = RESOURCE_LOOKUP_FLAGS_NONE) const; 468 469 /** Looks for a file at the specified @a path in the resource and 470 * if found returns information about it. 471 * 472 * @a lookup_flags controls the behaviour of the lookup. 473 * 474 * @newin{2,44} 475 * 476 * @param path A pathname inside the resource. 477 * @param[out] size A location to place the length of the contents of the file. 478 * @param[out] flags A location to place the flags about the file. 479 * @param lookup_flags A ResourceLookupFlags. 480 * @throw Gio::ResourceError if the file was not found. 481 */ 482 void get_info(const std::string& path, gsize& size, ResourceFlags& flags, ResourceLookupFlags lookup_flags = RESOURCE_LOOKUP_FLAGS_NONE) const; 483 484 485 /** Looks for a file at the specified @a path in the resource. 486 * 487 * @a lookup_flags controls the behaviour of the lookup. 488 * 489 * @newin{2,44} 490 * 491 * @param path A pathname inside the resource. 492 * @param lookup_flags A ResourceLookupFlags. 493 * @throw Gio::ResourceError if the file was not found. 494 */ 495 void get_file_exists(const std::string& path, ResourceLookupFlags lookup_flags = RESOURCE_LOOKUP_FLAGS_NONE) const; 496 497 /** Looks for a file at the specified @a path in the resource. 498 * 499 * @a lookup_flags controls the behaviour of the lookup. 500 * This method returns a <tt>bool</tt> instead of throwing in exception in case of errors. 501 * 502 * @newin{2,44} 503 * 504 * @param path A pathname inside the resource. 505 * @param lookup_flags A ResourceLookupFlags. 506 * @return <tt>true</tt> if the file was found, <tt>false</tt> if there were errors. 507 */ 508 bool get_file_exists_nothrow(const std::string& path, ResourceLookupFlags lookup_flags = RESOURCE_LOOKUP_FLAGS_NONE) const; 509 510 // 'register' is a keyword. Can't be the name of a method. 511 512 /** Registers the resource with the process-global set of resources. 513 * Once a resource is registered the files in it can be accessed 514 * with the global resource lookup functions like g_resources_lookup_data(). 515 * 516 * @newin{2,44} 517 */ 518 void register_global(); 519 520 /** Unregisters the resource from the process-global set of resources. 521 * 522 * @newin{2,44} 523 */ 524 void unregister_global(); 525 526 /** Looks for a file at the specified @a path in the set of 527 * globally registered resources and returns a InputStream 528 * that lets you read the data. 529 * 530 * @a lookup_flags controls the behaviour of the lookup. 531 * 532 * @newin{2,44} 533 * 534 * @param path A pathname inside the resource. 535 * @param lookup_flags A ResourceLookupFlags. 536 * @return InputStream or <tt>nullptr</tt> on error. 537 * Free the returned object with Glib::object_unref(). 538 * 539 * @throws Glib::Error 540 */ 541 static Glib::RefPtr<InputStream> open_stream_global(const std::string& path, ResourceLookupFlags lookup_flags = RESOURCE_LOOKUP_FLAGS_NONE); 542 543 /** Looks for a file at the specified @a path in the set of 544 * globally registered resources and returns a Bytes that 545 * lets you directly access the data in memory. 546 * 547 * The data is always followed by a zero byte, so you 548 * can safely use the data as a C string. However, that byte 549 * is not included in the size of the GBytes. 550 * 551 * For uncompressed resource files this is a pointer directly into 552 * the resource bundle, which is typically in some readonly data section 553 * in the program binary. For compressed files we allocate memory on 554 * the heap and automatically uncompress the data. 555 * 556 * @a lookup_flags controls the behaviour of the lookup. 557 * 558 * @newin{2,44} 559 * 560 * @param path A pathname inside the resource. 561 * @param lookup_flags A ResourceLookupFlags. 562 * @return Bytes or <tt>nullptr</tt> on error. 563 * Free the returned object with Glib::bytes_unref(). 564 * 565 * @throws Glib::Error 566 */ 567 static Glib::RefPtr<const Glib::Bytes> lookup_data_global(const std::string& path, ResourceLookupFlags lookup_flags = RESOURCE_LOOKUP_FLAGS_NONE); 568 569 /** Returns all the names of children at the specified @a path in the set of 570 * globally registered resources. 571 * 572 * @a lookup_flags controls the behaviour of the lookup. 573 * 574 * @newin{2,44} 575 * 576 * @param path A pathname inside the resource. 577 * @param lookup_flags A ResourceLookupFlags. 578 * @return An array of constant strings. 579 * 580 * @throws Glib::Error 581 */ 582 static std::vector<std::string> enumerate_children_global(const std::string& path, ResourceLookupFlags lookup_flags = RESOURCE_LOOKUP_FLAGS_NONE); 583 584 /** Looks for a file at the specified @a path in the set of 585 * globally registered resources and if found returns information about it. 586 * 587 * @a lookup_flags controls the behaviour of the lookup. 588 * 589 * @newin{2,44} 590 * 591 * @param path A pathname inside the resource. 592 * @param[out] size A location to place the length of the contents of the file. 593 * @param[out] flags A location to place the flags about the file. 594 * @param lookup_flags A ResourceLookupFlags. 595 * @throw Gio::ResourceError if the file was not found. 596 */ 597 static void get_info_global(const std::string& path, gsize& size, ResourceFlags& flags, ResourceLookupFlags lookup_flags = RESOURCE_LOOKUP_FLAGS_NONE); 598 599 600 /** Looks for a file at the specified @a path in the set of 601 * globally registered resources. 602 * 603 * @a lookup_flags controls the behaviour of the lookup. 604 * 605 * @newin{2,44} 606 * 607 * @param path A pathname inside the resource. 608 * @param lookup_flags A ResourceLookupFlags. 609 * @throw Gio::ResourceError if the file was not found. 610 */ 611 static void get_file_exists_global(const std::string& path, ResourceLookupFlags lookup_flags = RESOURCE_LOOKUP_FLAGS_NONE); 612 613 /** Looks for a file at the specified @a path in the set of 614 * globally registered resources. 615 * 616 * @a lookup_flags controls the behaviour of the lookup. 617 * This method returns a <tt>bool</tt> instead of throwing in exception in case of errors. 618 * 619 * @newin{2,44} 620 * 621 * @param path A pathname inside the resource. 622 * @param lookup_flags A ResourceLookupFlags. 623 * @return <tt>true</tt> if the file was found, <tt>false</tt> if there were errors. 624 */ 625 static bool get_file_exists_global_nothrow(const std::string& path, ResourceLookupFlags lookup_flags = RESOURCE_LOOKUP_FLAGS_NONE); 626 627 628 }; 629 630 } // namespace Gio 631 632 633 namespace Glib 634 { 635 636 /** A Glib::wrap() method for this object. 637 * 638 * @param object The C instance. 639 * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref. 640 * @result A C++ instance that wraps this C instance. 641 * 642 * @relates Gio::Resource 643 */ 644 GIOMM_API 645 Glib::RefPtr<Gio::Resource> wrap(GResource* object, bool take_copy = false); 646 647 } // namespace Glib 648 649 650 #endif /* _GIOMM_RESOURCE_H */ 651 652