Added bool operator to astring, returning true if the string is

not empty. Conveniently, this creates ambiguity if you write
astring == NULL. Rooted out remaining cases where we were doing
that and fixed them.
This commit is contained in:
Aaron Giles 2010-08-21 19:23:48 +00:00
parent 5f6ba3ed9c
commit 0e09afc1a8
5 changed files with 11 additions and 10 deletions

View File

@ -518,7 +518,7 @@ void cheat_render_text(running_machine *machine, render_container *container)
/* render any text and free it along the way */
for (linenum = 0; linenum < ARRAY_LENGTH(cheatinfo->output); linenum++)
if (cheatinfo->output[linenum].len() != 0)
if (cheatinfo->output[linenum])
{
/* output the text */
ui_draw_text_full(container, cheatinfo->output[linenum],
@ -956,7 +956,7 @@ static void cheat_execute_script(cheat_private *cheatinfo, cheat_entry *cheat, s
}
/* if there is a string to display, compute it */
if (entry->format.len() != 0)
if (entry->format)
{
UINT64 params[MAX_ARGUMENTS];
output_argument *arg;
@ -1283,14 +1283,14 @@ static void cheat_entry_save(mame_file *cheatfile, const cheat_entry *cheat)
mame_fprintf(cheatfile, "\t<cheat desc=\"%s\"", cheat->description.cstr());
if (cheat->numtemp != DEFAULT_TEMP_VARIABLES)
mame_fprintf(cheatfile, " tempvariables=\"%d\"", cheat->numtemp);
if (cheat->comment.len() == 0 && cheat->parameter == NULL && scriptcount == 0)
if (!cheat->comment && cheat->parameter == NULL && scriptcount == 0)
mame_fprintf(cheatfile, " />\n");
else
{
mame_fprintf(cheatfile, ">\n");
/* save the comment */
if (cheat->comment.len() != 0)
if (cheat->comment)
mame_fprintf(cheatfile, "\t\t<comment><![CDATA[\n%s\n\t\t]]></comment>\n", cheat->comment.cstr());
/* output the parameter, if present */
@ -1704,7 +1704,7 @@ static void script_entry_save(mame_file *cheatfile, const script_entry *entry)
astring tempstring;
/* output an action */
if (entry->format.len() == 0)
if (!entry->format)
{
mame_fprintf(cheatfile, "\t\t\t<action");
if (entry->condition != NULL)

View File

@ -2557,7 +2557,7 @@ void device_debug::breakpoint_check(offs_t pc)
global->execution_state = EXECUTION_STATE_STOPPED;
// if we hit, evaluate the action
if (bp->m_action.len() != 0)
if (bp->m_action)
debug_console_execute_command(m_device.machine, bp->m_action, 0);
// print a notification, unless the action made us go again
@ -2650,7 +2650,7 @@ void device_debug::watchpoint_check(address_space &space, int type, offs_t addre
global->execution_state = EXECUTION_STATE_STOPPED;
// if we hit, evaluate the action
if (wp->m_action != NULL)
if (wp->m_action)
debug_console_execute_command(space.machine, wp->m_action, 0);
// print a notification, unless the action made us go again
@ -3011,7 +3011,7 @@ void device_debug::tracer::update(offs_t pc)
m_loops = 0;
// execute any trace actions first
if (m_action != NULL)
if (m_action)
debug_console_execute_command(m_debug.m_device.machine, m_action, 0);
// print the address

View File

@ -492,7 +492,7 @@ static void dview_draw_title(DView *dv)
dview_draw_outlined_box(dv, RECT_DVIEW_TITLE, 0, 0, rect_get_width(&dv->bounds), TITLE_HEIGHT, col);
if (dv->title == NULL)
if (!dv->title)
return;
for (i=0; i<strlen(dv->title); i++)

View File

@ -145,7 +145,7 @@ void machine_config::detokenize(const machine_config_token *tokens, const device
case MCONFIG_TOKEN_DEVICE_MODIFY:
tag = TOKEN_GET_STRING(tokens);
device = m_devicelist.find(owner->subtag(tempstring, tag));
device = m_devicelist.find(owner->subtag(tempstring, tag).cstr());
if (device == NULL)
fatalerror("Unable to find device: tag=%s\n", tempstring.cstr());
break;

View File

@ -333,6 +333,7 @@ public:
astring &reset() { return cpy(""); }
astring &expand(int length) { astring_expand(this, length); return *this; }
operator bool() const { return this->text[0] != 0; }
operator char *() { return this->text; }
operator const char *() const { return astring_c(this); }
const char *cstr() const { return astring_c(this); }