FLTK logo

[fltk.general] Re: Simple way to copy fltk prefs to runtime prefs

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Simple way to copy fltk prefs to runtime prefs "anmol.... Apr 25, 2021  
 
I have this from another thread - https://groups.google.com/g/fltkgeneral/c/QnCEjdgiIPc/m/DCilrsHVAgAJ

ATM, I am using this. Just wondering if there is an API call I am missing.

  void copyGroup_(Fl_Preferences& src, Fl_Preferences& dst)
  {
      for (int i = 0; i < src.groups(); ++i) {
          Fl_Preferences s(src, i);
          Fl_Preferences d(dst, s.name());
          copyGroup_(s, d);
      }
      for (int i = 0; i < src.entries(); ++i) {
          const char* name = src.entry(i);
          char* data;
          src.get(name, data, "");
          dst.set(name, data);
          ::free(data);
      }
  }

copyPrefs() {
  Fl_Preferences srcFile(Fl_Preferences::USER, "fltk.org", "Hello");
  Fl_Preferences dstFile("/Users/matt/test.cfg", "matthiasm.com", "export");
  copyGroup_(srcFile, dstFile);
}


On Sunday, April 25, 2021 at 10:53:45 PM UTC+5:30 anmol....@gmail.com wrote:

    prefsP_= new Fl_Preferences(Fl_Preferences::USER, vendor, product);
    dataP_ = new Fl_Preferences(nullptr, "Runtime");

As we know, prefsP_ is written to HDD. dataP_ is only maintained in memory. In my code design, I'd like to make an identical copy of prefsP_ as runtime. The user can access these values without disk access and modify them as needed.

Only values that need to be saved will be written to HDD via prefsP_

Is there an API call like -  copy (prefsP_, dataP_) or something similar ?

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/b5aeee71-c047-431c-86de-7876274e1122n%40googlegroups.com.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.