DeSR Dependency Parser |
00001 /* 00002 ** IXE C++ Library 00003 ** ixe/conf_float.cpp 00004 ** ---------------------------------------------------------------------- 00005 ** Copyright (c) 2000 Ideare SpA. 00006 ** Copyright (c) 2000 Giuseppe Attardi (attardi@di.unipi.it). 00007 ** ---------------------------------------------------------------------- 00008 ** 00009 ** This file is part of DeSR. 00010 ** 00011 ** DeSR is free software; you can redistribute it and/or modify it 00012 ** under the terms of the GNU General Public License, version 3, 00013 ** as published by the Free Software Foundation. 00014 ** 00015 ** DeSR is distributed in the hope that it will be useful, 00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 ** GNU General Public License for more details. 00019 ** 00020 ** You should have received a copy of the GNU General Public License 00021 ** along with this program. If not, see <http://www.gnu.org/licenses/>. 00022 ** ---------------------------------------------------------------------- 00023 */ 00024 00025 // Settings 00026 #include "conf/conf_float.h" 00027 00028 // standard 00029 #include <iostream> 00030 #include <stdlib.h> 00031 00032 // local 00033 #include "text/strings.h" 00034 00035 using namespace std; 00036 using namespace Tanl::Text; 00037 00038 namespace IXE { 00039 00040 //============================================================================= 00048 //============================================================================= 00049 conf<float>::conf(char const *name, float default_value) 00050 : VarDefault<float>(name, default_value) 00051 { } 00052 00053 //============================================================================= 00059 //============================================================================= 00060 conf<float>& 00061 conf<float>::operator =(float new_value) 00062 { 00063 value = new_value; 00064 return *this; 00065 } 00066 00067 //============================================================================= 00076 //============================================================================= 00077 /* virtual */ 00078 void 00079 conf<float>::parseValue(char const*& lines) 00080 { 00081 if (!lines || !*lines) { 00082 Configuration::error() << "Configuration error: " << '"' << name() << "\" has no value" << endl; 00083 return; 00084 } 00085 00086 char const* line = next_token_line(lines, " \t\r"); 00087 float const n = ::atof(line); 00088 if (n || *line == '0') { 00089 operator =(n); 00090 return; 00091 } 00092 Configuration::error() << "Configuration error: " << '"' << name() << "\" has a non-numeric value" << endl; 00093 } 00094 00095 } // namespace IXE