本文整理汇总了C++中pstring::size方法的典型用法代码示例。如果您正苦于以下问题:C++ pstring::size方法的具体用法?C++ pstring::size怎么用?C++ pstring::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pstring
的用法示例。
在下文中一共展示了pstring::size方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: append_sheet
void orcus_xml::append_sheet(const pstring& name)
{
if (name.empty())
return;
mp_impl->mp_import_factory->append_sheet(name.get(), name.size());
}
示例2: characters
void xls_xml_context::characters(const pstring& str, bool transient)
{
if (str.empty())
return;
const xml_token_pair_t& elem = get_current_element();
if (elem.first == NS_xls_xml_ss && elem.second == XML_Data)
{
switch (m_cur_cell_type)
{
case ct_string:
{
if (transient)
m_cur_cell_string.push_back(m_pool.intern(str).first);
else
m_cur_cell_string.push_back(str);
}
break;
case ct_number:
{
const char* p = str.get();
m_cur_cell_value = to_double(p, p + str.size());
}
break;
default:
;
}
}
}
示例3: 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;
}
示例4: to_length
length_t to_length(const pstring& str)
{
length_t ret;
if (str.empty())
return ret;
const char* p = str.get();
const char* p_start = p;
const char* p_end = p_start + str.size();
ret.value = parse_numeric(p, p_end);
// TODO: See if this part can be optimized.
pstring tail(p, p_end-p);
if (tail == "in")
ret.unit = length_unit_inch;
else if (tail == "cm")
ret.unit = length_unit_centimeter;
else if (tail == "pt")
ret.unit = length_unit_point;
return ret;
}
示例5: to_date_time
date_time_t to_date_time(const pstring& str)
{
date_time_t ret;
int dash_count = 0, t_count = 0, colon_count = 0;
const char* p = str.get();
const char* p_end = p + str.size();
const char* digit = p;
size_t digit_len = 0;
bool valid = true;
for (; p != p_end && valid; ++p)
{
switch (*p)
{
case '-':
{
if (t_count || colon_count || !digit)
{
// Invalid date-time value. All dashes must occur before
// any of 'T' and ':' occur.
valid = false;
break;
}
switch (dash_count)
{
case 0:
// Flush year.
flush_int(ret.year, digit, digit_len);
break;
case 1:
// Flush month.
flush_int(ret.month, digit, digit_len);
break;
default:
valid = false;
}
++dash_count;
}
break;
case 'T':
{
if (t_count || dash_count != 2 || !digit)
{
// Invalid date-time value.
valid = false;
break;
}
// Flush day.
ret.day = strtol(digit, NULL, 10);
digit = NULL;
digit_len = 0;
++t_count;
}
break;
case ':':
{
if (!t_count || !digit)
{
// Invalid date-time value.
valid = false;
break;
}
switch (colon_count)
{
case 0:
// Flush hour.
flush_int(ret.hour, digit, digit_len);
break;
case 1:
// Flush minute.
flush_int(ret.minute, digit, digit_len);
break;
default:
valid = false;
}
++colon_count;
}
break;
default:
{
if (t_count)
{
// Time element.
switch (colon_count)
{
case 0:
// Hour
process_char(p, digit, digit_len);
break;
case 1:
// Minute
process_char(p, digit, digit_len);
break;
case 2:
//.........这里部分代码省略.........
示例6: type
parse_token::parse_token(const pstring& _characters) :
type(parse_token_t::characters)
{
characters.p = _characters.get();
characters.n = _characters.size();
}
示例7: process_line
pstring ppreprocessor::process_line(pstring line)
{
bool line_cont = plib::right(line, 1) == "\\";
if (line_cont)
line = plib::left(line, line.size() - 1);
if (m_state == LINE_CONTINUATION)
m_line += line;
else
m_line = line;
if (line_cont)
{
m_state = LINE_CONTINUATION;
return "";
}
else
m_state = PROCESS;
line = process_comments(m_line);
pstring lt = plib::trim(plib::replace_all(line, pstring("\t"), pstring(" ")));
pstring ret;
// FIXME ... revise and extend macro handling
if (plib::startsWith(lt, "#"))
{
std::vector<pstring> lti(psplit(lt, " ", true));
if (lti[0] == "#if")
{
m_level++;
std::size_t start = 0;
lt = replace_macros(lt);
std::vector<pstring> t(psplit(replace_all(lt.substr(3), pstring(" "), pstring("")), m_expr_sep));
int val = static_cast<int>(expr(t, start, 255));
if (val == 0)
m_ifflag |= (1 << m_level);
}
else if (lti[0] == "#ifdef")
{
m_level++;
if (get_define(lti[1]) == nullptr)
m_ifflag |= (1 << m_level);
}
else if (lti[0] == "#ifndef")
{
m_level++;
if (get_define(lti[1]) != nullptr)
m_ifflag |= (1 << m_level);
}
else if (lti[0] == "#else")
{
m_ifflag ^= (1 << m_level);
}
else if (lti[0] == "#endif")
{
m_ifflag &= ~(1 << m_level);
m_level--;
}
else if (lti[0] == "#include")
{
// ignore
}
else if (lti[0] == "#pragma")
{
if (m_ifflag == 0 && lti.size() > 3 && lti[1] == "NETLIST")
{
if (lti[2] == "warning")
error("NETLIST: " + catremainder(lti, 3, " "));
}
}
else if (lti[0] == "#define")
{
if (m_ifflag == 0)
{
if (lti.size() != 3)
error("PREPRO: only simple defines allowed: " + line);
m_defines.insert({lti[1], define_t(lti[1], lti[2])});
}
}
else
{
if (m_ifflag == 0)
error(pfmt("unknown directive on line {1}: {2}")(m_lineno)(replace_macros(line)));
}
}
else
{
lt = replace_macros(lt);
if (m_ifflag == 0)
ret += lt;
}
return ret;
}