本文整理汇总了C++中dynamic_string_array::size方法的典型用法代码示例。如果您正苦于以下问题:C++ dynamic_string_array::size方法的具体用法?C++ dynamic_string_array::size怎么用?C++ dynamic_string_array::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dynamic_string_array
的用法示例。
在下文中一共展示了dynamic_string_array::size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write_text_file
bool file_utils::write_text_file(const char *pPath, const dynamic_string_array &lines, bool unix_line_endings)
{
cfile_stream stream;
if (!stream.open(pPath, cDataStreamWritable))
return false;
for (uint i = 0; i < lines.size(); i++)
{
const dynamic_string &str = lines[i];
if (str.get_len())
stream.write(str.get_ptr(), str.get_len());
if (unix_line_endings)
stream.write("\n", 1);
else
stream.write("\r\n", 2);
}
return !stream.get_error();
}
示例2: parse
bool command_line_params::parse(const dynamic_string_array ¶ms, uint32_t total_param_descs, const command_line_param_desc *pParam_desc, const command_line_params::parse_config &config)
{
m_params = params;
command_line_param_desc desc;
desc.m_num_values = 0;
desc.m_support_listing_file = false;
desc.m_pName = "";
desc.m_pDesc = NULL;
uint32_t arg_index = 0;
while (arg_index < params.size())
{
const uint32_t cur_arg_index = arg_index;
const dynamic_string &src_param = params[arg_index++];
if (src_param.is_empty())
continue;
bool is_param = false;
uint32_t param_prefix_chars = 1;
#if VOGL_CMD_LINE_ALLOW_SLASH_PARAMS
is_param = (src_param[0] == '/');
#endif
if ((src_param[0] == '-') && ((config.m_single_minus_params) || (config.m_double_minus_params)))
{
is_param = true;
bool double_minus = (src_param[1] == '-');
if (double_minus)
{
if (config.m_double_minus_params)
{
param_prefix_chars = 2;
}
else
{
if (config.m_ignore_unrecognized_params)
continue;
console::error("Unrecognized command line parameter: \"%s\"\n", src_param.get_ptr());
return false;
}
}
}
if (is_param)
{
if (src_param.get_len() < (param_prefix_chars + 1))
{
console::warning("Skipping invalid command line parameter: \"%s\"\n", src_param.get_ptr());
continue;
}
dynamic_string key_str(src_param);
key_str.right(param_prefix_chars);
if (config.m_pParam_ignore_prefix)
{
if (key_str.begins_with(config.m_pParam_ignore_prefix, true))
continue;
}
if (config.m_pParam_accept_prefix)
{
if (!key_str.begins_with(config.m_pParam_accept_prefix, true))
continue;
}
int modifier = 0;
char c = key_str[key_str.get_len() - 1];
if (c == '+')
modifier = 1;
else if (c == '-')
modifier = -1;
if (modifier)
key_str.left(key_str.get_len() - 1);
if (total_param_descs)
{
uint32_t param_index;
for (param_index = 0; param_index < total_param_descs; param_index++)
if (key_str == pParam_desc[param_index].m_pName)
break;
if (param_index == total_param_descs)
{
if (config.m_ignore_unrecognized_params)
continue;
console::error("Unrecognized command line parameter: \"%s\"\n", src_param.get_ptr());
return false;
}
desc = pParam_desc[param_index];
}
//.........这里部分代码省略.........
示例3: parse
bool command_line_params::parse(const dynamic_string_array& params, uint n, const param_desc* pParam_desc)
{
CRNLIB_ASSERT(n && pParam_desc);
m_params = params;
uint arg_index = 0;
while (arg_index < params.size())
{
const uint cur_arg_index = arg_index;
const dynamic_string& src_param = params[arg_index++];
if (src_param.is_empty())
continue;
#if CRNLIB_CMD_LINE_ALLOW_SLASH_PARAMS
if ((src_param[0] == '/') || (src_param[0] == '-'))
#else
if (src_param[0] == '-')
#endif
{
if (src_param.get_len() < 2)
{
console::error("Invalid command line parameter: \"%s\"", src_param.get_ptr());
return false;
}
dynamic_string key_str(src_param);
key_str.right(1);
int modifier = 0;
char c = key_str[key_str.get_len() - 1];
if (c == '+')
modifier = 1;
else if (c == '-')
modifier = -1;
if (modifier)
key_str.left(key_str.get_len() - 1);
uint param_index;
for (param_index = 0; param_index < n; param_index++)
if (key_str == pParam_desc[param_index].m_pName)
break;
if (param_index == n)
{
console::error("Unrecognized command line parameter: \"%s\"", src_param.get_ptr());
return false;
}
const param_desc& desc = pParam_desc[param_index];
const uint cMaxValues = 16;
dynamic_string val_str[cMaxValues];
uint num_val_strs = 0;
if (desc.m_num_values)
{
CRNLIB_ASSERT(desc.m_num_values <= cMaxValues);
if ((arg_index + desc.m_num_values) > params.size())
{
console::error("Expected %u value(s) after command line parameter: \"%s\"", desc.m_num_values, src_param.get_ptr());
return false;
}
for (uint v = 0; v < desc.m_num_values; v++)
val_str[num_val_strs++] = params[arg_index++];
}
dynamic_string_array strings;
if ((desc.m_support_listing_file) && (val_str[0].get_len() >= 2) && (val_str[0][0] == '@'))
{
dynamic_string filename(val_str[0]);
filename.right(1);
filename.unquote();
if (!load_string_file(filename.get_ptr(), strings))
{
console::error("Failed loading listing file \"%s\"!", filename.get_ptr());
return false;
}
}
else
{
for (uint v = 0; v < num_val_strs; v++)
{
val_str[v].unquote();
strings.push_back(val_str[v]);
}
}
param_value pv;
pv.m_values.swap(strings);
pv.m_index = cur_arg_index;
pv.m_modifier = (int8)modifier;
m_param_map.insert(std::make_pair(key_str, pv));
}
else
//.........这里部分代码省略.........