本文整理汇总了C++中pstring::cstr方法的典型用法代码示例。如果您正苦于以下问题:C++ pstring::cstr方法的具体用法?C++ pstring::cstr怎么用?C++ pstring::cstr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pstring
的用法示例。
在下文中一共展示了pstring::cstr方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadLibrary
pdynlib::pdynlib(const pstring libname)
: m_isLoaded(false), m_lib(nullptr)
{
#ifdef _WIN32
//fprintf(stderr, "win: loading <%s>\n", libname.cstr());
if (libname != "")
m_lib = LoadLibrary(libname.cstr());
else
m_lib = GetModuleHandle(nullptr);
if (m_lib != nullptr)
m_isLoaded = true;
//else
// fprintf(stderr, "win: library <%s> not found!\n", libname.cstr());
#else
//printf("loading <%s>\n", libname.cstr());
if (libname != "")
m_lib = dlopen(libname.cstr(), 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());
#endif
}
示例2: model_value
ATTR_COLD nl_double netlist_param_model_t::model_value(const pstring &entity, const nl_double defval) const
{
pstring tmp = this->Value();
// .model 1N914 D(Is=2.52n Rs=.568 N=1.752 Cjo=4p M=.4 tt=20n Iave=200m Vpk=75 mfg=OnSemi type=silicon)
int p = tmp.ucase().find(entity.ucase() + "=");
if (p>=0)
{
int pblank = tmp.find(" ", p);
if (pblank < 0) pblank = tmp.len() + 1;
tmp = tmp.substr(p, pblank - p);
int pequal = tmp.find("=", 0);
if (pequal < 0)
netlist().error("parameter %s misformat in model %s temp %s\n", entity.cstr(), Value().cstr(), tmp.cstr());
tmp = tmp.substr(pequal+1);
nl_double factor = NL_FCONST(1.0);
switch (*(tmp.right(1).cstr()))
{
case 'm': factor = 1e-3; break;
case 'u': factor = 1e-6; break;
case 'n': factor = 1e-9; break;
case 'p': factor = 1e-12; break;
case 'f': factor = 1e-15; break;
case 'a': factor = 1e-18; break;
}
if (factor != NL_FCONST(1.0))
tmp = tmp.left(tmp.len() - 1);
return (nl_double) atof(tmp.cstr()) * factor;
}
else
{
netlist().log("Entity %s not found in model %s\n", entity.cstr(), tmp.cstr());
return defval;
}
}
示例3: verror
ATTR_COLD void parser_t::verror(pstring msg, int line_num, pstring line)
{
m_setup.netlist().error("line %d: error: %s\n\t\t%s\n", line_num,
msg.cstr(), line.cstr());
//throw error;
}
示例4: fatalerror_e
input_t(netlist::netlist_t *netlist, const pstring &line)
{
char buf[400];
double t;
int e = sscanf(line.cstr(), "%lf,%[^,],%lf", &t, buf, &m_value);
if ( e!= 3)
throw netlist::fatalerror_e("error %d scanning line %s\n", e, line.cstr());
m_time = netlist::netlist_time::from_double(t);
m_param = netlist->setup().find_param(buf, true);
}
示例5: fatalerror_e
wav_t(const pstring &fn, unsigned sr)
{
m_f = std::fopen(fn.cstr(),"w");
if (m_f==NULL)
throw netlist::fatalerror_e("Error opening output file: %s", fn.cstr());
initialize(sr);
std::fwrite(&m_fh, sizeof(m_fh), 1, m_f);
std::fwrite(&m_fmt, sizeof(m_fmt), 1, m_f);
std::fwrite(&m_data, sizeof(m_data), 1, m_f);
}
示例6: fopen
const char *filetobuf(pstring fname)
{
static pstring pbuf = "";
if (fname == "-")
{
char lbuf[1024];
while (!feof(stdin))
{
fgets(lbuf, 1024, stdin);
pbuf += lbuf;
}
printf("%d\n",*(pbuf.right(1).cstr()+1));
return pbuf.cstr();
}
else
{
FILE *f;
f = fopen(fname, "rb");
fseek(f, 0, SEEK_END);
long fsize = ftell(f);
fseek(f, 0, SEEK_SET);
char *buf = (char *) malloc(fsize + 1);
fread(buf, fsize, 1, f);
buf[fsize] = 0;
fclose(f);
return buf;
}
}
示例7: fatalerror_e
input_t(netlist::netlist_t *netlist, const pstring &line)
{
char buf[400];
double t;
int e = sscanf(line.cstr(), "%lf,%[^,],%lf", &t, buf, &m_value);
if ( e!= 3)
throw netlist::fatalerror_e(plib::pfmt("error {1} scanning line {2}\n")(e)(line));
m_time = netlist::netlist_time(t);
m_param = netlist->setup().find_param(buf, true);
}
示例8: get_sp_unit
double nl_convert_base_t::get_sp_unit(const pstring &unit)
{
int i = 0;
while (m_units[i].m_unit != "-")
{
if (m_units[i].m_unit == unit)
return m_units[i].m_mult;
i++;
}
fprintf(stderr, "Unit %s unknown\n", unit.cstr());
return 0.0;
}
示例9: postream
pofilestream::pofilestream(const pstring &fname) : postream(0), m_pos(0)
{
m_file = fopen(fname.cstr(), "wb");
if (m_file == NULL)
{
set_flag(FLAG_ERROR);
set_flag(FLAG_CLOSED);
}
else
{
if (ftell((FILE *) m_file) >= 0)
{
if (fseek((FILE *) m_file, 0, SEEK_SET) >= 0)
set_flag(FLAG_SEEKABLE);
}
}
}
示例10: process_line
void nl_convert_spice_t::process_line(const pstring &line)
{
if (line != "")
{
pstring_vector_t tt(line, " ", true);
double val = 0.0;
switch (tt[0].code_at(0))
{
case ';':
out("// {}\n", line.substr(1).cstr());
break;
case '*':
out("// {}\n", line.substr(1).cstr());
break;
case '.':
if (tt[0].equals(".SUBCKT"))
{
out("NETLIST_START({})\n", tt[1].cstr());
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.cstr());
break;
case 'Q':
{
bool cerr = false;
/* check for fourth terminal ... should be numeric net
* including "0" or start with "N" (ltspice)
*/
ATTR_UNUSED int 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];
pstring_vector_t m(model,"{");
if (m.size() == 2)
{
if (m[1].len() != 4)
fprintf(stderr, "error with model desc %s\n", model.cstr());
pins = m[1].left(3);
}
add_device("QBJT_EB", tt[0], m[0]);
add_term(tt[1], tt[0] + "." + pins.code_at(0));
add_term(tt[2], tt[0] + "." + pins.code_at(1));
add_term(tt[3], tt[0] + "." + pins.code_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].cstr());
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]);
//.........这里部分代码省略.........
示例11: error
void ppreprocessor::error(const pstring &err)
{
fprintf(stderr, "PREPRO ERROR: %s\n", err.cstr());
}
示例12: vlog
void vlog(const plib::plog_level &l, const pstring &ls) const override
{
pout("{}: {}\n", l.name().cstr(), ls.cstr());
if (l == plib::plog_level::FATAL)
throw std::exception();
}
示例13: pistream
pifilestream::pifilestream(const pstring &fname)
: pistream(0), m_pos(0), m_actually_close(true)
{
init(fopen(fname.cstr(), "rb"));
}