rllib  1
rlinifile.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                           rlinifile.h  -  description
00003                              -------------------
00004     begin                : Tue Jan 02 2001
00005     copyright            : (C) 2001 by Rainer Lehrig
00006     email                : lehrig@t-online.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This library is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as        *
00013  *   published by the Free Software Foundation                             *
00014  *                                                                         *
00015  ***************************************************************************/
00016 #ifndef _RL_INI_FILE_H_
00017 #define _RL_INI_FILE_H_
00018 
00019 #include "rldefine.h"
00020 #include "rlstring.h"
00021 
00025 class rlIniFile
00026 {
00027 public:
00028   rlIniFile();
00029   virtual ~rlIniFile();
00030   int read(const char *filename);
00031   int write(const char *filename);
00032   const char *filename();
00033   const char *text(const char *section, const char *name);
00034   void setText(const char *section, const char *name, const char *text);
00035   int  printf(const char *section, const char *name, const char *format, ...);
00036   void remove(const char *section);
00037   void remove(const char *section, const char *name);
00038   const char *firstSection();
00039   const char *nextSection();
00040   const char *firstName(const char *section);
00041   const char *nextName(const char *section);
00042   void setDefaultSection(const char *section);
00043   const char *defaultSection();
00051   const char *i18n(const char *tag, const char *default_text);
00088   const char *tr(const char *txt);
00089 private:
00090   typedef struct _rlSectionName_
00091   {
00092     _rlSectionName_ *nextName;
00093     char            *name;
00094     char            *param;
00095   }rlSectionName;
00096 
00097   typedef struct _rlSection_
00098   {
00099     _rlSection_   *nextSection;
00100     rlSectionName *firstName;
00101     char          *name;
00102   }rlSection;
00103 
00104   void copyIdentifier(char *buf, const char *line);
00105   void copyName(char *buf, const char *line);
00106   void copyParam(char *buf, const char *line);
00107   void deleteSectionNames(rlSection *section);
00108   rlSection *_firstSection;
00109   int currentSection, currentName;
00110   rlString fname;
00111   rlString default_section;
00112 };
00113 
00114 #endif