From: Christian P. <cp...@us...> - 2005-06-22 11:38:07
|
Update of /cvsroot/pclasses/pclasses2/plugins/ConfigStore/ini In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15277/plugins/ConfigStore/ini Added Files: Makefile.am ConfigStore_ini.cpp Log Message: - Added INI-Style ConfigStore plugin --- NEW FILE: Makefile.am --- INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include $(all_includes) METASOURCES = AUTO pkglib_LTLIBRARIES = ConfigStore_ini.la ConfigStore_ini_la_SOURCES = ConfigStore_ini.cpp ConfigStore_ini_la_LDFLAGS = -module -avoid-version ConfigStore_ini_la_LIBADD = $(top_builddir)/src/libpclasses.la \ $(top_builddir)/src/Unicode/libpclasses_unicode.la \ $(top_builddir)/src/IO/libpclasses_io.la \ $(top_builddir)/src/System/libpclasses_system.la \ $(top_builddir)/src/App/libpclasses_app.la --- NEW FILE: ConfigStore_ini.cpp --- /*************************************************************************** * Copyright (C) 2005 by Christian Prochnow, SecuLogiX GmbH * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "pclasses/IO/IOStream.h" #include "pclasses/IO/IORequest.h" #include "pclasses/IO/IOManager.h" #include "pclasses/System/Plugin.h" #include "pclasses/App/Config.h" #include "pclasses/App/ConfigStore.h" #include <list> using namespace P; using namespace P::IO; using namespace P::App; class ConfigStore_ini: public ConfigStore { public: ConfigStore_ini() throw() { } ~ConfigStore_ini() throw() { } void load() throw(IO::IOError) { } void save() throw(IO::IOError) { IOManager& ioMgr = IOManager::instance(); IORequest_Put* putReq = ioMgr.put(url()); putReq->connect(); IOStream strm(*putReq); section_list sectionContext; saveSection(strm, sectionContext, config()->root()); strm.flush(); putReq->close(); ioMgr.finish(putReq); } private: typedef std::list<const ConfigSection*> section_list; void saveSection(IOStream& strm, section_list& sectionContext, const ConfigSection& section) { ConfigSection::value_const_iterator vi = section.valuesBegin(); while(vi != section.valuesEnd()) { strm << vi->first << " = " << vi->second.value().utf8() << std::endl; ++vi; } ConfigSection::section_const_iterator si = section.sectionsBegin(); while(si != section.sectionsEnd()) { sectionContext.push_back(*si); saveSectionName(strm, sectionContext); saveSection(strm, sectionContext, **si); sectionContext.pop_back(); ++si; } } void saveSectionName(IOStream& strm, section_list& sectionContext) { strm << '['; section_list::const_iterator i = sectionContext.begin(); while(i != sectionContext.end()) { strm << (*i)->name(); ++i; if(i != sectionContext.end()) strm << '\\'; } strm << ']' << std::endl; } }; P_PLUGIN_REGISTER_TYPE(ConfigStore, ConfigStore_ini); P_PLUGIN_REGISTER_ALIAS(ConfigStore, ini, ConfigStore_ini); |