Application-ini and xml configuration files

Source: Internet
Author: User
Tags xml parser

Ini configuration file format

 

Why use the INI file? If our program does not have any configuration files, such a program is completely closed to the outside, once the program needs to modify some parameters, it must modify the program code itself and re-compile, this is very bad, therefore, you must use a configuration file to allow the program to perform necessary configuration after leaving the factory. The configuration file contains many ini configuration files, xml configuration files, and the system registry.

This article provides readers with information about the INI file format before implementing the ini configuration file module.

In the early Windows desktop system, the INI file was mainly used as the system configuration file and switched to the Registry since Win95. However, many system configurations use the INI file. In fact, an INI file is a simple text file, but such a TXT file must follow a certain INI file format. Currently, INI files are often used as configuration files in the wince system. The purpose of this study is to write a system configuration file for the GPS Positioning System Client. ". INI is the abbreviation of the first three letters of the English "initialization". Of course, the suffix of INI file is not necessarily ". ini "or ". cfg ",". conf "or ". TXT ".

 

The format of the INI file is very simple. The three basic elements are parameters, sections, and comments.

What is parameters?

The most basic "element" contained in INI is parameter. Each parameter has a name and a value. The name and value are separated by the equal sign "=. Name is on the left of the equal sign.

For example:

Name = Value

What is sections?

All parameters are combined in units of sections. All section names are exclusive to one row, and their names are surrounded by square brackets ([and]). All parameters after section declaration belong to this section. There is no obvious ending mark for a section. The beginning of a section is the end of the previous section, or the end of the file. In general, sections cannot be nested. In special cases, sections nesting can also be implemented.

Section:

[Section]

 

What is comments?

In the INI file, the Comment statement starts with the Semicolon. All comment statements are exclusive to one row until the end, no matter how long. All contents between the semicolon and the line terminator are ignored.

The annotation example is as follows:

; Comments text

 

Of course, all of the above are the most classic INI file formats, and there are many variants of the INI file format as needed;

INI instance:

; last modified 1 April 2001 by John Doe[owner]name=John Doeorganization=Acme Products [database]server=192.0.2.42     ; use IP address in case network name resolution is not workingport=143file = "acme payroll.dat"
This article Reprinted from: http://blog.163.com/lyzaily@126/blog/static/42438837200911901541762/
You can also refer to the description in the following wiki: http://en.wikipedia.org/wiki/INI_file
In addition, many applications also use XML as the configuration file. Below are some good articles I have collected:
Linux next XML library, libxml2, I used this library before: http://blog.163.com/xs_fantasy/blog/static/101560871201099102157667? Fromdm & fromsearch & isfromsearchengine = Yes
Introduction to using xml configuration files in C ++: http://blog.163.com/lyz_sea/blog/static/11558670720101029799733/
Tinyxml: an excellent C ++ XML Parser: http://dingchaoqun12.blog.163.com/blog/static/116062504201022411023779? Fromdm & fromsearch & isfromsearchengine = Yes
http://zxs19840808.blog.163.com/blog/static/119453558201063103150418/?fromdm&fromSearch&isFromSearchEngine=yes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.