From 3c3ee1d1775274c0358425c8692b5f9b82c99a8a Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sun, 19 Apr 2015 08:08:34 +0200 Subject: [PATCH] more conversions to std::string (nw) --- src/emu/bus/a800/a800_slot.c | 2 +- src/emu/cpu/dsp56k/inst.h | 10 ++-- src/emu/cpu/dsp56k/tables.c | 78 ++++++++++++++--------------- src/emu/debug/express.c | 46 ++++++++--------- src/emu/diimage.c | 24 ++++----- src/emu/diimage.h | 2 +- src/emu/emuopts.c | 4 +- src/emu/imagedev/floppy.c | 4 +- src/emu/mame.c | 4 +- src/emu/ui/devopt.c | 8 +-- src/lib/util/astring.h | 24 ++++----- src/lib/util/tagmap.h | 6 +-- src/osd/modules/font/font_windows.c | 2 +- src/osd/modules/lib/osdobj_common.h | 4 +- src/tools/chdman.c | 2 +- src/tools/src2html.c | 4 +- 16 files changed, 112 insertions(+), 112 deletions(-) diff --git a/src/emu/bus/a800/a800_slot.c b/src/emu/bus/a800/a800_slot.c index 0b011893a9f..ff9baade892 100644 --- a/src/emu/bus/a800/a800_slot.c +++ b/src/emu/bus/a800/a800_slot.c @@ -461,7 +461,7 @@ void a5200_cart_slot_device::get_default_card_software(std::string &result) type = identify_cart_type(&head[0]); astring info; - if (hashfile_extrainfo(*this, info) && info == "A13MIRRORING") + if (hashfile_extrainfo(*this, info) && info.cmp("A13MIRRORING")==0) type = A5200_16K_2CHIPS; } if (type < A5200_4K) diff --git a/src/emu/cpu/dsp56k/inst.h b/src/emu/cpu/dsp56k/inst.h index bad517ab171..b4b5c3e1688 100644 --- a/src/emu/cpu/dsp56k/inst.h +++ b/src/emu/cpu/dsp56k/inst.h @@ -358,7 +358,7 @@ public: assemble_D_from_P_table(BITSn(word0,0x0020), BITSn(word0,0x001f), dString); - if (dString == "!!") + if (dString.cmp("!!")==0) return false; switch(BITSn(word1,0x1f00)) @@ -1847,7 +1847,7 @@ public: void disassemble(astring& retString) const { astring ts = m_sign; - if (ts != "-") ts = ""; + if (ts.cmp("-") != 0) ts = ""; retString = "mac " + ts + regIdAsString(m_source) + "," + @@ -1941,7 +1941,7 @@ public: void disassemble(astring& retString) const { astring ts = m_sign; - if (ts != "-") ts = ""; + if (ts.cmp("-")!=0) ts = ""; retString = "macr " + ts + regIdAsString(m_source) + "," + @@ -2685,7 +2685,7 @@ public: void disassemble(astring& retString) const { astring ts = m_sign; - if (ts != "-") ts = ""; + if (ts.cmp("-")!=0) ts = ""; retString = "mpy " + ts + regIdAsString(m_source) + "," + @@ -2781,7 +2781,7 @@ public: void disassemble(astring& retString) const { astring ts = m_sign; - if (ts != "-") ts = ""; + if (ts.cmp("-") != 0) ts = ""; retString = "mpyr " + ts + regIdAsString(m_source) + "," + diff --git a/src/emu/cpu/dsp56k/tables.c b/src/emu/cpu/dsp56k/tables.c index 36af446cb96..727d7772d6e 100644 --- a/src/emu/cpu/dsp56k/tables.c +++ b/src/emu/cpu/dsp56k/tables.c @@ -831,45 +831,45 @@ astring opMnemonicAsString(const op_mnem& mnem) reg_id stringAsRegID(const astring& str) { - if (str == "X") return iX; - if (str == "X0") return iX0; - if (str == "X1") return iX1; - if (str == "Y") return iY; - if (str == "Y0") return iY0; - if (str == "Y1") return iY1; - if (str == "A") return iA; - if (str == "A0") return iA0; - if (str == "A1") return iA1; - if (str == "A2") return iA2; - if (str == "B") return iB; - if (str == "B0") return iB0; - if (str == "B1") return iB1; - if (str == "B2") return iB2; - if (str == "R0") return iR0; - if (str == "R1") return iR1; - if (str == "R2") return iR2; - if (str == "R3") return iR3; - if (str == "N0") return iN0; - if (str == "N1") return iN1; - if (str == "N2") return iN2; - if (str == "N3") return iN3; - if (str == "M0") return iM0; - if (str == "M1") return iM1; - if (str == "M2") return iM2; - if (str == "M3") return iM3; - if (str == "LC") return iLC; - if (str == "SR") return iSR; - if (str == "OMR") return iOMR; - if (str == "SP") return iSP; - if (str == "SSH") return iSSH; - if (str == "SSL") return iSSL; - if (str == "LA") return iLA; - if (str == "MR") return iMR; - if (str == "CCR") return iCCR; - if (str == "F") return iF; - if (str == "^F") return iFHAT; - if (str == "!!") return iINVALID; - if (str == "?") return iWEIRD; + if (str.cmp("X")==0) return iX; + if (str.cmp("X0") == 0) return iX0; + if (str.cmp("X1") == 0) return iX1; + if (str.cmp("Y") == 0) return iY; + if (str.cmp("Y0") == 0) return iY0; + if (str.cmp("Y1") == 0) return iY1; + if (str.cmp("A") == 0) return iA; + if (str.cmp("A0") == 0) return iA0; + if (str.cmp("A1") == 0) return iA1; + if (str.cmp("A2") == 0) return iA2; + if (str.cmp("B") == 0) return iB; + if (str.cmp("B0") == 0) return iB0; + if (str.cmp("B1") == 0) return iB1; + if (str.cmp("B2") == 0) return iB2; + if (str.cmp("R0") == 0) return iR0; + if (str.cmp("R1") == 0) return iR1; + if (str.cmp("R2") == 0) return iR2; + if (str.cmp("R3") == 0) return iR3; + if (str.cmp("N0") == 0) return iN0; + if (str.cmp("N1") == 0) return iN1; + if (str.cmp("N2") == 0) return iN2; + if (str.cmp("N3") == 0) return iN3; + if (str.cmp("M0") == 0) return iM0; + if (str.cmp("M1") == 0) return iM1; + if (str.cmp("M2") == 0) return iM2; + if (str.cmp("M3") == 0) return iM3; + if (str.cmp("LC") == 0) return iLC; + if (str.cmp("SR") == 0) return iSR; + if (str.cmp("OMR") == 0) return iOMR; + if (str.cmp("SP") == 0) return iSP; + if (str.cmp("SSH") == 0) return iSSH; + if (str.cmp("SSL") == 0) return iSSL; + if (str.cmp("LA") == 0) return iLA; + if (str.cmp("MR") == 0) return iMR; + if (str.cmp("CCR") == 0) return iCCR; + if (str.cmp("F") == 0) return iF; + if (str.cmp("^F") == 0) return iFHAT; + if (str.cmp("!!") == 0) return iINVALID; + if (str.cmp("?") == 0)return iWEIRD; return iINVALID; } diff --git a/src/emu/debug/express.c b/src/emu/debug/express.c index 28b2e408e3b..6269a25aa3a 100644 --- a/src/emu/debug/express.c +++ b/src/emu/debug/express.c @@ -861,14 +861,14 @@ void parsed_expression::parse_symbol_or_number(parse_token &token, const char *& { // accumulate a lower-case version of the symbol const char *stringstart = string; - astring buffer; + std::string buffer; while (1) { static const char valid[] = "abcdefghijklmnopqrstuvwxyz0123456789_$#.:"; char val = tolower((UINT8)string[0]); if (val == 0 || strchr(valid, val) == NULL) break; - buffer.cat(&val, 1); + buffer.append(&val, 1); string++; } @@ -880,49 +880,49 @@ void parsed_expression::parse_symbol_or_number(parse_token &token, const char *& } // empty string is automatically invalid - if (!buffer) + if (buffer.empty()) throw expression_error(expression_error::INVALID_TOKEN, token.offset()); // check for wordy variants on standard operators - if (buffer == "bnot") + if (buffer.compare("bnot")==0) { token.configure_operator(TVL_NOT, 2); return; } - if (buffer == "plus") + if (buffer.compare("plus") == 0) { token.configure_operator(TVL_ADD, 4); return; } - if (buffer == "minus") + if (buffer.compare("minus") == 0) { token.configure_operator(TVL_SUBTRACT, 4); return; } - if (buffer == "times" || buffer == "mul") + if (buffer.compare("times") == 0 || buffer.compare("mul") == 0) { token.configure_operator(TVL_MULTIPLY, 3); return; } - if (buffer == "div") + if (buffer.compare("div") == 0) { token.configure_operator(TVL_DIVIDE, 3); return; } - if (buffer == "mod") + if (buffer.compare("mod") == 0) { token.configure_operator(TVL_MODULO, 3); return; } - if (buffer == "lt") + if (buffer.compare("lt") == 0) { token.configure_operator(TVL_LESS, 6); return; } - if (buffer == "le") + if (buffer.compare("le") == 0) { token.configure_operator(TVL_LESSOREQUAL, 6); return; } - if (buffer == "gt") + if (buffer.compare("gt") == 0) { token.configure_operator(TVL_GREATER, 6); return; } - if (buffer == "ge") + if (buffer.compare("ge") == 0) { token.configure_operator(TVL_GREATEROREQUAL, 6); return; } - if (buffer == "eq") + if (buffer.compare("eq") == 0) { token.configure_operator(TVL_EQUAL, 7); return; } - if (buffer == "ne") + if (buffer.compare("ne") == 0) { token.configure_operator(TVL_NOTEQUAL, 7); return; } - if (buffer == "not") + if (buffer.compare("not") == 0) { token.configure_operator(TVL_COMPLEMENT, 2); return; } - if (buffer == "and") + if (buffer.compare("and") == 0) { token.configure_operator(TVL_LAND, 8); return; } - if (buffer == "band") + if (buffer.compare("band") == 0) { token.configure_operator(TVL_BAND, 8); return; } - if (buffer == "or") + if (buffer.compare("or") == 0) { token.configure_operator(TVL_LOR, 12); return; } - if (buffer == "bor") + if (buffer.compare("bor") == 0) { token.configure_operator(TVL_BOR, 10); return; } - if (buffer == "bxor") + if (buffer.compare("bxor") == 0) { token.configure_operator(TVL_BXOR, 9); return; } - if (buffer == "lshift") + if (buffer.compare("lshift") == 0) { token.configure_operator(TVL_LSHIFT, 5); return; } - if (buffer == "rshift") + if (buffer.compare("rshift") == 0) { token.configure_operator(TVL_RSHIFT, 5); return; } // if we have an 0x prefix, we must be a hex value diff --git a/src/emu/diimage.c b/src/emu/diimage.c index e9e4963f227..fb890c08dac 100644 --- a/src/emu/diimage.c +++ b/src/emu/diimage.c @@ -1171,18 +1171,18 @@ void device_image_interface::update_names(const device_type device_type, const c // case. //------------------------------------------------- -void device_image_interface::software_name_split(const char *swlist_swname, astring &swlist_name, astring &swname, astring &swpart) +void device_image_interface::software_name_split(const char *swlist_swname, std::string &swlist_name, std::string &swname, std::string &swpart) { // reset all output parameters - swlist_name.reset(); - swname.reset(); - swpart.reset(); + swlist_name.clear(); + swname.clear(); + swpart.clear(); // if no colon, this is the swname by itself const char *split1 = strchr(swlist_swname, ':'); if (split1 == NULL) { - swname.cpy(swlist_swname); + swname.assign(swlist_swname); return; } @@ -1190,22 +1190,22 @@ void device_image_interface::software_name_split(const char *swlist_swname, astr const char *split2 = strchr(split1 + 1, ':'); if (split2 == NULL) { - swname.cpy(swlist_swname, split1 - swlist_swname); - swpart.cpy(split1 + 1); + swname.assign(swlist_swname, split1 - swlist_swname); + swpart.assign(split1 + 1); return; } // if two colons present, split into 3 parts - swlist_name.cpy(swlist_swname, split1 - swlist_swname); - swname.cpy(split1 + 1, split2 - (split1 + 1)); - swpart.cpy(split2 + 1); + swlist_name.assign(swlist_swname, split1 - swlist_swname); + swname.assign(split1 + 1, split2 - (split1 + 1)); + swpart.assign(split2 + 1); } software_part *device_image_interface::find_software_item(const char *path, bool restrict_to_interface) { // split full software name into software list name and short software name - astring swlist_name, swinfo_name, swpart_name; + std::string swlist_name, swinfo_name, swpart_name; software_name_split(path, swlist_name, swinfo_name, swpart_name); // determine interface @@ -1217,7 +1217,7 @@ software_part *device_image_interface::find_software_item(const char *path, bool software_list_device_iterator deviter(device().mconfig().root_device()); for (software_list_device *swlistdev = deviter.first(); swlistdev != NULL; swlistdev = deviter.next()) { - if (swlist_name == swlistdev->list_name() || !(swlist_name.len() > 0)) + if (swlist_name.compare(swlistdev->list_name())==0 || !(swlist_name.length() > 0)) { software_info *info = swlistdev->find(swinfo_name.c_str()); if (info != NULL) diff --git a/src/emu/diimage.h b/src/emu/diimage.h index deaa9f8e9a1..459bcacac4b 100644 --- a/src/emu/diimage.h +++ b/src/emu/diimage.h @@ -234,7 +234,7 @@ public: bool load_software(software_list_device &swlist, const char *swname, const rom_entry *entry); int reopen_for_write(const char *path); - static void software_name_split(const char *swlist_swname, astring &swlist_name, astring &swname, astring &swpart); + static void software_name_split(const char *swlist_swname, std::string &swlist_name, std::string &swname, std::string &swpart); protected: bool load_internal(const char *path, bool is_create, int create_format, option_resolution *create_args, bool just_load); diff --git a/src/emu/emuopts.c b/src/emu/emuopts.c index 1b16624fa53..74a452d00af 100644 --- a/src/emu/emuopts.c +++ b/src/emu/emuopts.c @@ -484,10 +484,10 @@ const game_driver *emu_options::system() const void emu_options::set_system_name(const char *name) { // remember the original system name - astring old_system_name(system_name()); + std::string old_system_name(system_name()); // if the system name changed, fix up the device options - if (old_system_name != name) + if (old_system_name.compare(name)!=0) { // first set the new name astring error; diff --git a/src/emu/imagedev/floppy.c b/src/emu/imagedev/floppy.c index baa5ea514a2..6fe78ec14d7 100644 --- a/src/emu/imagedev/floppy.c +++ b/src/emu/imagedev/floppy.c @@ -862,7 +862,7 @@ ui_menu_control_floppy_image::~ui_menu_control_floppy_image() void ui_menu_control_floppy_image::do_load_create() { floppy_image_device *fd = static_cast(image); - if(input_filename == "") { + if(input_filename.cmp("")==0) { int err = fd->create(output_filename.c_str(), 0, NULL); if (err != 0) { popmessage("Error: %s", fd->error()); @@ -871,7 +871,7 @@ void ui_menu_control_floppy_image::do_load_create() fd->setup_write(output_format); } else { int err = fd->load(input_filename.c_str()); - if(!err && output_filename != "") + if(!err && output_filename.cmp("")!=0) err = fd->reopen_for_write(output_filename.c_str()); if(err != 0) { popmessage("Error: %s", fd->error()); diff --git a/src/emu/mame.c b/src/emu/mame.c index 9632ab04a79..297fe1c6d9b 100644 --- a/src/emu/mame.c +++ b/src/emu/mame.c @@ -225,8 +225,8 @@ int machine_manager::execute() // check the state of the machine if (m_new_driver_pending) { - astring old_system_name(m_options.system_name()); - bool new_system = (old_system_name != m_new_driver_pending->name); + std::string old_system_name(m_options.system_name()); + bool new_system = (old_system_name.compare(m_new_driver_pending->name)!=0); // first: if we scheduled a new system, remove device options of the old system // notice that, if we relaunch the same system, there is no effect on the emulation if (new_system) diff --git a/src/emu/ui/devopt.c b/src/emu/ui/devopt.c index b203eb24324..c1e26ed9049 100644 --- a/src/emu/ui/devopt.c +++ b/src/emu/ui/devopt.c @@ -158,11 +158,11 @@ void ui_menu_device_config::populate() int bios = 0; if (dev->rom_region()) { - astring bios_str; + std::string bios_str; // first loop through roms in search of default bios (shortname) for (const rom_entry *rom = dev->rom_region(); !ROMENTRY_ISEND(rom); rom++) if (ROMENTRY_ISDEFAULT_BIOS(rom)) - bios_str.cpy(ROM_GETNAME(rom)); + bios_str.assign(ROM_GETNAME(rom)); // then loop again to count bios options and to get the default bios complete name for (const rom_entry *rom = dev->rom_region(); !ROMENTRY_ISEND(rom); rom++) @@ -170,8 +170,8 @@ void ui_menu_device_config::populate() if (ROMENTRY_ISSYSTEM_BIOS(rom)) { bios++; - if (bios_str == ROM_GETNAME(rom)) - bios_str.cpy(ROM_GETHASHDATA(rom)); + if (bios_str.compare(ROM_GETNAME(rom))==0) + bios_str.assign(ROM_GETHASHDATA(rom)); } } diff --git a/src/lib/util/astring.h b/src/lib/util/astring.h index 089ee585dae..b17ae17076d 100644 --- a/src/lib/util/astring.h +++ b/src/lib/util/astring.h @@ -48,18 +48,18 @@ public: friend astring operator+(const char *lhs, const astring &rhs) { return astring(lhs) += rhs; } // comparison operators - bool operator==(const char *string) const { return (cmp(string) == 0); } - bool operator==(const astring &string) const { return (cmp(string) == 0); } - bool operator!=(const char *string) const { return (cmp(string) != 0); } - bool operator!=(const astring &string) const { return (cmp(string) != 0); } - bool operator<(const char *string) const { return (cmp(string) < 0); } - bool operator<(const astring &string) const { return (cmp(string) < 0); } - bool operator<=(const char *string) const { return (cmp(string) <= 0); } - bool operator<=(const astring &string) const { return (cmp(string) <= 0); } - bool operator>(const char *string) const { return (cmp(string) > 0); } - bool operator>(const astring &string) const { return (cmp(string) > 0); } - bool operator>=(const char *string) const { return (cmp(string) >= 0); } - bool operator>=(const astring &string) const { return (cmp(string) >= 0); } +// bool operator==(const char *string) const { return (cmp(string) == 0); } +// bool operator==(const astring &string) const { return (cmp(string) == 0); } +// bool operator!=(const char *string) const { return (cmp(string) != 0); } +// bool operator!=(const astring &string) const { return (cmp(string) != 0); } +// bool operator<(const char *string) const { return (cmp(string) < 0); } +// bool operator<(const astring &string) const { return (cmp(string) < 0); } +// bool operator<=(const char *string) const { return (cmp(string) <= 0); } +// bool operator<=(const astring &string) const { return (cmp(string) <= 0); } +// bool operator>(const char *string) const { return (cmp(string) > 0); } +// bool operator>(const astring &string) const { return (cmp(string) > 0); } +// bool operator>=(const char *string) const { return (cmp(string) >= 0); } +// bool operator>=(const astring &string) const { return (cmp(string) >= 0); } // character access operators char operator[](int index) const { return (index < len()) ? m_text[index] : 0; } diff --git a/src/lib/util/tagmap.h b/src/lib/util/tagmap.h index a2b82e2da96..50550f3e6c3 100644 --- a/src/lib/util/tagmap.h +++ b/src/lib/util/tagmap.h @@ -15,7 +15,7 @@ #include "osdcore.h" #include "coretmpl.h" -#include "astring.h" +#include #ifdef MAME_DEBUG #include "eminline.h" #endif @@ -67,7 +67,7 @@ public: m_object(object) { } // accessors - const astring &tag() const { return m_tag; } + const std::string &tag() const { return m_tag; } _ElementType object() const { return m_object; } // setters @@ -81,7 +81,7 @@ public: // internal state entry_t * m_next; UINT32 m_fullhash; - astring m_tag; + std::string m_tag; _ElementType m_object; }; diff --git a/src/osd/modules/font/font_windows.c b/src/osd/modules/font/font_windows.c index 9056b98054a..162a8956f89 100644 --- a/src/osd/modules/font/font_windows.c +++ b/src/osd/modules/font/font_windows.c @@ -47,7 +47,7 @@ bool osd_font_windows::open(const char *font_path, const char *_name, int &heigh { // accept qualifiers from the name astring name(_name); - if (name == "default") name = "Tahoma"; + if (name.cmp("default")==0) name = "Tahoma"; bool bold = (name.replace(0, "[B]", "") + name.replace(0, "[b]", "") > 0); bool italic = (name.replace(0, "[I]", "") + name.replace(0, "[i]", "") > 0); diff --git a/src/osd/modules/lib/osdobj_common.h b/src/osd/modules/lib/osdobj_common.h index e6a2a7a0311..366e832fd03 100644 --- a/src/osd/modules/lib/osdobj_common.h +++ b/src/osd/modules/lib/osdobj_common.h @@ -240,8 +240,8 @@ private: // FIXME: should be elsewhere osd_module *select_module_options(const core_options &opts, const astring &opt_name) { - astring opt_val = opts.value(opt_name.c_str()); - if (opt_val == "auto") + std::string opt_val = opts.value(opt_name.c_str()); + if (opt_val.compare("auto")==0) opt_val = ""; else if (!m_mod_man.type_has_name(opt_name.c_str(), opt_val.c_str())) { diff --git a/src/tools/chdman.c b/src/tools/chdman.c index d80e6d79921..a416772729d 100644 --- a/src/tools/chdman.c +++ b/src/tools/chdman.c @@ -1075,7 +1075,7 @@ static void parse_compression(const parameters_t ¶ms, chd_codec_type compres return; // special case: 'none' - if (*compression_str == "none") + if (compression_str->cmp("none")==0) { compression[0] = compression[1] = compression[2] = compression[3] = CHD_CODEC_NONE; return; diff --git a/src/tools/src2html.c b/src/tools/src2html.c index 33dd77604f4..7d0c55fa6c0 100644 --- a/src/tools/src2html.c +++ b/src/tools/src2html.c @@ -833,7 +833,7 @@ static bool find_include_file(astring &srcincpath, int srcrootlen, int dstrootle for (include_path *curpath = incpaths; curpath != NULL; curpath = curpath->next) { // a '.' include path is specially treated - if (curpath->path == ".") + if (curpath->path.cmp(".")==0) srcincpath.cpysubstr(srcfile, 0, srcfile.rchr(0, PATH_SEPARATOR[0])); else srcincpath.cpysubstr(srcfile, 0, srcrootlen + 1).cat(curpath->path); @@ -845,7 +845,7 @@ static bool find_include_file(astring &srcincpath, int srcrootlen, int dstrootle { // handle .. by removing a chunk from the incpath astring pathpart(filename, lastsepindex, sepindex - lastsepindex); - if (pathpart == "..") + if (pathpart.cmp("..")==0) { sepindex = srcincpath.rchr(0, PATH_SEPARATOR[0]); if (sepindex != -1)