Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

ReadConfig.C

Go to the documentation of this file.
00001 // Copyright (C) 2001, Compaq Computer Corporation
00002 // 
00003 // This file is part of Vesta.
00004 // 
00005 // Vesta is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 // 
00010 // Vesta is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with Vesta; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 // Last modified on Tue Aug  3 17:01:04 EDT 2004 by ken@xorian.net  
00020 //      modified on Sat Feb 12 12:02:04 PST 2000 by mann  
00021 //      modified on Fri Aug  8 14:46:02 PDT 1997 by heydon
00022 
00023 #include <stdio.h>
00024 #include <Basics.H>
00025 #include <VestaConfig.H>
00026 #include "ReadConfig.H"
00027 
00028 using std::cerr;
00029 using std::endl;
00030 
00031 void DieWithError(const Text &msg) throw () {
00032   cerr << "Fatal error: " << msg << endl;
00033   exit(1);
00034 }
00035 
00036 Text ReadConfig::Location() throw ()
00037 {
00038     try {
00039         return VestaConfig::get_location();
00040     } catch (VestaConfig::failure f) {
00041         DieWithError("failed to locate Vesta-2 configuration file");
00042     }
00043     return ""; // not reached
00044 }
00045 
00046 Text ReadConfig::TextVal(const Text& sect, const Text& nm) throw ()
00047 {
00048     Text res;
00049     try {
00050         res = VestaConfig::get_Text(sect, nm);
00051     } catch (VestaConfig::failure f) {
00052         DieWithError(f.msg);
00053     }
00054     return res;
00055 }
00056 
00057 int ReadConfig::IntVal(const Text& sect, const Text& nm) throw ()
00058 {
00059     int res;
00060     try {
00061         res = VestaConfig::get_int(sect, nm);
00062     } catch (VestaConfig::failure f) {
00063         DieWithError(f.msg);
00064     }
00065     return res;
00066 }
00067 
00068 bool ReadConfig::OptIntVal(const Text& sect, const Text& nm, int& val) throw ()
00069 {
00070     bool res;
00071     try {
00072         Text dummy;
00073         if ((res = VestaConfig::get(sect, nm, dummy))) {
00074             val = VestaConfig::get_int(sect, nm);
00075         }
00076     } catch (VestaConfig::failure f) {
00077         DieWithError(f.msg);
00078     }
00079     return res;
00080 }
00081 
00082 bool ReadConfig::OptBoolVal(const Text& sect, const Text& nm, bool& val)
00083   throw ()
00084 {
00085     bool res;
00086     try {
00087         Text dummy;
00088         if ((res = VestaConfig::get(sect, nm, dummy))) {
00089             int int_val = VestaConfig::get_int(sect, nm);
00090             val = (int_val != 0) ? true : false;
00091         }
00092     } catch (VestaConfig::failure f) {
00093         DieWithError(f.msg);
00094     }
00095     return res;
00096 }

Generated on Mon May 8 00:48:32 2006 for Vesta by  doxygen 1.4.2