Click here to Skip to main content
12,359,102 members (34,220 online)
Click here to Skip to main content

Stats

68.7K views
1.2K downloads
43 bookmarked
Posted

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;
private:
	int b_CategoryIsValid();
	int b_EntryIsValid();

public:
	CIniFile();
	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);


};



#endif

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.

License

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

Share

About the Author

Silviu Simen
Software Developer
Canada Canada
No Biography provided

You may also be interested in...

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