当前位置: 首页>>代码示例>>C++>>正文


C++ pstring::substr方法代码示例

本文整理汇总了C++中pstring::substr方法的典型用法代码示例。如果您正苦于以下问题:C++ pstring::substr方法的具体用法?C++ pstring::substr怎么用?C++ pstring::substr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pstring的用法示例。


在下文中一共展示了pstring::substr方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: get_sp_val

double nl_convert_base_t::get_sp_val(const pstring &sin)
{
	std::size_t p = 0;
	while (p < sin.length() && (m_numberchars.find(sin.substr(p, 1)) != pstring::npos))
		++p;
	pstring val = plib::left(sin, p);
	pstring unit = sin.substr(p);
	double ret = get_sp_unit(unit) * plib::pstonum<double, true>(val);
	return ret;
}
开发者ID:fesh0r,项目名称:mame-full,代码行数:10,代码来源:nl_convert.cpp

示例2: get_sp_val

double nl_convert_base_t::get_sp_val(const pstring &sin)
{
	std::size_t p = 0;
	while (p < sin.length() && (m_numberchars.find(sin.substr(p, 1)) != pstring::npos))
		++p;
	pstring val = sin.left(p);
	pstring unit = sin.substr(p);
	double ret = get_sp_unit(unit) * val.as_double();
	return ret;
}
开发者ID:MASHinfo,项目名称:mame,代码行数:10,代码来源:nl_convert.cpp

示例3: get_sp_val

double nl_convert_base_t::get_sp_val(const pstring &sin)
{
	int p = sin.len() - 1;
	while (p>=0 && (sin.substr(p,1) < "0" || sin.substr(p,1) > "9"))
		p--;
	pstring val = sin.substr(0,p + 1);
	pstring unit = sin.substr(p + 1);

	double ret = get_sp_unit(unit) * val.as_double();
	return ret;
}
开发者ID:NULUSIOS,项目名称:mame,代码行数:11,代码来源:nl_convert.cpp

示例4: compile

void pfunction::compile(const std::vector<pstring> &inputs, const pstring &expr)
{
	if (expr.startsWith("rpn:"))
		compile_postfix(inputs, expr.substr(4));
	else
		compile_infix(inputs, expr);
}
开发者ID:MASHinfo,项目名称:mame,代码行数:7,代码来源:pfunction.cpp

示例5: process_comments

pstring ppreprocessor::process_comments(pstring line)
{
	bool in_string = false;

	std::size_t e = line.size();
	pstring ret = "";
	for (std::size_t i=0; i < e; )
	{
		pstring c = plib::left(line, 1);
		line = line.substr(1);
		if (!m_comment)
		{
			if (c=="\"")
			{
				in_string = !in_string;
				ret += c;
			}
			else if (in_string && c=="\\")
			{
				i++;
				ret += (c + plib::left(line, 1));
				line = line.substr(1);
			}
			else if (!in_string && c=="/" && plib::left(line,1) == "*")
				m_comment = true;
			else if (!in_string && c=="/" && plib::left(line,1) == "/")
				break;
			else
				ret += c;
		}
		else
			if (c=="*" && plib::left(line,1) == "/")
			{
				i++;
				line = line.substr(1);
				m_comment = false;
			}
		i++;
	}
	return ret;
}
开发者ID:PugsyMAME,项目名称:mame,代码行数:41,代码来源:pparser.cpp

示例6: 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]);
//.........这里部分代码省略.........
开发者ID:NULUSIOS,项目名称:mame,代码行数:101,代码来源:nl_convert.cpp

示例7: 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;
//.........这里部分代码省略.........
开发者ID:fesh0r,项目名称:mame-full,代码行数:101,代码来源:nl_convert.cpp


注:本文中的pstring::substr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。