Skip to content

Commit

Permalink
Further additions of std::string_view
Browse files Browse the repository at this point in the history
- corefile.cpp, fileio.cpp: Change puts to take a std::string_view parameter
- rendlay.cpp: Use std::string_view instead of bare pointers in various functions
- vecstream.h: Add std::string_view conversion operator to obtain output buffer without needing to make it a C string with explicit null termination
- xmlfile.cpp: Add get_attribute_string_ptr method that distinguishes between empty strings and absent attributes without falling back to C strings
  • Loading branch information
ajrhacker committed Jan 1, 2021
1 parent 21fd983 commit aa29519
Show file tree
Hide file tree
Showing 15 changed files with 232 additions and 216 deletions.
2 changes: 1 addition & 1 deletion src/emu/fileio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ u32 emu_file::write(const void *buffer, u32 length)
// puts - write a line to a text file
//-------------------------------------------------

int emu_file::puts(const char *s)
int emu_file::puts(std::string_view s)
{
// write the data if we can
if (m_file)
Expand Down
2 changes: 1 addition & 1 deletion src/emu/fileio.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class emu_file

// writing
u32 write(const void *buffer, u32 length);
int puts(const char *s);
int puts(std::string_view s);
int vprintf(util::format_argument_pack<std::ostream> const &args);
template <typename Format, typename... Params> int printf(Format &&fmt, Params &&...args)
{
Expand Down
2 changes: 1 addition & 1 deletion src/emu/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ int image_manager::write_config(emu_options &options, const char *filename, cons
if (filerr == osd_file::error::NONE)
{
std::string inistring = options.output_ini();
file.puts(inistring.c_str());
file.puts(inistring);
retval = 0;
}
return retval;
Expand Down

0 comments on commit aa29519

Please sign in to comment.