Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

REG file parser using the Boost Spirit Parser Framework

, , 29 Jun 2009 CPOL
This article describes a sample parser of reg files using the Boost Spirit Parser Framework. We'll discuss why we use the curtain libraries and make one or another solution, algorithm, and also tests.
RegFileParser_bin.zip
RegFileParser_bin
bin
RegFileParserAutoTest.exe
RegFileParserTestCmd.exe
RegFileParser_source.zip
RegFileParser_source
src
boost_libs
libboost_program_options-vc90-mt-s-1_38.lib
libboost_program_options-vc90-mt-sgd-1_38.lib
RegFileParserAutoTest
TestFiles
RegFileParserLib
RegFileParserTestCmd
RegFileParserTestCmd.idc
RegFileParser_source_no_boost.zip
RegFileParser_source_no_boost
src
RegFileParserAutoTest
TestFiles
RegFileParserLib
RegFileParserTestCmd
RegFileParserTestCmd.idc
#ifndef __PRINT_OBSERVER_H_INCLUDED__
#define __PRINT_OBSERVER_H_INCLUDED__

#include "IRegFileObserver.hpp"
#include "pool_def.hpp"
#include <string>

namespace reg_parser
{
	
template<class charT,class streamT>
class CRegPrintObserver:public IRegFileObserver<charT>
{
	typedef QString<charT> StringT;

	streamT& out_;
public:
	CRegPrintObserver(streamT& out)
		: out_(out)
	{}

	void OnKeyFound(const charT* begin, const charT* end)
	{
		StringT kname(begin,end);

		out_ << "\n[" << kname.c_str() << "]\n";
	}
	
	void OnValueFound(const charT* nameBegin, const charT* nameEnd,
					  const charT* dataBegin, const charT* dataEnd)
	{
		StringT vname(nameBegin,nameEnd);
		StringT vdata(dataBegin,dataEnd);

		out_ << vname.c_str() 
			 << "="
			 << vdata.c_str()
			 << std::endl;
	}
};

}//namespace reg_parser

#endif // __PRINT_OBSERVER_H_INCLUDED__

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 Authors

Apriorit Inc
Apriorit Inc.
Ukraine Ukraine
ApriorIT is a Software Research and Development company that works in advanced knowledge-intensive scopes.
 
Company offers integrated research&development services for the software projects in such directions as Corporate Security, Remote Control, Mobile Development, Embedded Systems, Virtualization, Drivers and others.
 
Official site http://www.apriorit.com
Group type: Organisation

31 members

Follow on   LinkedIn

Ivan Romanenko
Software Developer Codedgers Inc
Ukraine Ukraine
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.1411023.1 | Last Updated 30 Jun 2009
Article Copyright 2009 by Apriorit Inc, Ivan Romanenko
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid