Slice Tools
  • Home
  • SourceForge Page


  • libFoundation
  • Home
  • Class Hierarchy
  • Class List
  • Class Members
  • Examples


  • SourceForge.net Logo
     

    ConfigSection.hh

    Go to the documentation of this file.
    00001 // $Id: ConfigSection.hh,v 1.1 2005/07/29 02:55:15 mschatz Exp $
    00002 
    00005 
    00006 #ifndef CONFIGSECTION_HH
    00007 #define CONFIGSECTION_HH 1
    00008 
    00009 #include <map>
    00010 #include <list>
    00011 #include <string>
    00012 #include <iostream>
    00013 
    00014 #include "Exceptions.hh"
    00015 
    00016 // Predeclare to avoid circular references
    00017 class ConfigFile;
    00018 
    00020 class ConfigSection
    00021 {
    00022 public:
    00023   ConfigSection(ConfigSection * parent, std::string sectionName);
    00024   ~ConfigSection();
    00025 
    00026   ConfigSection * findSection(std::string sectionName);
    00027   void printSection(int indentLevel=0, std::ostream & os=std::cout);
    00028 
    00029   std::string getSectionName();
    00030   std::string getFullSectionName();
    00031   std::string getFullVariableName(std::string variableName);
    00032 
    00033   ConfigSection * getNextSection();
    00034   std::string getNextVariable();
    00035 
    00036   std::string getValue(std::string variableName);
    00037   bool hasVariable(std::string variableName);
    00038 
    00039   void resetIterators();
    00040 
    00041 protected:
    00042   ConfigSection * addNewSection(std::string sectionName);
    00043 
    00044   void resolveSubstitutions();
    00045   void addVariable(const char * varLine);
    00046   static std::string parseSectionName(const char * sectionName);
    00047  
    00048 private:
    00049   void addSection(ConfigSection * newSection);
    00050   static void stripWhitespace(std::string & val);
    00051   std::string getIndent(int indentlevel);
    00052 
    00053   std::string getBaseSectionName(std::string sectionName);
    00054   std::string getSubSectionName(std::string sectionName);
    00055 
    00056   std::string resolveVariable(std::string searchval, std::string searchVariable);
    00057   std::list<ConfigSection *> m_sectionList;
    00058   std::list<ConfigSection *>::const_iterator m_sectionListIter;
    00059 
    00060   std::map<std::string, std::string> m_valueMap;
    00061   std::map<std::string, std::string>::const_iterator m_valueMapIter;
    00062 
    00063   std::string m_sectionName;
    00064   ConfigSection * m_parent;
    00065 
    00066   // ConfigFile can load the config file without exposing the
    00067   // entire interface to underling application
    00068 friend class ConfigFile;
    00069 };
    00070 
    00071 
    00072 #endif