00001 /****************************************************************************** 00002 * swconfig.h - definition of Class SWConfig used for saving and retrieval 00003 * of configuration information 00004 * 00005 * $Id: swconfig.h 2180 2008-07-13 20:29:25Z scribe $ 00006 * 00007 * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org) 00008 * CrossWire Bible Society 00009 * P. O. Box 2528 00010 * Tempe, AZ 85280-2528 00011 * 00012 * This program is free software; you can redistribute it and/or modify it 00013 * under the terms of the GNU General Public License as published by the 00014 * Free Software Foundation version 2. 00015 * 00016 * This program is distributed in the hope that it will be useful, but 00017 * WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 * General Public License for more details. 00020 * 00021 */ 00022 00023 #ifndef SWCONFIG_H 00024 #define SWCONFIG_H 00025 00026 #include <map> 00027 00028 #include <defs.h> 00029 #include <multimapwdef.h> 00030 #include <swbuf.h> 00031 00032 SWORD_NAMESPACE_START 00033 00034 typedef multimapwithdefault < SWBuf, SWBuf, std::less < SWBuf > >ConfigEntMap; 00035 typedef std::map < SWBuf, ConfigEntMap, std::less < SWBuf > >SectionMap; 00036 00040 class SWDLLEXPORT SWConfig { 00041 private: 00042 char getline(int fd, SWBuf &line); 00043 public: 00047 SWBuf filename; 00051 SectionMap Sections; 00052 00056 SWConfig(const char *ifilename); 00057 SWConfig(); 00058 virtual ~SWConfig(); 00059 00063 virtual void Load(); 00064 00068 virtual void Save(); 00069 00073 virtual void augment(SWConfig &addFrom); 00074 virtual SWConfig & operator +=(SWConfig &addFrom) { augment(addFrom); return *this; } 00075 00085 virtual ConfigEntMap & operator [](const char *section); 00086 }; 00087 SWORD_NAMESPACE_END 00088 #endif
1.6.1