Question

I want to write a software for managing recipes. The recipes are valid standalone xml files. They contain string and integer values and image data (in a base64 representation). The user should be able to create/open, edit and save recipes. Now I have concerns about file management and efficiency (speed and memory).

  1. How should I manage all the recipes? I think I could either store them all as plain xml files in a folder, or have them all in one library file of some sort. The first approach might be faster on startup, as the recipes are loaded when the user clicks them, e.g. in a QTreeView. The second approach might be more efficient and fast because the whole library would be kept in memory, although it could be more complex to change its contents.

  2. I want to use DOM for xml file handling - or would QXmlStreamReader/writer be a better choice here?

  3. Either way, I would have to manage the recipe data using unique IDs, e.g. for several different "Cookies" recipes. When using the first approach from question 1., I would use file names based on such an ID. Are there any convenient ways to create unique IDs? Because when using incrementing integers I'd have to track which numbers are already in use.

Was it helpful?

Solution

I'm using XML files for transferring recipes in my recipe program. I have options to import and export using XML.

I am using a database to store the recipes. I do not use XML data files to store recipes. I'll leave data management to the database (I'm not wasting my time writing and debugging a database).

For data storage, there more efficient file formats than XML. Also, you may want to create "index tables" which allow for sorted and more efficient access to files than having to always parse an XML file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top