本文整理汇总了C++中StringT::size方法的典型用法代码示例。如果您正苦于以下问题:C++ StringT::size方法的具体用法?C++ StringT::size怎么用?C++ StringT::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringT
的用法示例。
在下文中一共展示了StringT::size方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TOKEN_FROM_ID
inline bool
handle_identifier(boost::wave::token_id prev,
boost::wave::token_id before, StringT const &value)
{
using namespace boost::wave;
switch (static_cast<unsigned int>(prev)) {
case T_IDENTIFIER:
case T_NONREPLACABLE_IDENTIFIER:
case T_COMPL_ALT:
case T_OR_ALT:
case T_AND_ALT:
case T_NOT_ALT:
case T_XOR_ALT:
case T_ANDASSIGN_ALT:
case T_ORASSIGN_ALT:
case T_XORASSIGN_ALT:
case T_NOTEQUAL_ALT:
case T_FIXEDPOINTLIT:
return true;
case T_FLOATLIT:
case T_INTLIT:
case T_PP_NUMBER:
return (value.size() > 1 || (value[0] != 'e' && value[0] != 'E'));
// avoid constructing universal characters (\u1234)
case TOKEN_FROM_ID('\\', UnknownTokenType):
return would_form_universal_char(value);
}
return false;
}
示例2: ctx
void
read_s(
StringT& str,
void const* data,
std::size_t const size
) {
duct::IO::StreamContext ctx(FromU::id, duct::Endian::system);
duct::IO::imemstream stream(data, size * FromU::char_size);
std::printf(
"stream size: %lu\n",
static_cast<unsigned long>(duct::IO::size(stream))
);
DUCT_ASSERTE(stream.good());
ctx.read_string(
stream, str, static_cast<std::streamsize>(size), duct::CHAR_NULL
);
DUCT_ASSERTE(stream.good());
print_states(stream);
std::printf(
"String [size: %lu bsize: %lu len: %lu]: |",
static_cast<unsigned long>(size),
static_cast<unsigned long>(size*FromU::char_size),
static_cast<unsigned long>(str.size())
);
std::cout << str << "|\n";
str.clear();
}
示例3: would_form_universal_char
inline bool
would_form_universal_char (StringT const &value)
{
if ('u' != value[0] && 'U' != value[0])
return false;
if ('u' == value[0] && value.size() < 5)
return false;
if ('U' == value[0] && value.size() < 9)
return false;
typename StringT::size_type pos =
value.find_first_not_of("0123456789abcdefABCDEF", 1);
if (StringT::npos == pos ||
('u' == value[0] && pos > 5) ||
('U' == value[0] && pos > 9))
{
return true; // would form an universal char
}
return false;
}
示例4: switch
inline bool
is_trigraph(StringT const& trigraph)
{
if (trigraph.size() < 3 || '?' != trigraph[0] || '?' != trigraph[1])
return false;
switch (trigraph[2]) {
case '\'': case '=': case '/': case '(':
case ')': case '<': case '>': case '!':
case '-':
break;
default:
return false;
}
return true;
}
示例5:
inline bool
is_special_macroname (StringT const &name)
{
if (name.size() < 7)
return false;
if ("defined" == name)
return true;
if ('_' == name[0] && '_' == name[1]) {
StringT str = name.substr(2);
if (str == "cplusplus" || str == "STDC__" ||
str == "TIME__" || str == "DATE__" ||
str == "LINE__" || str == "FILE__" ||
str == "INCLUDE_LEVEL__")
{
return true;
}
}
return false;
}
示例6: show_help
/**
* show help and usage information
*
* @param out output stream
* @param program_name the name of executable to display
* @param usage_str additional help shown before help for options
*
* @param show_usage should "Usage:" information be shown, can be
* useful when this help is shown additionally to main help
*/
void show_help(std::ostream &out, char const *program_name
, StringT const &usage_str = ""
, bool show_usage = true) const
{
if (show_usage) {
if (usage_str.size()) {
out << "Usage: " << program_name << " " << usage_str;
} else {
out << "Usage: " << program_name << " [options]\n"
<< "\twhere [options] are:\n";
}
} else {
out << usage_str;
}
std::map<StringT, std::pair<char, StringT> > grouped;
for (auto p : short_opts_)
grouped[p.second].first = p.first;
for (auto p : long_opts_)
grouped[p.second].second = p.first;
for (auto p : grouped) {
auto &sl = p.second;
out << "\t";
if (sl.first) {
out << '-' << sl.first;
if (opt_with_params_.count(p.first))
out << " <" << p.first << '>';
}
out << "\t";
if (sl.second.size()) {
out << "--" << sl.second;
if (opt_with_params_.count(p.first))
out << " <" << p.first << '>';
}
out << "\n";
}
}
示例7: mg_write
static int inline mg_write(struct mg_connection* conn, const StringT& string)
{
return mg_write(conn, string.c_str(), string.size());
}