|
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 "DOTAttributes.h" 00023 00024 using namespace degate; 00025 00026 void DOTAttributes::add(std::string const& attribute_name, 00027 std::string const& value) { 00028 std::ostringstream stm; 00029 stm << attribute_name << "=\"" << value << "\""; 00030 attributes[attribute_name] = stm.str(); 00031 } 00032 00033 00034 00035 void DOTAttributes::add_position(long center_x, long center_y, 00036 bool preserve_position) { 00037 std::ostringstream stm; 00038 stm << "pos" << "=\"" << center_x << "," << center_y; 00039 if(preserve_position) stm << "!"; 00040 stm << "\""; 00041 attributes["pos"] = stm.str(); 00042 } 00043 00044 00045 std::string DOTAttributes::get_string() const { 00046 std::string result; 00047 00048 for(std::map<std::string, std::string>::const_iterator iter = attributes.begin(); 00049 iter != attributes.end(); ++iter) { 00050 00051 if(result.size() > 0) result += ","; 00052 result += (*iter).second; 00053 } 00054 00055 return std::string("[") + result + std::string("];"); 00056 } 00057
1.7.4