Easy data storage formats for c++ begginners [closed] - c++

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I'm making a c++ program and need a way to store data for users and things like that. I've tried JSON, but the libraries are very difficult to use, at least for a beginner like me. I am looking for a key-value pair type format. JSON work, if I could find an easier library for that.

If you are looking for storage formats for data, then options are -
XML (3rd party libraries available)
JSON (3rd party libraries available)
INI file (key value pair in text file)
CSV format (text file)
Object serialization
etc
Storage mechanisms are -
File store (XML, JSON, CSV as plain text file)
Database (RDBMS, Object store)
In memory objects
Above are few regularly used storage techniques in C++ (and many other languages also).
~Nilesh

Related

How can I programmaticaly change variables in a Word document using C++? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have a Word document which is a template, and inside this document I whish to have some variable fields. Through my program I want to change these values on demand (e.g. calling Word and passing some parameters to it using a C++ program). I've searched a lot but so far I couldn't find good examples of that.
Microsoft Word has a proprietary file format which I imagine will be incredibly tricky to parse programmatically (i.e. by opening the file using an fstream).
If you are keen on using Microsoft products, your best bet may be to use Microsoft Access (a database manager), insert the data you want as a row in some database, and then create some formatted form which uses this data and generates a printable document for you. Here's a useful link: Create Form in Microsoft Access

Flatbuffers usage [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I’m kind of confused how flat buffers work.
I tried looking at the docs but am still confused.
Basically, what I need to do is
Load JSON data (or actually, ANY data format as long as it’s changeable by another user and readable) from a file into a struct or read the fields one by one.
Save the struct back into any readable data format as a file once the app closes
That’s why I’m confused on flatbuffers.
How do you change the file once it’s saved? Is the saved result binary? Or is that not what it was built for?
I’m using RapidJson currently.
The usage is read text data into a struct, when app ends save struct into text that’s modifiable.
Flatbuffers are a compact binary representation of a given data structure, with the promise that it can be used "straight from the wire", without any deserialization after the fact. By contrast, protocol buffers fill the same niche but need to be (de)serialized.
For your purposes, just stick with JSON or YAML, since "readable by humans" is a priority.

C++ multiple big files in one binary file [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
What is an efficient way to store multiple big files (100Mo to 5Go) in one binary file in c++ ?
For example, if I have an audio file, a very large image file, and a text file, I want to create a binary file that contains these three files and be able to retrieve them latter (to recreate the three original files).
Thanks for your help.
Short answer: Yes.
The long answer is it depends on how you want to package these things, what framing you want to use.
Do you need compression? Do you need random access? One way that's easy to implement is just using the zip container, it's well defined and there's a lot of libraries for creating and manipulating them. The same goes for the tar or cpio format.
The alternative is to write your own container format. This is a lot more difficult, you'll have to write an archiver and extractor.

Is there a standard way of storing data for C++ applications? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
In the Java and JavaScript world json files are a standard way of storing complex data objects in files. Does C++ have its own standards in this matter too?
While I would disagree that storing JSON files is a "standard way" (esp. for Java), there are many different ways to achieve that in any language. It totally depends on your actual use case. You can write primitive values to files, key/value pairs of some sort, XML, JSON, YAML, write to a Database, send data to web services, ...
No, there is no standard way for generically storing data to files.
Not really. You could use static data (and have its constructor called, conceptually before main in an unspecified order).
You could also have a big literal string in your file -the raw string literal
feature of C++11 is handy- and have some code (e.g. a constructor which would accept a string encoded in JSON form) parse it.
They are just one way of storing data. Not "standard".
XML is another for example. All of these are available in C++ along with others

Advice on C++ database program [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I want to build a simple program that searches through a local database and returns a list of results. Essentially the program will be a searchable archive. This will be my first project of this type and I'm looking for some advice.
Fast reading of the database is important. Writing can be slow.
There will be at most a few thousand records, and most records will probably contain less than 3 kb in text.
Records should be flexible when it comes to their fields. Some records will have the field "abc", others will not. The number of fields per record may vary.
Should I simply write my data structures in C++, and then serialize them? Does it make sense to use an existing (lightweight) database framework? If so, can you recommend any that are free and easy to use and preferably written in modern C++?
My target platform is Window and I'm using the Visual Studio compiler.
Edit: the consensus is to use SQLite. Any recommendations as to which of the many SQlite C++ wrappers to use?
As commented by #Joachim, I would suggest SQLite. I have used it in C++ projects and it's straightforward to use. You basically put two files in your project sqlite3.c and sqlite3.h and then start coding to the interface (read the last paragraph of http://www.sqlite.org/selfcontained.html). You don't have to worry about configuring a database server. It's fast and lightweight. Read about transactions and SQLite if you need to speed some operations up.