| 1 | /* This file is part of the FaCT++ DL reasoner |
| 2 | Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester |
| 3 | Copyright (C) 2015-2017 Dmitry Tsarkov |
| 4 | |
| 5 | This library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Lesser General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2.1 of the License, or (at your option) any later version. |
| 9 | |
| 10 | This library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Lesser General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Lesser General Public |
| 16 | License along with this library; if not, write to the Free Software |
| 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | |
| 20 | #include <ostream> |
| 21 | |
| 22 | #include "ifOptions.h"cxx . . $ `<file>/Kernel/ifOptions.h`/ |
| 23 | #include "configure.h"cxx . . $ `<file>/Kernel/configure.h`/ |
| 24 | |
| 25 | bool ifOptioncxx . . $ ifOption# :: setAValuecxx . . $ ifOption#setAValue(7c222eea44a24d43). ( const stdcxx . . $ std/::stringcxx . . $ std/string#& s ) |
| 26 | { |
| 27 | if ( typecxx . . $ ifOption#type. == iotBoolcxx . . $ ifOption#iotBool. ) // check possible boolean values |
| 28 | { |
| 29 | if ( s ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "0" || s ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "off" || s ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "no" || s ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "false" ) |
| 30 | bValuecxx . . $ ifOption#bValue. = false; |
| 31 | else if ( s ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "1" || s ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "on" || s ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "yes" || s ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "true" ) |
| 32 | bValuecxx . . $ ifOption#bValue. = true; |
| 33 | else |
| 34 | return true; |
| 35 | } |
| 36 | else if ( typecxx . . $ ifOption#type. == iotIntcxx . . $ ifOption#iotInt. ) // check possible integer values |
| 37 | { |
| 38 | if ( !isdigit (s[cxx . . $ std/__cxx11/basic_string#`operator[]`(fe0a407a03ea4a2d).0]) ) |
| 39 | return true; |
| 40 | else |
| 41 | iValuecxx . . $ ifOption#iValue. = stoicxx . . $ std/__cxx11/stoi(ffee248579a0a688).(s); |
| 42 | } |
| 43 | else // text values |
| 44 | tValuecxx . . $ ifOption#tValue. =cxx . . $ std/__cxx11/basic_string#`operator=`(c0b47be1fddc0e75). s; |
| 45 | |
| 46 | return false; |
| 47 | } |
| 48 | |
| 49 | /// output in the form of config file |
| 50 | void ifOptioncxx . . $ ifOption# :: printConfStringcxx . . $ ifOption#printConfString(490063bd7e6d8d5d). ( stdcxx . . $ std/::ostreamcxx . . $ std/ostream#& o ) const |
| 51 | { |
| 52 | // name and type |
| 53 | o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n;---\n;--- Option '" <<cxx . . $ std/`operator<<`(88df5bef833f7f83). optionNamecxx . . $ ifOption#optionName. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "': "; |
| 54 | if ( typecxx . . $ ifOption#type. == iotBoolcxx . . $ ifOption#iotBool. ) |
| 55 | o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "boolean"; |
| 56 | else if ( typecxx . . $ ifOption#type. == iotIntcxx . . $ ifOption#iotInt. ) |
| 57 | o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "integer"; |
| 58 | else if ( typecxx . . $ ifOption#type. == iotTextcxx . . $ ifOption#iotText. ) |
| 59 | o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "text"; |
| 60 | else // sanity check |
| 61 | fpp_unreachablecxx . . $ `Kernel/fpp_assert.h:49:9`!(); |
| 62 | |
| 63 | // description, default, name |
| 64 | o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " ---\n;---\n;* " <<cxx . . $ std/`operator<<`(88df5bef833f7f83). optionDescriptioncxx . . $ ifOption#optionDescription. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n;* Default value: '" |
| 65 | <<cxx . . $ std/`operator<<`(88df5bef833f7f83). defaultValuecxx . . $ ifOption#defaultValue. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "'\n\n; " <<cxx . . $ std/`operator<<`(88df5bef833f7f83). optionNamecxx . . $ ifOption#optionName. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " = "; |
| 66 | |
| 67 | // value |
| 68 | if ( typecxx . . $ ifOption#type. == iotBoolcxx . . $ ifOption#iotBool. ) |
| 69 | o <<cxx . . $ std/basic_ostream#`operator<<`(511cbee2d2e28827). getBoolcxx . . $ ifOption#getBool(50ce9a9e25b4a850). (); |
| 70 | else if ( typecxx . . $ ifOption#type. == iotIntcxx . . $ ifOption#iotInt. ) |
| 71 | o <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). getIntcxx . . $ ifOption#getInt(455f465bc33b4cdf). (); |
| 72 | else if ( typecxx . . $ ifOption#type. == iotTextcxx . . $ ifOption#iotText. ) |
| 73 | o <<cxx . . $ std/`operator<<`(88df5bef833f7f83). getTextcxx . . $ ifOption#getText(f4fff0029955a25f).(); |
| 74 | else // sanity check |
| 75 | fpp_unreachablecxx . . $ `Kernel/fpp_assert.h:49:9`!(); |
| 76 | |
| 77 | o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n"; |
| 78 | } |
| 79 | |
| 80 | bool ifOptionSetcxx . . $ ifOptionSet# :: initByConfigurecxx . . $ ifOptionSet#initByConfigure(bb2da3fc04b58aa3). ( Configurationcxx . . $ Configuration#& Config, const stdcxx . . $ std/::stringcxx . . $ std/string#& Section ) |
| 81 | { |
| 82 | // try to load given config section |
| 83 | if ( Config.useSectioncxx . . $ Configuration#useSection(7c222eea44a24d43). ( Section ) ) |
| 84 | return true; |
| 85 | |
| 86 | // for all registered options |
| 87 | for ( const auto& p: Basecxx . . $ ifOptionSet#Base. ) |
| 88 | if ( !Config.checkValuecxx . . $ Configuration#checkValue(7c222eea44a24d43).(p.firstcxx . . $ std/pair#first.) ) // if option located in config file |
| 89 | if ( p.secondcxx . . $ std/pair#second.->setAValuecxx . . $ ifOption#setAValue(7c222eea44a24d43).(Config.getValuecxx . . $ Configuration#getValue(219584694fe2b248).())) // ... set up its value |
| 90 | return true; // can't set value |
| 91 | |
| 92 | // all done without errors |
| 93 | return false; |
| 94 | } |
| 95 | |
| 96 | /// output in the form of config file |
| 97 | void ifOptionSetcxx . . $ ifOptionSet# :: printConfigcxx . . $ ifOptionSet#printConfig(490063bd7e6d8d5d). ( stdcxx . . $ std/::ostreamcxx . . $ std/ostream#& o ) const |
| 98 | { |
| 99 | // print LeveLogger info |
| 100 | o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "[LeveLogger]\n\n;--- Logging file name\n file = reasoning.log\n" |
| 101 | ";--- Logging level (the less level you give, the less information will be logged)\n allowedLevel = 0\n\n"; |
| 102 | |
| 103 | // print header |
| 104 | o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n[Tuning]\n"; |
| 105 | |
| 106 | for ( const auto& opt: Basecxx . . $ ifOptionSet#Base. ) |
| 107 | opt.secondcxx . . $ std/pair#second.->printConfStringcxx . . $ ifOption#printConfString(490063bd7e6d8d5d).(o); |
| 108 | o <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 109 | } |