From 7c682a8a12dd14ce90c589bb944876772e05745d Mon Sep 17 00:00:00 2001 From: darkeye Date: Thu, 9 Nov 2000 22:08:17 +0000 Subject: [PATCH] added function getForSure --- darkice/trunk/src/ConfigSection.cpp | 23 +++++++++++++++++++++++ darkice/trunk/src/ConfigSection.h | 11 +++++++++++ 2 files changed, 34 insertions(+) diff --git a/darkice/trunk/src/ConfigSection.cpp b/darkice/trunk/src/ConfigSection.cpp index 52ae4e2..9ed0b3c 100644 --- a/darkice/trunk/src/ConfigSection.cpp +++ b/darkice/trunk/src/ConfigSection.cpp @@ -107,6 +107,26 @@ ConfigSection :: get ( const char * key ) const throw ( Exception ) } +/*------------------------------------------------------------------------------ + * Get a value for a key, in the key does not exist, throw an exception + *----------------------------------------------------------------------------*/ +const char * +ConfigSection :: getForSure ( const char * key, + const char * message1 = 0, + const char * message2 = 0, + int code = 0 ) const + throw ( Exception ) +{ + const char * value; + + if ( !(value = get( key)) ) { + throw Exception( __FILE__, __LINE__, key, message1, message2, code); + } + + return value; +} + + /*------------------------------------------------------------------------------ * Add a configuration line *----------------------------------------------------------------------------*/ @@ -160,6 +180,9 @@ ConfigSection :: addLine ( const char * line ) throw ( Exception ) $Source$ $Log$ + Revision 1.2 2000/11/09 22:08:17 darkeye + added function getForSure + Revision 1.1 2000/11/08 17:29:50 darkeye added configuration file reader diff --git a/darkice/trunk/src/ConfigSection.h b/darkice/trunk/src/ConfigSection.h index 1776c82..23b2827 100644 --- a/darkice/trunk/src/ConfigSection.h +++ b/darkice/trunk/src/ConfigSection.h @@ -117,6 +117,14 @@ class ConfigSection : public virtual Referable get ( const char * key ) const throw ( Exception ); + virtual const char * + getForSure ( const char * key, + const char * message1 = 0, + const char * message2 = 0, + int code = 0 ) const + throw ( Exception ); + + virtual bool addLine ( const char * line ) throw ( Exception ); }; @@ -137,6 +145,9 @@ class ConfigSection : public virtual Referable $Source$ $Log$ + Revision 1.2 2000/11/09 22:08:17 darkeye + added function getForSure + Revision 1.1 2000/11/08 17:29:50 darkeye added configuration file reader