cstr() ==> c_str() (nw)

This commit is contained in:
couriersud 2016-12-30 23:38:13 +01:00
parent f1a6e2b47e
commit 0eefe5f02d
20 changed files with 104 additions and 104 deletions

View File

@ -72,7 +72,7 @@ void netlist_mame_analog_input_t::device_start()
m_param = dynamic_cast<netlist::param_double_t *>(p);
if (m_param == nullptr)
{
fatalerror("device %s wrong parameter type for %s\n", basetag(), m_param_name.cstr());
fatalerror("device %s wrong parameter type for %s\n", basetag(), m_param_name.c_str());
}
if (m_mult != 1.0 || m_offset != 0.0)
{
@ -183,7 +183,7 @@ void netlist_mame_int_input_t::device_start()
m_param = dynamic_cast<netlist::param_int_t *>(p);
if (m_param == nullptr)
{
fatalerror("device %s wrong parameter type for %s\n", basetag(), m_param_name.cstr());
fatalerror("device %s wrong parameter type for %s\n", basetag(), m_param_name.c_str());
}
}
@ -215,7 +215,7 @@ void netlist_mame_logic_input_t::device_start()
m_param = dynamic_cast<netlist::param_logic_t *>(p);
if (m_param == nullptr)
{
fatalerror("device %s wrong parameter type for %s\n", basetag(), m_param_name.cstr());
fatalerror("device %s wrong parameter type for %s\n", basetag(), m_param_name.c_str());
}
}
@ -282,7 +282,7 @@ void netlist_ram_pointer_t::device_start()
m_param = dynamic_cast<netlist::param_ptr_t *>(p);
if (m_param == nullptr)
{
fatalerror("device %s wrong parameter type for %s\n", basetag(), m_param_name.cstr());
fatalerror("device %s wrong parameter type for %s\n", basetag(), m_param_name.c_str());
}
m_data = (*m_param)();
@ -375,22 +375,22 @@ void netlist_mame_t::vlog(const plib::plog_level &l, const pstring &ls) const
switch (l)
{
case plib::plog_level::DEBUG:
m_parent.logerror("netlist DEBUG: %s\n", errstr.cstr());
m_parent.logerror("netlist DEBUG: %s\n", errstr.c_str());
break;
case plib::plog_level::INFO:
m_parent.logerror("netlist INFO: %s\n", errstr.cstr());
m_parent.logerror("netlist INFO: %s\n", errstr.c_str());
break;
case plib::plog_level::VERBOSE:
m_parent.logerror("netlist VERBOSE: %s\n", errstr.cstr());
m_parent.logerror("netlist VERBOSE: %s\n", errstr.c_str());
break;
case plib::plog_level::WARNING:
m_parent.logerror("netlist WARNING: %s\n", errstr.cstr());
m_parent.logerror("netlist WARNING: %s\n", errstr.c_str());
break;
case plib::plog_level::ERROR:
m_parent.logerror("netlist ERROR: %s\n", errstr.cstr());
m_parent.logerror("netlist ERROR: %s\n", errstr.c_str());
break;
case plib::plog_level::FATAL:
emu_fatalerror error("netlist ERROR: %s\n", errstr.cstr());
emu_fatalerror error("netlist ERROR: %s\n", errstr.c_str());
throw error;
}
}
@ -554,38 +554,38 @@ ATTR_COLD void netlist_mame_device_t::save_state()
{
for (auto const & s : netlist().state().save_list())
{
netlist().log().debug("saving state for {1}\n", s->m_name.cstr());
netlist().log().debug("saving state for {1}\n", s->m_name.c_str());
if (s->m_dt.is_float)
{
if (s->m_dt.size == sizeof(double))
{
double *td = s->resolved<double>();
if (td != nullptr) save_pointer(td, s->m_name.cstr(), s->m_count);
if (td != nullptr) save_pointer(td, s->m_name.c_str(), s->m_count);
}
else if (s->m_dt.size == sizeof(float))
{
float *td = s->resolved<float>();
if (td != nullptr) save_pointer(td, s->m_name.cstr(), s->m_count);
if (td != nullptr) save_pointer(td, s->m_name.c_str(), s->m_count);
}
else
netlist().log().fatal("Unknown floating type for {1}\n", s->m_name.cstr());
netlist().log().fatal("Unknown floating type for {1}\n", s->m_name.c_str());
}
else if (s->m_dt.is_integral)
{
if (s->m_dt.size == sizeof(int64_t))
save_pointer((int64_t *) s->m_ptr, s->m_name.cstr(), s->m_count);
save_pointer((int64_t *) s->m_ptr, s->m_name.c_str(), s->m_count);
else if (s->m_dt.size == sizeof(int32_t))
save_pointer((int32_t *) s->m_ptr, s->m_name.cstr(), s->m_count);
save_pointer((int32_t *) s->m_ptr, s->m_name.c_str(), s->m_count);
else if (s->m_dt.size == sizeof(int16_t))
save_pointer((int16_t *) s->m_ptr, s->m_name.cstr(), s->m_count);
save_pointer((int16_t *) s->m_ptr, s->m_name.c_str(), s->m_count);
else if (s->m_dt.size == sizeof(int8_t))
save_pointer((int8_t *) s->m_ptr, s->m_name.cstr(), s->m_count);
save_pointer((int8_t *) s->m_ptr, s->m_name.c_str(), s->m_count);
#if (PHAS_INT128)
else if (s->m_dt.size == sizeof(INT128))
save_pointer((int64_t *) s->m_ptr, s->m_name.cstr(), s->m_count * 2);
save_pointer((int64_t *) s->m_ptr, s->m_name.c_str(), s->m_count * 2);
#endif
else
netlist().log().fatal("Unknown integral type size {1} for {2}\n", s->m_dt.size, s->m_name.cstr());
netlist().log().fatal("Unknown integral type size {1} for {2}\n", s->m_dt.size, s->m_name.c_str());
}
else if (s->m_dt.is_custom)
{
@ -627,11 +627,11 @@ void netlist_mame_cpu_device_t::device_start()
netlist::detail::net_t *n = netlist().m_nets[i].get();
if (n->is_logic())
{
state_add(i*2, n->name().cstr(), downcast<netlist::logic_net_t *>(n)->Q_state_ptr());
state_add(i*2, n->name().c_str(), downcast<netlist::logic_net_t *>(n)->Q_state_ptr());
}
else
{
state_add(i*2+1, n->name().cstr(), downcast<netlist::analog_net_t *>(n)->Q_Analog_state_ptr()).formatstr("%20s");
state_add(i*2+1, n->name().c_str(), downcast<netlist::analog_net_t *>(n)->Q_Analog_state_ptr()).formatstr("%20s");
}
}
@ -664,7 +664,7 @@ ATTR_COLD offs_t netlist_mame_cpu_device_t::disasm_disassemble(std::ostream &str
{
int dpc = netlist().queue().size() - relpc - 1;
// FIXME: 50 below fixes crash in mame-debugger. It's based on try on error.
util::stream_format(stream, "%c %s @%10.7f", (relpc == 0) ? '*' : ' ', netlist().queue()[dpc].m_object->name().cstr(),
util::stream_format(stream, "%c %s @%10.7f", (relpc == 0) ? '*' : ' ', netlist().queue()[dpc].m_object->name().c_str(),
netlist().queue()[dpc].m_exec_time.as_double());
}
@ -795,7 +795,7 @@ void netlist_mame_sound_device_t::sound_stream_update(sound_stream &stream, stre
std::unique_ptr<plib::pistream> netlist_source_memregion_t::stream(const pstring &name)
{
memory_region *mem = downcast<netlist_mame_t &>(setup().netlist()).machine().root_device().memregion(m_name.cstr());
memory_region *mem = downcast<netlist_mame_t &>(setup().netlist()).machine().root_device().memregion(m_name.c_str());
return plib::make_unique_base<plib::pistream, plib::pimemstream>(mem->base(), mem->bytes());
}

View File

@ -797,7 +797,7 @@ public:
{
int pos = (upto - m_last_buffer) / m_sample;
if (pos >= BUFSIZE)
netlist().log().fatal("sound {1}: exceeded BUFSIZE\n", name().cstr());
netlist().log().fatal("sound {1}: exceeded BUFSIZE\n", name().c_str());
while (m_last_pos < pos )
{
m_buffer[m_last_pos++] = (stream_sample_t) m_cur;

View File

@ -235,7 +235,7 @@ namespace netlist
desc.setup(m_desc, disabled_ignore * 0);
#if 0
printf("%s\n", name().cstr());
printf("%s\n", name().c_str());
for (int j=0; j < m_size; j++)
printf("%05x %04x %04x %04x\n", j, m_ttp->m_outs[j] & ((1 << m_NO)-1),
m_ttp->m_outs[j] >> m_NO, m_ttp->m_timing[j * m_NO + 0]);

View File

@ -53,9 +53,9 @@ namespace netlist
else
netlist().log().warning("D/A Proxy: Found power terminals on device {1}", out_proxied->device().name());
#if (0)
printf("%s %s\n", out_proxied->name().cstr(), out_proxied->device().name().cstr());
printf("%s %s\n", out_proxied->name().c_str(), out_proxied->device().name().c_str());
auto x = netlist().setup().find_terminal(out_proxied->name(), detail::device_object_t::type_t::OUTPUT, false);
if (x) printf("==> %s\n", x->name().cstr());
if (x) printf("==> %s\n", x->name().c_str());
#endif
}

View File

@ -146,7 +146,7 @@ void detail::queue_t::on_pre_save()
pstring p = this->listptr()[i].m_object->name();
std::size_t n = p.len();
if (n > 63) n = 63;
std::strncpy(m_names[i].m_buf, p.cstr(), n);
std::strncpy(m_names[i].m_buf, p.c_str(), n);
m_names[i].m_buf[n] = 0;
}
}

View File

@ -207,7 +207,7 @@ double setup_t::get_initial_param_val(const pstring name, const double def)
if (i != m_param_values.end())
{
double vald = 0;
if (sscanf(i->second.cstr(), "%lf", &vald) != 1)
if (sscanf(i->second.c_str(), "%lf", &vald) != 1)
log().fatal("Invalid number conversion {1} : {2}\n", name, i->second);
return vald;
}
@ -221,7 +221,7 @@ int setup_t::get_initial_param_val(const pstring name, const int def)
if (i != m_param_values.end())
{
double vald = 0;
if (sscanf(i->second.cstr(), "%lf", &vald) != 1)
if (sscanf(i->second.c_str(), "%lf", &vald) != 1)
log().fatal("Invalid number conversion {1} : {2}\n", name, i->second);
return static_cast<int>(vald);
}
@ -1076,12 +1076,12 @@ bool source_t::parse(const pstring &name)
std::unique_ptr<plib::pistream> source_string_t::stream(const pstring &name)
{
return plib::make_unique_base<plib::pistream, plib::pimemstream>(m_str.cstr(), m_str.len());
return plib::make_unique_base<plib::pistream, plib::pimemstream>(m_str.c_str(), m_str.len());
}
std::unique_ptr<plib::pistream> source_mem_t::stream(const pstring &name)
{
return plib::make_unique_base<plib::pistream, plib::pimemstream>(m_str.cstr(), m_str.len());
return plib::make_unique_base<plib::pistream, plib::pimemstream>(m_str.c_str(), m_str.len());
}
std::unique_ptr<plib::pistream> source_file_t::stream(const pstring &name)

View File

@ -62,8 +62,8 @@ dynlib::dynlib(const pstring libname)
: m_isLoaded(false), m_lib(nullptr)
{
#ifdef _WIN32
//fprintf(stderr, "win: loading <%s>\n", libname.cstr());
TCHAR *buffer = tstring_from_utf8(libname.cstr());
//fprintf(stderr, "win: loading <%s>\n", libname.c_str());
TCHAR *buffer = tstring_from_utf8(libname.c_str());
if (libname != "")
m_lib = LoadLibrary(buffer);
else
@ -71,27 +71,27 @@ dynlib::dynlib(const pstring libname)
if (m_lib != nullptr)
m_isLoaded = true;
//else
// fprintf(stderr, "win: library <%s> not found!\n", libname.cstr());
// fprintf(stderr, "win: library <%s> not found!\n", libname.c_str());
pfree_array(buffer);
#else
//printf("loading <%s>\n", libname.cstr());
//printf("loading <%s>\n", libname.c_str());
if (libname != "")
m_lib = dlopen(libname.cstr(), RTLD_LAZY);
m_lib = dlopen(libname.c_str(), RTLD_LAZY);
else
m_lib = dlopen(nullptr, RTLD_LAZY);
if (m_lib != nullptr)
m_isLoaded = true;
//else
// printf("library <%s> not found: %s\n", libname.cstr(), dlerror());
// printf("library <%s> not found: %s\n", libname.c_str(), dlerror());
#endif
}
dynlib::dynlib(const pstring path, const pstring libname)
: m_isLoaded(false), m_lib(nullptr)
{
// printf("win: loading <%s>\n", libname.cstr());
// printf("win: loading <%s>\n", libname.c_str());
#ifdef _WIN32
TCHAR *buffer = tstring_from_utf8(libname.cstr());
TCHAR *buffer = tstring_from_utf8(libname.c_str());
if (libname != "")
m_lib = LoadLibrary(buffer);
else
@ -100,20 +100,20 @@ dynlib::dynlib(const pstring path, const pstring libname)
m_isLoaded = true;
else
{
//printf("win: library <%s> not found!\n", libname.cstr());
//printf("win: library <%s> not found!\n", libname.c_str());
}
pfree_array(buffer);
#else
//printf("loading <%s>\n", libname.cstr());
//printf("loading <%s>\n", libname.c_str());
if (libname != "")
m_lib = dlopen(libname.cstr(), RTLD_LAZY);
m_lib = dlopen(libname.c_str(), RTLD_LAZY);
else
m_lib = dlopen(nullptr, RTLD_LAZY);
if (m_lib != nullptr)
m_isLoaded = true;
else
{
//printf("library <%s> not found!\n", libname.cstr());
//printf("library <%s> not found!\n", libname.c_str());
}
#endif
}
@ -138,9 +138,9 @@ bool dynlib::isLoaded() const
void *dynlib::getsym_p(const pstring name)
{
#ifdef _WIN32
return (void *) GetProcAddress((HMODULE) m_lib, name.cstr());
return (void *) GetProcAddress((HMODULE) m_lib, name.c_str());
#else
return dlsym(m_lib, name.cstr());
return dlsym(m_lib, name.c_str());
#endif
}

View File

@ -26,7 +26,7 @@ pfmt::pfmt(const pstring &fmt)
m_allocated = 2 * l;
m_str = palloc_array<char>(2 * l);
}
memcpy(m_str, fmt.cstr(), l);
memcpy(m_str, fmt.c_str(), l);
}
pfmt::pfmt(const char *fmt)

View File

@ -122,7 +122,7 @@ public:
P &operator ()(const char *x, const char *f = "") { format_element(f, "", "s", x); return static_cast<P &>(*this); }
P &operator ()(char *x, const char *f = "") { format_element(f, "", "s", x); return static_cast<P &>(*this); }
P &operator ()(const void *x, const char *f = "") { format_element(f, "", "p", x); return static_cast<P &>(*this); }
P &operator ()(const pstring &x, const char *f = "") { format_element(f, "", "s", x.cstr() ); return static_cast<P &>(*this); }
P &operator ()(const pstring &x, const char *f = "") { format_element(f, "", "s", x.c_str() ); return static_cast<P &>(*this); }
template<typename T>
P &operator ()(const T x, const char *f = "")

View File

@ -58,7 +58,7 @@ void postream::write(pistream &strm)
pifilestream::pifilestream(const pstring &fname)
: pistream(0)
, m_file(fopen(fname.cstr(), "rb"))
, m_file(fopen(fname.c_str(), "rb"))
, m_pos(0)
, m_actually_close(true)
, m_filename(fname)
@ -147,7 +147,7 @@ pstdin::pstdin()
// -----------------------------------------------------------------------------
pofilestream::pofilestream(const pstring &fname)
: postream(0), m_file(fopen(fname.cstr(), "wb")), m_pos(0), m_actually_close(true), m_filename(fname)
: postream(0), m_file(fopen(fname.c_str(), "wb")), m_pos(0), m_actually_close(true), m_filename(fname)
{
if (m_file == nullptr)
throw file_open_e(m_filename);

View File

@ -126,7 +126,7 @@ public:
void write(const pstring &text)
{
write(text.cstr(), text.blen());
write(text.c_str(), text.blen());
}
void write(const char c)
@ -325,7 +325,7 @@ class pistringstream : public pimemstream
P_PREVENT_COPYING(pistringstream)
public:
pistringstream(const pstring &str) : pimemstream(str.cstr(), str.len()), m_str(str) { }
pistringstream(const pstring &str) : pimemstream(str.c_str(), str.len()), m_str(str) { }
private:
/* only needed for a reference till destruction */

View File

@ -46,7 +46,7 @@ void pstring_t<F>::pcat(const pstring_t &s)
if (m_ptr->len() > 0)
std::memcpy(n->str(), m_ptr->str(), m_ptr->len());
if (slen > 0)
std::memcpy(n->str() + m_ptr->len(), s.cstr(), slen);
std::memcpy(n->str() + m_ptr->len(), s.c_str(), slen);
*(n->str() + n->len()) = 0;
sfree(m_ptr);
m_ptr = n;
@ -65,7 +65,7 @@ int pstring_t<F>::pcmp(const pstring_t &right) const
else
return -1;
}
int ret = memcmp(m_ptr->str(), right.cstr(), l);
int ret = memcmp(m_ptr->str(), right.c_str(), l);
if (ret == 0)
{
if (this->blen() > right.blen())
@ -102,7 +102,7 @@ template<typename F>
const pstring_t<F> pstring_t<F>::ucase() const
{
pstring_t ret = *this;
ret.pcopy(cstr(), blen());
ret.pcopy(c_str(), blen());
for (std::size_t i=0; i<ret.len(); i++)
ret.m_ptr->str()[i] = static_cast<char>(toupper(static_cast<int>(ret.m_ptr->str()[i])));
return ret;
@ -230,7 +230,7 @@ double pstring_t<F>::as_double(bool *error) const
if (error != nullptr)
*error = false;
ret = strtod(cstr(), &e);
ret = strtod(c_str(), &e);
if (*e != 0)
if (error != nullptr)
*error = true;
@ -246,9 +246,9 @@ long pstring_t<F>::as_long(bool *error) const
if (error != nullptr)
*error = false;
if (startsWith("0x"))
ret = strtol(substr(2).cstr(), &e, 16);
ret = strtol(substr(2).c_str(), &e, 16);
else
ret = strtol(cstr(), &e, 10);
ret = strtol(c_str(), &e, 10);
if (*e != 0)
if (error != nullptr)
*error = true;
@ -279,7 +279,7 @@ bool pstring_t<F>::startsWith(const pstring_t &arg) const
if (arg.blen() > blen())
return false;
else
return (memcmp(arg.cstr(), cstr(), arg.blen()) == 0);
return (memcmp(arg.c_str(), c_str(), arg.blen()) == 0);
}
template<typename F>
@ -288,7 +288,7 @@ bool pstring_t<F>::endsWith(const pstring_t &arg) const
if (arg.blen() > blen())
return false;
else
return (memcmp(cstr()+this->blen()-arg.blen(), arg.cstr(), arg.blen()) == 0);
return (memcmp(c_str()+this->blen()-arg.blen(), arg.c_str(), arg.blen()) == 0);
}
@ -299,7 +299,7 @@ bool pstring_t<F>::startsWith(const mem_t *arg) const
if (alen > blen())
return false;
else
return (memcmp(arg, cstr(), alen) == 0);
return (memcmp(arg, c_str(), alen) == 0);
}
template<typename F>
@ -351,7 +351,7 @@ void pstringbuffer::pcopy(const pstring &from)
{
std::size_t nl = from.blen() + 1;
resize(nl);
std::memcpy(m_ptr, from.cstr(), nl);
std::memcpy(m_ptr, from.c_str(), nl);
}
void pstringbuffer::pcat(const char *s)
@ -377,7 +377,7 @@ void pstringbuffer::pcat(const pstring &s)
const std::size_t slen = s.blen();
const std::size_t nl = m_len + slen + 1;
resize(nl);
std::memcpy(m_ptr + m_len, s.cstr(), slen);
std::memcpy(m_ptr + m_len, s.c_str(), slen);
m_len += slen;
m_ptr[m_len] = 0;
}

View File

@ -90,7 +90,7 @@ public:
iterator end() const { return iterator(m_ptr->str() + blen()); }
// C string conversion helpers
const mem_t *cstr() const { return m_ptr->str(); }
const mem_t *c_str() const { return m_ptr->str(); }
// concatenation operators
pstring_t& operator+=(const pstring_t &string) { pcat(string); return *this; }
@ -356,7 +356,7 @@ public:
pstringbuffer &operator=(const pstringbuffer &string) { pcopy(string); return *this; }
// C string conversion helpers
const char *cstr() const { return m_ptr; }
const char *c_str() const { return m_ptr; }
operator pstring() const { return pstring(m_ptr); }
@ -405,7 +405,7 @@ namespace std
typedef std::size_t result_type;
result_type operator()(argument_type const& s) const
{
const pstring::mem_t *string = s.cstr();
const pstring::mem_t *string = s.c_str();
result_type result = 5381;
for (pstring::mem_t c = *string; c != 0; c = *string++)
result = ((result << 5) + result ) ^ (result >> (32 - 5)) ^ static_cast<result_type>(c);

View File

@ -57,7 +57,7 @@ namespace plib
ename (e v) : m_v(v) { } \
bool set_from_string (const pstring &s) { \
static const char *strings = # __VA_ARGS__; \
int f = from_string_int(strings, s.cstr()); \
int f = from_string_int(strings, s.c_str()); \
if (f>=0) { m_v = static_cast<e>(f); return true; } else { return false; } \
} \
operator e() const {return m_v;} \

View File

@ -33,10 +33,10 @@ namespace plib
const pstring environment(const pstring &var, const pstring &default_val)
{
if (getenv(var.cstr()) == nullptr)
if (getenv(var.c_str()) == nullptr)
return default_val;
else
return pstring(getenv(var.cstr()));
return pstring(getenv(var.c_str()));
}
}
@ -73,7 +73,7 @@ namespace plib
std::size_t p = static_cast<std::size_t>(-1);
for (std::size_t j=0; j < onstrl.size(); j++)
{
if (std::memcmp(onstrl[j].cstr(), &(str.cstr()[i]), onstrl[j].blen())==0)
if (std::memcmp(onstrl[j].c_str(), &(str.c_str()[i]), onstrl[j].blen())==0)
{
p = j;
break;
@ -90,7 +90,7 @@ namespace plib
}
else
{
pstring::traits::code_t c = pstring::traits::code(str.cstr() + i);
pstring::traits::code_t c = pstring::traits::code(str.c_str() + i);
col += c;
i+=pstring::traits::codelen(c);
}

View File

@ -181,7 +181,7 @@ protected:
void vlog(const plib::plog_level &l, const pstring &ls) const override
{
pstring err = plib::pfmt("{}: {}\n")(l.name())(ls.cstr());
pstring err = plib::pfmt("{}: {}\n")(l.name())(ls.c_str());
pout("{}", err);
if (l == plib::plog_level::FATAL)
throw netlist::nl_exception(err);
@ -199,7 +199,7 @@ void usage(tool_options_t &opts)
{
pout("{}\n", opts.help(
"nltool serves as the Swiss Army knife to run, test and convert netlists.",
"nltool [options]").cstr());
"nltool [options]").c_str());
}
struct input_t
@ -214,7 +214,7 @@ struct input_t
{
char buf[400];
double t;
int e = sscanf(line.cstr(), "%lf,%[^,],%lf", &t, buf, &m_value);
int e = sscanf(line.c_str(), "%lf,%[^,],%lf", &t, buf, &m_value);
if ( e!= 3)
throw netlist::nl_exception(plib::pfmt("error {1} scanning line {2}\n")(e)(line));
m_time = netlist::netlist_time::from_double(t);
@ -409,13 +409,13 @@ static void listdevices(tool_options_t &opts)
out += "," + f->param_desc();
}
out += ")";
printf("%s\n", out.cstr());
printf("%s\n", out.c_str());
if (terms.size() > 0)
{
pstring t = "";
for (auto & j : terms)
t += "," + j;
printf("Terminals: %s\n", t.substr(1).cstr());
printf("Terminals: %s\n", t.substr(1).c_str());
}
devs.push_back(std::move(d));
}
@ -514,11 +514,11 @@ int main(int argc, char *argv[])
result = c.result();
}
/* present result */
pout_strm.write(result.cstr());
pout_strm.write(result.c_str());
}
else
{
perr("Unknown command {}\n", cmd.cstr());
perr("Unknown command {}\n", cmd.c_str());
usage(opts);
return 1;
}

View File

@ -148,7 +148,7 @@ static void convert(nlwav_options_t &opts)
{
#if 1
double t = 0.0; double v = 0.0;
sscanf(line.cstr(), "%lf %lf", &t, &v);
sscanf(line.c_str(), "%lf %lf", &t, &v);
while (t >= ct)
{
outsam += (ct - lt) * cursam;
@ -203,7 +203,7 @@ static void convert(nlwav_options_t &opts)
static void usage(plib::pstream_fmt_writer_t &fw, nlwav_options_t &opts)
{
fw("{}\n", opts.help("Convert netlist log files into wav files.\n",
"nltool [options]").cstr());
"nltool [options]").c_str());
}

View File

@ -300,7 +300,7 @@ unsigned matrix_solver_w_t<m_N, storage_N>::solve_non_dynamic(const bool newton_
for (unsigned i = 0; i < rowcount; i++)
{
if (H[i][i] == 0.0)
printf("%s H singular\n", this->name().cstr());
printf("%s H singular\n", this->name().c_str());
const nl_double f = 1.0 / H[i][i];
for (unsigned j = i+1; j < rowcount; j++)
{
@ -355,7 +355,7 @@ unsigned matrix_solver_w_t<m_N, storage_N>::solve_non_dynamic(const bool newton_
tmp += A(i,j) * new_V[j];
}
if (std::abs(tmp-RHS(i)) > 1e-6)
printf("%s failed on row %d: %f RHS: %f\n", this->name().cstr(), i, std::abs(tmp-RHS(i)), RHS(i));
printf("%s failed on row %d: %f RHS: %f\n", this->name().c_str(), i, std::abs(tmp-RHS(i)), RHS(i));
}
if (newton_raphson)
{

View File

@ -121,7 +121,7 @@ void nl_convert_base_t::dump_nl()
{
net_t *net = m_nets[m_ext_alias[i]].get();
// use the first terminal ...
out("ALIAS({}, {})\n", m_ext_alias[i].cstr(), net->terminals()[0].cstr());
out("ALIAS({}, {})\n", m_ext_alias[i].c_str(), net->terminals()[0].c_str());
// if the aliased net only has this one terminal connected ==> don't dump
if (net->terminals().size() == 1)
net->set_no_export();
@ -138,14 +138,14 @@ void nl_convert_base_t::dump_nl()
std::size_t j = sorted[i];
if (m_devs[j]->has_value())
out("{}({}, {})\n", m_devs[j]->type().cstr(),
m_devs[j]->name().cstr(), get_nl_val(m_devs[j]->value()).cstr());
out("{}({}, {})\n", m_devs[j]->type().c_str(),
m_devs[j]->name().c_str(), get_nl_val(m_devs[j]->value()).c_str());
else if (m_devs[j]->has_model())
out("{}({}, \"{}\")\n", m_devs[j]->type().cstr(),
m_devs[j]->name().cstr(), m_devs[j]->model().cstr());
out("{}({}, \"{}\")\n", m_devs[j]->type().c_str(),
m_devs[j]->name().c_str(), m_devs[j]->model().c_str());
else
out("{}({})\n", m_devs[j]->type().cstr(),
m_devs[j]->name().cstr());
out("{}({})\n", m_devs[j]->type().c_str(),
m_devs[j]->name().c_str());
}
// print nets
for (auto & i : m_nets)
@ -153,11 +153,11 @@ void nl_convert_base_t::dump_nl()
net_t * net = i.second.get();
if (!net->is_no_export())
{
//printf("Net {}\n", net->name().cstr());
out("NET_C({}", net->terminals()[0].cstr() );
//printf("Net {}\n", net->name().c_str());
out("NET_C({}", net->terminals()[0].c_str() );
for (std::size_t j=1; j<net->terminals().size(); j++)
{
out(", {}", net->terminals()[j].cstr() );
out(", {}", net->terminals()[j].c_str() );
}
out(")\n");
}
@ -178,7 +178,7 @@ const pstring nl_convert_base_t::get_nl_val(const double val)
break;
i++;
}
return plib::pfmt(m_units[i].m_func.cstr())(val / m_units[i].m_mult);
return plib::pfmt(m_units[i].m_func.c_str())(val / m_units[i].m_mult);
}
}
double nl_convert_base_t::get_sp_unit(const pstring &unit)
@ -190,7 +190,7 @@ double nl_convert_base_t::get_sp_unit(const pstring &unit)
return m_units[i].m_mult;
i++;
}
fprintf(stderr, "Unit %s unknown\n", unit.cstr());
fprintf(stderr, "Unit %s unknown\n", unit.c_str());
return 0.0;
}
@ -269,12 +269,12 @@ void nl_convert_spice_t::process_line(const pstring &line)
out("// {}\n", line.substr(1));
break;
case '*':
out("// {}\n", line.substr(1).cstr());
out("// {}\n", line.substr(1).c_str());
break;
case '.':
if (tt[0].equals(".SUBCKT"))
{
out("NETLIST_START({})\n", tt[1].cstr());
out("NETLIST_START({})\n", tt[1].c_str());
for (std::size_t i=2; i<tt.size(); i++)
add_ext_alias(tt[i]);
}
@ -284,7 +284,7 @@ void nl_convert_spice_t::process_line(const pstring &line)
out("NETLIST_END()\n");
}
else
out("// {}\n", line.cstr());
out("// {}\n", line.c_str());
break;
case 'Q':
{
@ -304,7 +304,7 @@ void nl_convert_spice_t::process_line(const pstring &line)
if (m.size() == 2)
{
if (m[1].len() != 4)
fprintf(stderr, "error with model desc %s\n", model.cstr());
fprintf(stderr, "error with model desc %s\n", model.c_str());
pins = m[1].left(m[1].begin() + 3);
}
add_device("QBJT_EB", tt[0], m[0]);
@ -346,7 +346,7 @@ void nl_convert_spice_t::process_line(const pstring &line)
//add_term(tt[2], tt[0] + ".2");
}
else
fprintf(stderr, "Voltage Source %s not connected to GND\n", tt[0].cstr());
fprintf(stderr, "Voltage Source %s not connected to GND\n", tt[0].c_str());
break;
case 'I': // Input pin special notation
{
@ -379,7 +379,7 @@ void nl_convert_spice_t::process_line(const pstring &line)
break;
}
default:
out("// IGNORED {}: {}\n", tt[0].cstr(), line.cstr());
out("// IGNORED {}: {}\n", tt[0].c_str(), line.c_str());
}
}
}
@ -485,7 +485,7 @@ void nl_convert_eagle_t::convert(const pstring &contents)
}
else
{
out("Unexpected {}\n", token.str().cstr());
out("Unexpected {}\n", token.str().c_str());
return;
}
}

View File

@ -204,7 +204,7 @@ public:
void verror(const pstring &msg, int line_num, const pstring &line) override
{
m_convert.out("{} (line {}): {}\n", msg.cstr(), line_num, line.cstr());
m_convert.out("{} (line {}): {}\n", msg.c_str(), line_num, line.c_str());
}
@ -273,7 +273,7 @@ public:
void verror(const pstring &msg, int line_num, const pstring &line) override
{
m_convert.out("{} (line {}): {}\n", msg.cstr(), line_num, line.cstr());
m_convert.out("{} (line {}): {}\n", msg.c_str(), line_num, line.c_str());
}