Click here to Skip to main content
12,896,953 members (52,889 online)
Click here to Skip to main content


44 bookmarked
Posted 3 Jan 2006

INI file reader using the spirit library

, 3 Jan 2006 CPOL
A simple implementation of an INI file reader using the boost::spirit framework
#ifndef _INI_FILE_H_
#define _INI_FILE_H_

struct Entry
	string name;
	string value;

struct Category
	string name;
	vector<Entry> entries;

typedef vector<Category> CategoryList;

class CIniFile
	CategoryList m_file;
	int m_crt_category;
	int m_crt_entry;
	int b_CategoryIsValid();
	int b_EntryIsValid();

	void ClearAll();

	int m_status;
	void LoadFile(string filename);
	void SaveToFile(string filename);

	int GetNumCategories();
	void SetCategory(int cat);
	int SetCategory(string name);
	string GetCategoryName();
	void AddCategoryUnique(string name);
	void AddCategory(string name);

	int GetNumEntries();
	void SetEntry(int entry);
	int SetEntry(string name);
	int SetEntryByValue(string value);

	string GetEntryName();
	string GetEntryValue();
	string GetEntryValueByName(string name);
	void AddEntryUnique(string name, string value);
	void AddEntry(string name, string value);
	void ChangeEntry(string name, string value);
	void SetValue(string value);

	void DeleteEntry(string name);
	void DeleteEntry(int entry);
	void DeleteByValue(string value);



By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Silviu Simen
Software Developer
Canada Canada
No Biography provided

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170424.1 | Last Updated 3 Jan 2006
Article Copyright 2006 by Silviu Simen
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid