0

I would like to know if it is possible to serialize an object using boost serialization to a file with a custom extension. Instead of a .xml, I would like to create a custom extension, for example .hst and associate a custom icon to the file. The format of the file can stay the same, only I would like to make it more professional by not generating .xml files

DreamTool
  • 149
  • 1
  • 15
  • Just curious... How is it that .xml files are unprofessional? They are one of the most universally used formats. Is there a specific case that this would be beneficial? Just seems that you are asking to add an overly large amount of complexity without any gain. – Lilith Daemon Jul 14 '15 at 21:14
  • What you say is true, and I don't think .xml is unprofessional, but I would like to create a software that has its own file extension so that the files saved are easier to recognize. – DreamTool Jul 14 '15 at 21:18
  • As I understand your question, this is trivially possible by constructing the output stream with something like `std::ofstream ofs("filename.hst");`. Can you explain what you mean? – George Hilliard Jul 14 '15 at 21:24
  • I will look and see if I can find something, honestly this is such an obscure thing I don't know the answer off the top of my head. Also keep in mind, if you intend to distribute your application, a great deal of file extensions are used for one thing or another. You mentioned .hst, this is often used for log files. Checkout sites like filext.com to see if it is already used for something else. – Lilith Daemon Jul 14 '15 at 21:26
  • Also overwriting an end-user's file extensions is one of the fastest ways to trigger an "uninstall" response. – Lilith Daemon Jul 14 '15 at 21:28
  • Great Rootix, I will make sure the extension I choose is not already used, or at least largely used. I mentioned .hst because that would fit well with the name of the software, but that was just an example. – DreamTool Jul 15 '15 at 13:08

1 Answers1

0

According to this tutorial for property tree, you should be able to parse any file regardless of the actual file extension.

http://www.boost.org/doc/libs/1_42_0/doc/html/boost_propertytree/tutorial.html

As I am sure you are aware, the file extension is merely an indicator of what the file is, and does not actually affect the content of the file. However as I advised earlier, I would be careful of deviating from pre-existing file extension standards as you may cause issues on the end-user's system. Without great need, I would highly recommend you refrain from deviating on standards. If you MUST use custom extensions, be sure to look and see if your proposed extension is used for something else. Checkout sites such as:

http://filext.com/

http://fileinfo.com/

And other such databases.

Lilith Daemon
  • 1,473
  • 1
  • 19
  • 37
  • Thank you Rootix. With further researches, I discovered that I could generate a file with a custom extension only by changing the value of Filter property of the SaveFileDialog that is opened when choosing the output file. I will ask a new question to know how to add a custom icon to the file. – DreamTool Jul 15 '15 at 14:22
  • @DreamTool Happy to be of assistance. When setting an icon for the file extension, be sure to specify the operating system. This will allow a more concise answer. Good luck :) – Lilith Daemon Jul 15 '15 at 14:37