本文整理汇总了C++中VSTRING::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ VSTRING::begin方法的具体用法?C++ VSTRING::begin怎么用?C++ VSTRING::begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VSTRING
的用法示例。
在下文中一共展示了VSTRING::begin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse_param
int parse_param(const VSTRING& param, ComType com_type, ParamInfo& ret_param)
{
VSTRING::const_iterator iter = param.begin();
for (; iter != param.end(); iter++)
{
int32_t cmd = -1;
int ret = TFS_SUCCESS;
bool has_value = false;
if (TFS_SUCCESS == get_cmd(const_cast<char*>((*iter).c_str()), cmd, has_value))
{
if (has_value)
{
if ((++iter) == param.end())
{
TBSYS_LOG(ERROR, "please input param value...");
return TFS_ERROR;
}
}
bool is_common = true;
switch (cmd)
{
case CMD_NUM:
ret = get_value((*iter).c_str(), ret_param.num_);
if(0 == ret_param.num_ || ret_param.num_ > (uint64_t)MAX_READ_NUM)
{
TBSYS_LOG(ERROR, "please input num in [1, %d]", MAX_READ_NUM);
return TFS_ERROR;
}
break;
case CMD_COUNT:
ret = get_value((*iter).c_str(), ret_param.count_);
break;
case CMD_INTERVAL:
ret = get_value((*iter).c_str(), ret_param.interval_);
break;
case CMD_REDIRECT:
ret = get_value((*iter).c_str(), ret_param.filename_);
break;
default:
is_common = false;
break;
}
if (is_common) continue;
if (com_type & SERVER_TYPE)
{
switch (cmd)
{
case CMD_SERVER_ID:
if (get_value((*iter).c_str(), ret_param.server_ip_port_) == TFS_SUCCESS)
{
if (ret_param.server_ip_port_.find_first_of(":") == string::npos)
{
ret = TFS_ERROR;
}
}
break;
case CMD_BLOCK_LIST:
ret_param.type_ = SERVER_TYPE_BLOCK_LIST;
break;
case CMD_BLOCK_WRITABLE:
ret_param.type_ = SERVER_TYPE_BLOCK_WRITABLE;
break;
case CMD_BLOCK_MASTER:
ret_param.type_ = SERVER_TYPE_BLOCK_MASTER;
break;
case CMD_NEED_FAMILY:
ret_param.need_family_ = true;
break;
default:
ret = CMD_UNKNOWN;
break;
}
}
if (com_type & BLOCK_TYPE)
{
uint64_t tmp = 0;
switch (cmd)
{
case CMD_BLOCK_ID:
if ((ret = get_value((*iter).c_str(), tmp)) == TFS_SUCCESS)
{
ret_param.block_id_ = tmp;
}
break;
case CMD_SERVER_LIST:
g_need_cmp ? (ret_param.type_ = BLOCK_CMP_SERVER) : (ret_param.type_ = BLOCK_TYPE_SERVER_LIST);
break;
case CMD_BLOCK_STATUS:
ret_param.type_ = BLOCK_TYPE_BLOCK_STATUS;
break;
case CMD_BLOCK_FULL:
ret_param.type_ |= BLOCK_TYPE_BLOCK_FULL;// additional condition
break;
case CMD_ALL:
ret_param.type_ = BLOCK_CMP_ALL_INFO;
break;
case CMD_PART:
ret_param.type_ = BLOCK_CMP_PART_INFO;
break;
default:
//.........这里部分代码省略.........
示例2: parse_param
int parse_param(const VSTRING& param, ComType com_type, ParamInfo& ret_param)
{
VSTRING::const_iterator iter = param.begin();
for (; iter != param.end(); iter++)
{
int32_t cmd = -1;
int ret = TFS_SUCCESS;
bool has_value = false;
if (TFS_SUCCESS == get_cmd(const_cast<char*>((*iter).c_str()), cmd, has_value))
{
if (has_value)
{
if ((++iter) == param.end())
{
TBSYS_LOG(ERROR, "please input param value...");
return TFS_ERROR;
}
}
bool is_common = true;
switch (cmd)
{
case CMD_NUM:
ret = get_value((*iter).c_str(), ret_param.num_);
break;
case CMD_COUNT:
ret = get_value((*iter).c_str(), ret_param.count_);
break;
case CMD_INTERVAL:
ret = get_value((*iter).c_str(), ret_param.interval_);
break;
case CMD_REDIRECT:
ret = get_value((*iter).c_str(), ret_param.filename_);
break;
default:
is_common = false;
break;
}
if (is_common) continue;
if (com_type & SERVER_TYPE)
{
switch (cmd)
{
case CMD_SERVER_ID:
if (get_value((*iter).c_str(), ret_param.server_ip_port_) == TFS_SUCCESS)
{
if (ret_param.server_ip_port_.find_first_of(":") == string::npos)
{
ret = TFS_ERROR;
}
}
break;
case CMD_BLOCK_LIST:
ret_param.type_ = SERVER_TYPE_BLOCK_LIST;
break;
case CMD_BLOCK_WRITABLE:
ret_param.type_ = SERVER_TYPE_BLOCK_WRITABLE;
break;
case CMD_BLOCK_MASTER:
ret_param.type_ = SERVER_TYPE_BLOCK_MASTER;
break;
default:
ret = CMD_UNKNOWN;
break;
}
}
if (com_type & BLOCK_TYPE)
{
int32_t tmp = -1;
switch (cmd)
{
case CMD_BLOCK_ID:
if ((ret = get_value((*iter).c_str(), tmp)) == TFS_SUCCESS)
{
ret_param.block_id_ = static_cast< uint32_t > (tmp);
}
break;
case CMD_SERVER_LIST:
g_need_cmp ? (ret_param.type_ = BLOCK_CMP_SERVER) : (ret_param.type_ = BLOCK_TYPE_SERVER_LIST);
break;
case CMD_ALL:
ret_param.type_ = BLOCK_CMP_ALL_INFO;
break;
case CMD_PART:
ret_param.type_ = BLOCK_CMP_PART_INFO;
break;
default:
ret = CMD_UNKNOWN;
break;
}
}
if (com_type & MACHINE_TYPE)
{
switch (cmd)
{
case CMD_ALL:
ret_param.type_ = MACHINE_TYPE_ALL;
break;
case CMD_PART:
ret_param.type_ = MACHINE_TYPE_PART;
break;
//.........这里部分代码省略.........