本文整理汇总了C++中pstring::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ pstring::c_str方法的具体用法?C++ pstring::c_str怎么用?C++ pstring::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pstring
的用法示例。
在下文中一共展示了pstring::c_str方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pcat
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::copy(s.c_str(), s.c_str() + slen, m_ptr + m_len);
m_len += slen;
m_ptr[m_len] = 0;
}
示例2: file_open_e
pofilestream::pofilestream(const pstring &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);
init();
}
示例3: vlog
void netlist_tool_t::vlog(const plib::plog_level &l, const pstring &ls) const
{
pstring err = plib::pfmt("{}: {}\n")(l.name())(ls.c_str());
// FIXME: ...
m_app.pout("{}", err);
if (l == plib::plog_level::FATAL)
throw netlist::nl_exception(err);
}
示例4: nl_exception
input_t(const netlist::setup_t &setup, const pstring &line)
{
char buf[400];
double t;
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);
m_param = setup.find_param(pstring(buf, pstring::UTF8), true);
}
示例5: nl_exception
input_t(const netlist::setup_t &setup, const pstring &line)
: m_value(0.0)
{
std::array<char, 400> buf; // NOLINT(cppcoreguidelines-pro-type-member-init)
double t;
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
int e = sscanf(line.c_str(), "%lf,%[^,],%lf", &t, buf.data(), &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);
m_param = setup.find_param(pstring(buf.data()), true);
}
示例6: vlog
void vlog(const plib::plog_level &l, const pstring &ls) const override
{
switch (l)
{
case plib::plog_level::DEBUG:
break;
case plib::plog_level::VERBOSE:
break;
case plib::plog_level::INFO:
osd_printf_verbose("netlist INFO: %s\n", ls.c_str());
break;
case plib::plog_level::WARNING:
osd_printf_warning("netlist WARNING: %s\n", ls.c_str());
break;
case plib::plog_level::ERROR:
osd_printf_error("netlist ERROR: %s\n", ls.c_str());
break;
case plib::plog_level::FATAL:
throw emu_fatalerror(1, "netlist FATAL: %s\n", ls.c_str());
}
}
示例7: get_sp_unit
double nl_convert_base_t::get_sp_unit(const pstring &unit)
{
int i = 0;
while (pstring(m_units[i].m_unit, pstring::UTF8) != "-")
{
if (pstring(m_units[i].m_unit, pstring::UTF8) == unit)
return m_units[i].m_mult;
i++;
}
fprintf(stderr, "Unit %s unknown\n", unit.c_str());
return 0.0;
}
示例8: vlog
void netlist_tool_callbacks_t::vlog(const plib::plog_level &l, const pstring &ls) const
{
pstring err = plib::pfmt("{}: {}\n")(l.name())(ls.c_str());
if (l == plib::plog_level::WARNING)
m_app.m_warnings++;
if (l == plib::plog_level::ERROR)
m_app.m_errors++;
if (l == plib::plog_level::FATAL)
{
m_app.m_errors++;
throw netlist::nl_exception(err);
}
else
m_app.pout("{}", err);
}
示例9: save
void AgentProgram::save(const pstring& filename)
{
// standard ascii:
ofstream file(filename.c_str());
file << "Destination selection: ";
switch (m_sel_type) {
case SEL_STANDARD:
file << "Standard" << endl;
break;
case SEL_LENGTH:
file << "Gibsonian Length" << endl;
break;
case SEL_OPTIC_FLOW:
file << "Gibsonian Optic Flow" << endl;
break;
case SEL_COMPARATIVE_LENGTH:
file << "Gibsonian Comparative Length" << endl;
break;
case SEL_COMPARATIVE_OPTIC_FLOW:
file << "Gibsonian Comparative Optic Flow" << endl;
break;
default:
file << "Unknown" << endl;
}
file << "Steps: " << m_steps << endl;
file << "Bins: " << ((m_vbin == -1) ? 32 : m_vbin * 2 + 1) << endl;
/*
file << "Ahead bins: " << m_vahead * 2 + 1 << endl;
file << "Ahead threshold: " << m_ahead_threshold << endl;
file << "Feeler threshold: " << m_feeler_threshold << endl;
file << "Feeler probability: " << m_feeler_probability << endl;
*/
file << "Rule order: " << m_rule_order[0] << " "
<< m_rule_order[1] << " "
<< m_rule_order[2] << " "
<< m_rule_order[3] << endl;
for (int i = 0; i < 4; i++) {
file << "Rule " << i << " (Bin -" << 1 + (i * 2) << "/+" << 1 + (i * 2) << ")" << endl;
file << "Threshold: " << m_rule_threshold[i] << endl;
file << "Turn Probability: " << m_rule_probability[i] << endl;
}
file << "Fitness: " << m_fitness << endl;
}
示例10: open
bool AgentProgram::open(const pstring& filename)
{
// standard ascii:
ifstream file(filename.c_str());
pstring line;
file >> line;
if (!line.empty()) {
line.makelower();
if (!compare(line,"destination selection:",22)) {
return false;
}
else {
pstring method = line.substr(22);
method.ltrim();
if (!method.empty()) {
if (method == "standard") {
m_sel_type = SEL_STANDARD;
}
else if (method == "gibsonian length") {
m_sel_type = SEL_LENGTH;
}
else if (method == "gibsonian optic flow") {
m_sel_type = SEL_OPTIC_FLOW;
}
else if (method == "gibsonian comparative length") {
m_sel_type = SEL_COMPARATIVE_LENGTH;
}
else if (method == "gibsonian comparative optic flow") {
m_sel_type = SEL_COMPARATIVE_OPTIC_FLOW;
}
file >> line;
}
else {
return false;
}
}
示例11:
void nl_convert_rinf_t::tokenizer::verror(const pstring &msg, int line_num, const pstring &line)
{
m_convert.out("{} (line {}): {}\n", msg.c_str(), line_num, line.c_str());
}
示例12: process_line
void nl_convert_spice_t::process_line(const pstring &line)
{
if (line != "")
{
//printf("// %s\n", line.c_str());
std::vector<pstring> tt(plib::psplit(line, " ", true));
double val = 0.0;
switch (tt[0].at(0))
{
case ';':
out("// {}\n", line.substr(1));
break;
case '*':
out("// {}\n", line.substr(1).c_str());
break;
case '.':
if (tt[0] == ".SUBCKT")
{
m_subckt = tt[1] + "_";
out("NETLIST_START({})\n", tt[1]);
for (std::size_t i=2; i<tt.size(); i++)
add_ext_alias(tt[i]);
}
else if (tt[0] == ".ENDS")
{
dump_nl();
out("NETLIST_END()\n");
m_subckt = "";
}
else if (tt[0] == ".MODEL")
{
out("NET_MODEL(\"{} {}\")\n", m_subckt + tt[1], rem(tt,2));
}
else
out("// {}\n", line.c_str());
break;
case 'Q':
{
/* check for fourth terminal ... should be numeric net
* including "0" or start with "N" (ltspice)
*/
pstring model;
pstring pins ="CBE";
bool err;
auto nval = plib::pstonum_ne<long, true>(tt[4], err);
plib::unused_var(nval);
if ((!err || plib::startsWith(tt[4], "N")) && tt.size() > 5)
model = tt[5];
else
model = tt[4];
std::vector<pstring> m(plib::psplit(model,"{"));
if (m.size() == 2)
{
if (m[1].length() != 4)
plib::perrlogger("error with model desc {}\n", model);
pins = plib::left(m[1], 3);
}
add_device("QBJT_EB", tt[0], m_subckt + m[0]);
add_term(tt[1], tt[0] + "." + pins.at(0));
add_term(tt[2], tt[0] + "." + pins.at(1));
add_term(tt[3], tt[0] + "." + pins.at(2));
}
break;
case 'R':
if (plib::startsWith(tt[0], "RV"))
{
val = get_sp_val(tt[4]);
add_device("POT", tt[0], val);
add_term(tt[1], tt[0] + ".1");
add_term(tt[2], tt[0] + ".2");
add_term(tt[3], tt[0] + ".3");
}
else
{
val = get_sp_val(tt[3]);
add_device("RES", tt[0], val);
add_term(tt[1], tt[0] + ".1");
add_term(tt[2], tt[0] + ".2");
}
break;
case 'C':
val = get_sp_val(tt[3]);
add_device("CAP", tt[0], val);
add_term(tt[1], tt[0] + ".1");
add_term(tt[2], tt[0] + ".2");
break;
case 'B': // arbitrary behavioural current source - needs manual work afterwords
add_device("CS", tt[0], "/*" + rem(tt, 3) + "*/");
add_term(tt[1], tt[0] + ".P");
add_term(tt[2], tt[0] + ".N");
break;
case 'E':
add_device("VCVS", tt[0]);
add_term(tt[1], tt[0] + ".OP");
add_term(tt[2], tt[0] + ".ON");
add_term(tt[3], tt[0] + ".IP");
add_term(tt[4], tt[0] + ".IN");
out("PARAM({}, {})\n", tt[0] + ".G", tt[5]);
break;
//.........这里部分代码省略.........
示例13: pcopy
void pstringbuffer::pcopy(const pstring &from)
{
std::size_t nl = from.blen() + 1;
resize(nl);
std::copy(from.c_str(), from.c_str() + nl, m_ptr);
}
示例14: process_line
void nl_convert_spice_t::process_line(const pstring &line)
{
if (line != "")
{
std::vector<pstring> tt(plib::psplit(line, " ", true));
double val = 0.0;
switch (tt[0].at(0))
{
case ';':
out("// {}\n", line.substr(1));
break;
case '*':
out("// {}\n", line.substr(1).c_str());
break;
case '.':
if (tt[0].equals(".SUBCKT"))
{
out("NETLIST_START({})\n", tt[1].c_str());
for (std::size_t i=2; i<tt.size(); i++)
add_ext_alias(tt[i]);
}
else if (tt[0].equals(".ENDS"))
{
dump_nl();
out("NETLIST_END()\n");
}
else
out("// {}\n", line.c_str());
break;
case 'Q':
{
bool cerr = false;
/* check for fourth terminal ... should be numeric net
* including "0" or start with "N" (ltspice)
*/
ATTR_UNUSED long nval(tt[4].as_long(&cerr));
pstring model;
pstring pins ="CBE";
if ((!cerr || tt[4].startsWith("N")) && tt.size() > 5)
model = tt[5];
else
model = tt[4];
std::vector<pstring> m(plib::psplit(model,"{"));
if (m.size() == 2)
{
if (m[1].length() != 4)
fprintf(stderr, "error with model desc %s\n", model.c_str());
pins = m[1].left(3);
}
add_device("QBJT_EB", tt[0], m[0]);
add_term(tt[1], tt[0] + "." + pins.at(0));
add_term(tt[2], tt[0] + "." + pins.at(1));
add_term(tt[3], tt[0] + "." + pins.at(2));
}
break;
case 'R':
if (tt[0].startsWith("RV"))
{
val = get_sp_val(tt[4]);
add_device("POT", tt[0], val);
add_term(tt[1], tt[0] + ".1");
add_term(tt[2], tt[0] + ".2");
add_term(tt[3], tt[0] + ".3");
}
else
{
val = get_sp_val(tt[3]);
add_device("RES", tt[0], val);
add_term(tt[1], tt[0] + ".1");
add_term(tt[2], tt[0] + ".2");
}
break;
case 'C':
val = get_sp_val(tt[3]);
add_device("CAP", tt[0], val);
add_term(tt[1], tt[0] + ".1");
add_term(tt[2], tt[0] + ".2");
break;
case 'V':
// just simple Voltage sources ....
if (tt[2].equals("0"))
{
val = get_sp_val(tt[3]);
add_device("ANALOG_INPUT", tt[0], val);
add_term(tt[1], tt[0] + ".Q");
//add_term(tt[2], tt[0] + ".2");
}
else
fprintf(stderr, "Voltage Source %s not connected to GND\n", tt[0].c_str());
break;
case 'I': // Input pin special notation
{
val = get_sp_val(tt[2]);
add_device("ANALOG_INPUT", tt[0], val);
add_term(tt[1], tt[0] + ".Q");
}
break;
case 'D':
add_device("DIODE", tt[0], tt[3]);
//.........这里部分代码省略.........