|
degate 0.1.1
|
00001 /* 00002 00003 This file is part of the IC reverse engineering tool degate. 00004 00005 Copyright 2008, 2009, 2010 by Martin Schobert 00006 00007 Degate is free software: you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation, either version 3 of the License, or 00010 any later version. 00011 00012 Degate is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with degate. If not, see <http://www.gnu.org/licenses/>. 00019 00020 */ 00021 00022 #include "Importer.h" 00023 00024 #include <sys/types.h> 00025 #include <sys/stat.h> 00026 #include <unistd.h> 00027 #include <errno.h> 00028 00029 #include <string> 00030 #include <iostream> 00031 #include <sstream> 00032 #include <stdexcept> 00033 #include <list> 00034 #include "FileSystem.h" 00035 00036 using namespace std; 00037 using namespace degate; 00038 00039 ret_t Importer::check_file(std::string const& filename) const { 00040 00041 if(is_file(filename)) { 00042 return RET_OK; 00043 } 00044 else { 00045 debug(TM, "Can't open file %s", filename.c_str()); 00046 return RET_ERR; 00047 } 00048 } 00049 00050 00051 bool Importer::parse_bool(std::string const & str) const { 00052 if(str == "true" || str == "enabled") return true; 00053 else if(str == "false" || str == "disabled") return false; 00054 else { 00055 debug(TM, "invalid attribute value '%s'", str.c_str()); 00056 throw std::invalid_argument("Can't parse string as a boolean value."); 00057 } 00058 } 00059
1.7.4