gtkmm load from resource plain text file

Stack Overflow Asked by Tophyd Ayur on December 19, 2020

I have a simple resource xml file looks like

<?xml version="1.0" encoding="UTF-8" ?>
    <gresource prefix="ui"> 
        <file preprocess="xml-stripblanks"></file>
    <gresource prefix="text-data">

And UI loaded without problem


But I do not know how to load and read the text file that is defined in the resource file as "definition.txt".

One Answer

You are able to retrieve the file contents with one of two static methods of Gio::Resource class: open_stream_global or lookup_data_global. Here are their signatures:

  • Glib::RefPtr< InputStream > open_stream_global (const std::string& path, ResourceLookupFlags lookup_flags=RESOURCE_LOOKUP_FLAGS_NONE)
  • Glib::RefPtr< const Glib::Bytes > lookup_data_global (const std::string& path, ResourceLookupFlags lookup_flags=RESOURCE_LOOKUP_FLAGS_NONE)

As you can see, the difference between them is how you access data: via a Gio stream class or Glib::Bytes (a "data array": byte contents + length).

Answered by RodolfoRG on December 19, 2020

Add your own answers!

Related Questions

Choice on a list affects the following duplicated list

0  Asked on December 11, 2021 by mrtsm


How can I change server in spring boot application?

4  Asked on December 11, 2021 by vikram-shekhawat


How to modify ggplot2 legend keys?

3  Asked on December 11, 2021 by philippe-massicotte


Split JSON to multiple Objects

2  Asked on December 11, 2021 by marcio-lino


Angular/Typescript Text with routerLink

2  Asked on December 11, 2021 by dotnet


How to use multiple factors in na.aggregate() from zoo package

1  Asked on December 11, 2021 by shadrack-kibet


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP