updated astring constructors to have just one string param, to be more like std::string (nw)

This commit is contained in:
Miodrag Milanovic 2015-04-13 12:25:00 +02:00
parent dcd4f2a5b8
commit 2edee0b811
26 changed files with 50 additions and 47 deletions

View File

@ -64,7 +64,7 @@ const char *driverpath = m_enumerator.config().root_device().searchpath();
for (const rom_entry *region = rom_first_region(*device); region != NULL; region = rom_next_region(region))
{
// temporary hack: add the driver path & region name
astring combinedpath(device->searchpath(), ";", driverpath);
astring combinedpath = astring(device->searchpath()).cat(";").cat(driverpath);
if (device->shortname())
combinedpath.cat(";").cat(device->shortname());
m_searchpath = combinedpath.c_str();
@ -188,8 +188,15 @@ media_auditor::summary media_auditor::audit_software(const char *list_name, soft
// store validation for later
m_validation = validation;
astring combinedpath(swinfo->shortname(), ";", list_name, PATH_SEPARATOR, swinfo->shortname());
astring locationtag(list_name, "%", swinfo->shortname(), "%");
astring combinedpath(swinfo->shortname());
combinedpath.cat(";");
combinedpath.cat(list_name);
combinedpath.cat(PATH_SEPARATOR);
combinedpath.cat(swinfo->shortname());
astring locationtag(list_name);
locationtag.cat("%");
locationtag.cat(swinfo->shortname());
locationtag.cat("%");
if (swinfo->parentname() != NULL)
{
locationtag.cat(swinfo->parentname());

View File

@ -1686,7 +1686,7 @@ void media_identifier::identify(const char *filename)
for (const osd_directory_entry *entry = osd_readdir(directory); entry != NULL; entry = osd_readdir(directory))
if (entry->type == ENTTYPE_FILE)
{
astring curfile(filename, PATH_SEPARATOR, entry->name);
astring curfile = astring(filename).cat(PATH_SEPARATOR).cat(entry->name);
identify(curfile.c_str());
}

View File

@ -654,7 +654,7 @@ drcbe_x64::drcbe_x64(drcuml_state &drcuml, device_t &device, drc_cache &cache, U
// create the log
if (device.machine().options().drc_log_native())
{
astring filename("drcbex64_", device.shortname(), ".asm");
astring filename = astring("drcbex64_").cat(device.shortname()).cat(".asm");
m_log = x86log_create_context(filename.c_str());
}
}

View File

@ -568,7 +568,7 @@ drcbe_x86::drcbe_x86(drcuml_state &drcuml, device_t &device, drc_cache &cache, U
// create the log
if (device.machine().options().drc_log_native())
{
astring filename("drcbex86_", device.shortname(), ".asm");
astring filename = astring("drcbex86_").cat(device.shortname()).cat(".asm");
m_log = x86log_create_context(filename.c_str());
}
}

View File

@ -129,7 +129,7 @@ drcuml_state::drcuml_state(device_t &device, drc_cache &cache, UINT32 flags, int
// if we're to log, create the logfile
if (device.machine().options().drc_log_uml())
{
astring filename("drcuml_", m_device.shortname(), ".asm");
astring filename = astring("drcuml_").cat(m_device.shortname()).cat(".asm");
m_umllog = fopen(filename.c_str(), "w");
}
}

View File

@ -499,13 +499,13 @@ UINT32 device_image_interface::crc()
-------------------------------------------------*/
void device_image_interface::battery_load(void *buffer, int length, int fill)
{
astring fname(device().machine().system().name, PATH_SEPARATOR, m_basename_noext.c_str(), ".nv");
astring fname = astring(device().machine().system().name).cat(PATH_SEPARATOR).cat(m_basename_noext.c_str()).cat(".nv");
image_battery_load_by_name(device().machine().options(), fname.c_str(), buffer, length, fill);
}
void device_image_interface::battery_load(void *buffer, int length, void *def_buffer)
{
astring fname(device().machine().system().name, PATH_SEPARATOR, m_basename_noext.c_str(), ".nv");
astring fname = astring(device().machine().system().name).cat(PATH_SEPARATOR).cat(m_basename_noext.c_str()).cat(".nv");
image_battery_load_by_name(device().machine().options(), fname.c_str(), buffer, length, def_buffer);
}
@ -517,7 +517,7 @@ void device_image_interface::battery_load(void *buffer, int length, void *def_bu
-------------------------------------------------*/
void device_image_interface::battery_save(const void *buffer, int length)
{
astring fname(device().machine().system().name, PATH_SEPARATOR, m_basename_noext.c_str(), ".nv");
astring fname = astring(device().machine().system().name).cat(PATH_SEPARATOR).cat(m_basename_noext.c_str()).cat(".nv");
image_battery_save_by_name(device().machine().options(), fname.c_str(), buffer, length);
}

View File

@ -549,7 +549,7 @@ const char *emu_options::main_value(astring &buffer, const char *name) const
const char *emu_options::sub_value(astring &buffer, const char *name, const char *subname) const
{
astring tmp(",", subname, "=");
astring tmp = astring(",").cat(subname).cat("=");
buffer = value(name);
int pos = buffer.find(0, tmp.c_str());
if (pos != -1)

View File

@ -408,7 +408,7 @@ void palette_device::device_start()
if (share != NULL)
{
// find the extended (split) memory, if present
astring tag_ext(tag(), "_ext");
astring tag_ext = astring(tag()).cat("_ext");
const memory_share *share_ext = memshare(tag_ext.c_str());
// make sure we have specified a format

View File

@ -281,21 +281,21 @@ file_error emu_file::open(const char *name)
file_error emu_file::open(const char *name1, const char *name2)
{
// concatenate the strings and do a standard open
astring name(name1, name2);
astring name = astring(name1).cat(name2);
return open(name.c_str());
}
file_error emu_file::open(const char *name1, const char *name2, const char *name3)
{
// concatenate the strings and do a standard open
astring name(name1, name2, name3);
astring name = astring(name1).cat(name2).cat(name3);
return open(name.c_str());
}
file_error emu_file::open(const char *name1, const char *name2, const char *name3, const char *name4)
{
// concatenate the strings and do a standard open
astring name(name1, name2, name3, name4);
astring name = astring(name1).cat(name2).cat(name3).cat(name4);
return open(name.c_str());
}
@ -314,21 +314,21 @@ file_error emu_file::open(const char *name, UINT32 crc)
file_error emu_file::open(const char *name1, const char *name2, UINT32 crc)
{
// concatenate the strings and do a standard open
astring name(name1, name2);
astring name = astring(name1).cat(name2);
return open(name.c_str(), crc);
}
file_error emu_file::open(const char *name1, const char *name2, const char *name3, UINT32 crc)
{
// concatenate the strings and do a standard open
astring name(name1, name2, name3);
astring name = astring(name1).cat(name2).cat(name3);
return open(name.c_str(), crc);
}
file_error emu_file::open(const char *name1, const char *name2, const char *name3, const char *name4, UINT32 crc)
{
// concatenate the strings and do a standard open
astring name(name1, name2, name3, name4);
astring name = astring(name1).cat(name2).cat(name3).cat(name4);
return open(name.c_str(), crc);
}

View File

@ -170,7 +170,7 @@ void diablo_image_device::call_unload()
static chd_error open_disk_diff(emu_options &options, const char *name, chd_file &source, chd_file &diff_chd)
{
astring fname(name, ".dif");
astring fname = astring(name).cat(".dif");
/* try to open the diff */
//printf("Opening differencing image file: %s\n", fname.c_str());

View File

@ -176,7 +176,7 @@ void harddisk_image_device::call_unload()
static chd_error open_disk_diff(emu_options &options, const char *name, chd_file &source, chd_file &diff_chd)
{
astring fname(name, ".dif");
astring fname = astring(name).cat(".dif");
/* try to open the diff */
//printf("Opening differencing image file: %s\n", fname.c_str());

View File

@ -206,7 +206,7 @@ TIMER_CALLBACK_MEMBER(running_machine::autoboot_callback)
else if (strlen(options().autoboot_command())!=0) {
astring cmd = astring(options().autoboot_command());
cmd.replace("'","\\'");
astring val = astring("emu.keypost('", cmd.c_str(), "')").c_str();
astring val = astring("emu.keypost('").cat(cmd.c_str()).cat("')").c_str();
manager().lua()->load_string(val.c_str());
}
}

View File

@ -1571,7 +1571,7 @@ bool render_target::load_layout_file(const char *dirname, const char *filename)
else
{
// build the path and optionally prepend the directory
astring fname(filename, ".lay");
astring fname = astring(filename).cat(".lay");
if (dirname != NULL)
fname.ins(0, PATH_SEPARATOR).ins(0, dirname);

View File

@ -1179,7 +1179,7 @@ int open_disk_image(emu_options &options, const game_driver *gamedrv, const rom_
static chd_error open_disk_diff(emu_options &options, const rom_entry *romp, chd_file &source, chd_file &diff_chd)
{
astring fname(ROM_GETNAME(romp), ".dif");
astring fname = astring(ROM_GETNAME(romp)).cat(".dif");
/* try to open the diff */
LOG(("Opening differencing image file: %s\n", fname.c_str()));
@ -1236,7 +1236,7 @@ static void process_disk_entries(romload_private *romdata, const char *regiontag
chd_error err;
/* make the filename of the source */
astring filename(ROM_GETNAME(romp), ".chd");
astring filename = astring(ROM_GETNAME(romp)).cat(".chd");
/* first open the source drive */
LOG(("Opening disk image: %s\n", filename.c_str()));

View File

@ -267,7 +267,7 @@ inline void save_manager::save_item(device_t *device, const char *module, const
template<>
inline void save_manager::save_item(device_t *device, const char *module, const char *tag, int index, attotime &value, const char *name)
{
astring tempstr(name, ".attoseconds");
astring tempstr = astring(name).cat(".attoseconds");
save_memory(device, module, tag, index, tempstr.c_str(), &value.attoseconds, sizeof(value.attoseconds));
tempstr.cpy(name).cat(".seconds");
save_memory(device, module, tag, index, tempstr.c_str(), &value.seconds, sizeof(value.seconds));

View File

@ -149,8 +149,8 @@ bool software_part::is_compatible(const software_list_device &swlistdev) const
return true;
// copy the comma-delimited strings and ensure they end with a final comma
astring comp(compatibility, ",");
astring filt(filter, ",");
astring comp = astring(compatibility).cat(",");
astring filt = astring(filter).cat(",");
// iterate over filter items and see if they exist in the compatibility list; if so, return true
for (int start = 0, end = filt.chr(start, ','); end != -1; start = end + 1, end = filt.chr(start, ','))
@ -175,10 +175,10 @@ bool software_part::matches_interface(const char *interface_list) const
return true;
// copy the comma-delimited interface list and ensure it ends with a final comma
astring interfaces(interface_list, ",");
astring interfaces = astring(interface_list).cat(",");
// then add a comma to the end of our interface and return true if we find it in the list string
astring our_interface(m_interface, ",");
astring our_interface = astring(m_interface).cat(",");
return (interfaces.find(0, our_interface.c_str()) != -1);
}
@ -500,7 +500,7 @@ void software_list_device::device_validity_check(validity_checker &valid) const
{
// add to the global map whenever we check a list so we don't re-check
// it in the future
if (valid.already_checked(astring("softlist/", m_list_name.c_str()).c_str()))
if (valid.already_checked(astring("softlist/").cat(m_list_name.c_str()).c_str()))
return;
// do device validation only in case of validate command

View File

@ -1785,7 +1785,7 @@ void tilemap_device::device_start()
m_basemem.set(*share, m_bytes_per_entry);
// look for an extension entry
astring tag_ext(tag(), "_ext");
astring tag_ext = astring(tag()).cat("_ext");
share = memshare(tag_ext.c_str());
if (share != NULL)
m_extmem.set(*share, m_bytes_per_entry);

View File

@ -132,7 +132,7 @@ void ui_menu_control_device_image::test_create(bool &can_create, bool &need_conf
void ui_menu_control_device_image::load_software_part()
{
astring temp_name(sld->list_name(), ":", swi->shortname(), ":", swp->name());
astring temp_name = astring(sld->list_name()).cat(":").cat(swi->shortname()).cat(":").cat(swp->name());
driver_enumerator drivlist(machine().options(), machine().options().system_name());
media_auditor auditor(drivlist);

View File

@ -308,8 +308,8 @@ void video_manager::save_snapshot(screen_device *screen, emu_file &file)
create_snapshot_bitmap(screen);
// add two text entries describing the image
astring text1(emulator_info::get_appname(), " ", build_version);
astring text2(machine().system().manufacturer, " ", machine().system().description);
astring text1 = astring(emulator_info::get_appname()).cat(" ").cat(build_version);
astring text2 = astring(machine().system().manufacturer).cat(" ").cat(machine().system().description);
png_info pnginfo = { 0 };
png_add_text(&pnginfo, "Software", text1.c_str());
png_add_text(&pnginfo, "System", text2.c_str());
@ -1278,8 +1278,8 @@ void video_manager::record_frame()
png_info pnginfo = { 0 };
if (m_mng_frame == 0)
{
astring text1(emulator_info::get_appname(), " ", build_version);
astring text2(machine().system().manufacturer, " ", machine().system().description);
astring text1 = astring(emulator_info::get_appname()).cat(" ").cat(build_version);
astring text2 = astring(machine().system().manufacturer).cat(" ").cat(machine().system().description);
png_add_text(&pnginfo, "Software", text1.c_str());
png_add_text(&pnginfo, "System", text2.c_str());
}

View File

@ -260,7 +260,7 @@ static int filename_endswith(const char *str, const char *suffix)
// This function will be called by mongoose on every new request.
int web_engine::begin_request_handler(struct mg_connection *conn)
{
astring file_path(mg_get_option(m_server, "document_root"), PATH_SEPARATOR, conn->uri);
astring file_path = astring(mg_get_option(m_server, "document_root")).cat(PATH_SEPARATOR).cat(conn->uri);
if (filename_endswith(file_path.c_str(), ".lp"))
{
FILE *fp = NULL;

View File

@ -34,10 +34,6 @@ public:
// construction with copy
astring(const char *string) { init(); if(string) cpy(string); }
astring(const char *string, int length) { init().cpy(string, length); }
astring(const char *str1, const char *str2) { init().cpy(str1).cat(str2); }
astring(const char *str1, const char *str2, const char *str3) { init().cpy(str1).cat(str2).cat(str3); }
astring(const char *str1, const char *str2, const char *str3, const char *str4) { init().cpy(str1).cat(str2).cat(str3).cat(str4); }
astring(const char *str1, const char *str2, const char *str3, const char *str4, const char *str5) { init().cpy(str1).cat(str2).cat(str3).cat(str4).cat(str5); }
astring(const astring &string) { init().cpy(string); }
astring(const astring &string, int start, int count = -1) { init().cpysubstr(string, start, count); }

View File

@ -687,7 +687,7 @@ void core_options::append_entry(core_options::entry &newentry)
// for boolean options add a "no" variant as well
if (newentry.type() == OPTION_BOOLEAN)
m_entrymap.add(astring("no", newentry.name(name)).c_str(), &newentry);
m_entrymap.add(astring("no").cat(newentry.name(name)).c_str(), &newentry);
}
}

View File

@ -145,5 +145,5 @@ void disasmwin_info::process_string(char const *string)
void disasmwin_info::update_caption()
{
win_set_window_text_utf8(window(), astring("Disassembly: ", m_views[0]->source_name()).c_str());
win_set_window_text_utf8(window(), astring("Disassembly: ").cat(m_views[0]->source_name()).c_str());
}

View File

@ -12,7 +12,7 @@
logwin_info::logwin_info(debugger_windows_interface &debugger) :
debugwin_info(debugger, false, astring("Errorlog: ", debugger.machine().system().description, " [", debugger.machine().system().name, "]").c_str(), NULL)
debugwin_info(debugger, false, astring("Errorlog: ").cat(debugger.machine().system().description).cat(" [").cat(debugger.machine().system().name).cat("]").c_str(), NULL)
{
if (!window())
return;

View File

@ -275,5 +275,5 @@ void memorywin_info::process_string(char const *string)
void memorywin_info::update_caption()
{
win_set_window_text_utf8(window(), astring("Memory: ", m_views[0]->source_name()).c_str());
win_set_window_text_utf8(window(), astring("Memory: ").cat(m_views[0]->source_name()).c_str());
}

View File

@ -370,8 +370,8 @@ void shaders::render_snapshot(surface *surface)
return;
// add two text entries describing the image
astring text1(emulator_info::get_appname(), " ", build_version);
astring text2(machine->system().manufacturer, " ", machine->system().description);
astring text1 = astring(emulator_info::get_appname()).cat(" ").cat(build_version);
astring text2 = astring(machine->system().manufacturer).cat(" ").cat(machine->system().description);
png_info pnginfo = { 0 };
png_add_text(&pnginfo, "Software", text1.c_str());
png_add_text(&pnginfo, "System", text2.c_str());