00001 /* ScummVM - Graphic Adventure Engine 00002 * 00003 * ScummVM is the legal property of its developers, whose names 00004 * are too numerous to list here. Please refer to the COPYRIGHT 00005 * file distributed with this source distribution. 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation; either version 2 00010 * of the License, or (at your option) any later version. 00011 * 00012 * This program 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 this program; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00020 * 00021 */ 00022 00023 #include "common/str.h" 00024 #include "common/winexe.h" 00025 00026 namespace Common { 00027 00028 WinResourceID &WinResourceID::operator=(const String &x) { 00029 _name = x; 00030 _idType = kIDTypeString; 00031 return *this; 00032 } 00033 00034 WinResourceID &WinResourceID::operator=(uint32 x) { 00035 _id = x; 00036 _idType = kIDTypeNumerical; 00037 return *this; 00038 } 00039 00040 bool WinResourceID::operator==(const String &x) const { 00041 return _idType == kIDTypeString && _name.equalsIgnoreCase(x); 00042 } 00043 00044 bool WinResourceID::operator==(const uint32 &x) const { 00045 return _idType == kIDTypeNumerical && _id == x; 00046 } 00047 00048 bool WinResourceID::operator==(const WinResourceID &x) const { 00049 if (_idType != x._idType) 00050 return false; 00051 if (_idType == kIDTypeString) 00052 return _name.equalsIgnoreCase(x._name); 00053 if (_idType == kIDTypeNumerical) 00054 return _id == x._id; 00055 return true; 00056 } 00057 00058 String WinResourceID::getString() const { 00059 if (_idType != kIDTypeString) 00060 return ""; 00061 00062 return _name; 00063 } 00064 00065 uint32 WinResourceID::getID() const { 00066 if (_idType != kIDTypeNumerical) 00067 return 0xffffffff; 00068 00069 return _id; 00070 } 00071 00072 String WinResourceID::toString() const { 00073 if (_idType == kIDTypeString) 00074 return _name; 00075 else if (_idType == kIDTypeNumerical) 00076 return String::format("0x%08x", _id); 00077 00078 return ""; 00079 } 00080 00081 } // End of namespace Common