3594. Doc / View - an ini-like save system
- This demo shows how to use a small class, CIni, to load and save documents using a ini-file like system. The standard serialization way is nice and easy to use .. your nightmare starts when you have to read files made with another application.
Sometimes, when the data to be saved are few and simple, it would be nicer to save them in a simple text file. The old function to write/read from ini files are dangerous to use, since help says they may be mapped in the registry. This class organize datas using Section, keywords and values and permits to use bool, string, multiline string, double, float, long, int, CRect, CPoint and COLORREF.
这个演示程序演示了如何使用一个类,CIni,来加载和保存文档,类似于一个ini文件。标准的序列化很好,且易于使用,但当你必须读取其它应用程序生成的文件时,就遇到了大麻烦。
有时,当需要保存的数据很少且较简单时,使用一个简单的文本文件就可以完成任务。以前读写ini的函数使用起来很危险,帮助文件说它们可以映射到注册表。这个类使用分段、关键字和值来组织数据,可以使用布尔型、字符串、多行文本字符串,双精度数、浮点数、长整型数、整型、 CRect, CPoint 和 COLORREF。
来源: http://www.codeguru.com/doc_view/cini.shtml |