Loading/Saving documents

Hey again guys. I trying to understand how load and save documents. I was looking for demo project in extra folder, but I don’t understand them very well.

I think that I must create a class “document” that inherit to FileBasedDocument. Ok. Now, I implement the pure virtual method. Between them there’re two that I think that they’re the point about loading/saving: “loadDocument” and “saveDocument”.

The questions are:

  • must I implement a method that can create (loadDocument) and read (saveDocument) objects in my program?
  • usually the comercial programs doesn’t save their “objects” in a text file, but in another unreadable format. I think that they save it in unreadable format because it has more advantages… so… how should I do this?

Thanks you :slight_smile:

answer to question 1. is ofcourse

answer to question 2. is: unreadable does not mean better. Binary formats are better when you need to load a lot of data, fast. XML is better because it’s readable and more flexible. it’s up to you to chose your format, juce can do both.

Thx for answer, really. However I continue struggling. The code for save in “jucer” is too big and I’ve problems understanding.

With FileBasedDocument, can I save in both formats? XML and binary? where could I see an small example about how to load/save an object?

btw, is there any book or extensive tutorial where I can learn Juce? I know how program in c++ but juce hates me! It would be nice that juce reference would have more simple examples.

there was a tutorial in PDF on Juce somewhere here (look at the sticky topics).

As far as save/load you need to write your own methods, serialize and unserialize data and write/read it somewhere.