ini_config.h

Go to the documentation of this file.
00001 #ifndef INI_CONFIGURATOR_CLASS
00002 #define INI_CONFIGURATOR_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : ini_configurator                                                  *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 2000-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00019 
00020 #include "opsysdll.h"
00021 
00022 #include <basis/object_base.h>
00023 #ifdef __WIN32__
00024   #include <data_struct/configurator.h>
00025 #else
00026   #include "ini_parser.h"
00027 #endif
00028 
00029 // forward.
00030 class byte_filer;
00031 class filename;
00032 
00033 class OPSYSTEM_CLASS_STYLE ini_configurator : public configurator
00034 {
00035 public:
00037 
00044   enum file_location_default {
00045     APPLICATION_DIRECTORY,  
00046     OS_DIRECTORY,  
00047     ALL_USERS_DIRECTORY  
00048   };
00049 
00050   ini_configurator(const istring &ini_filename,
00051           treatment_of_defaults behavior = RETURN_ONLY,
00052           file_location_default where = ALL_USERS_DIRECTORY);
00054 
00058   virtual ~ini_configurator();
00059 
00060   IMPLEMENT_CLASS_NAME("ini_configurator");
00061 
00062   istring name() const;
00064   void name(const istring &name);
00066 
00067   virtual bool get(const istring &section, const istring &entry,
00068           istring &found);
00070 
00073   virtual void sections(string_array &list);
00075 
00076   virtual bool section_exists(const istring &section);
00078 
00080   virtual bool put(const istring &section, const istring &entry,
00081           const istring &to_store);
00083 
00084   virtual bool delete_section(const istring &section);
00086 
00087   virtual bool delete_entry(const istring &section, const istring &entry);
00089 
00090   virtual bool get_section(const istring &section, string_table &info);
00092 
00094   virtual bool put_section(const istring &section, const string_table &info);
00096 
00099   // dictates whether the stored entries will have spaces between '='
00100   // and the key name and value.  only applicable on linux.
00101   bool add_spaces() const { return _add_spaces; }
00102   void add_spaces(bool add_them) { _add_spaces = add_them; }
00103 
00104 private:
00105   filename *_ini_name;  
00106 #ifdef __UNIX__
00107   ini_parser *_parser;  
00108 #endif
00109   file_location_default _where;  
00110   bool _add_spaces;  
00111 
00112 #ifdef __WIN32__
00113   bool put_profile_string(const istring &section, const istring &entry,
00114           const istring &to_store);
00116   void get_profile_string(const istring &section, const istring &entry,
00117           const istring &default_value, flexichar *return_buffer,
00118           int buffer_size);
00120 #endif
00121 #ifdef __UNIX__
00122   void read_ini_file();
00124   void write_ini_file();
00126 #endif
00127 
00128   // not to be called.
00129   ini_configurator(const ini_configurator &);
00130   ini_configurator &operator =(const ini_configurator &);
00131 
00132   static const istring_object &ini_str_fake_default();
00133 };
00134 
00135 #endif
00136 

Generated on Fri Nov 28 04:29:29 2008 for HOOPLE Libraries by  doxygen 1.5.1