本文整理汇总了C++中VSTRING类的典型用法代码示例。如果您正苦于以下问题:C++ VSTRING类的具体用法?C++ VSTRING怎么用?C++ VSTRING使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VSTRING类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void Loader::init(const brahms::Environment& environment)
{
// The bindings are accessed via the INSTALL_PREFIX.
#if STANDALONE_INSTALL
installPrefix = brahms::os::getenv("SYSTEMML_INSTALL_PATH", false);
if (installPrefix.empty()) {
installPrefix = INSTALL_PREFIX;
installPrefix += brahms::os::PATH_SEPARATOR;
}
#else
installPrefix = INSTALL_PREFIX;
installPrefix += brahms::os::PATH_SEPARATOR;
#endif
// get path from Execution Parameters
string sNamespaceRoots = environment.gets("NamespaceRoots");
// break out separate paths
VSTRING roots = brahms::text::explode(brahms::os::ENV_SEPARATOR, sNamespaceRoots);
// trim any whitespace from them
for (UINT32 i=0; i<roots.size(); i++)
{
string root = roots[i];
brahms::text::trim(root);
if (root.length())
namespaceRoots.push_back(root);
}
// check we got some
if (!namespaceRoots.size())
ferr << E_EXECUTION_PARAMETERS << "malformed execution parameter NamespaceRoots (no entries)";
}
示例2: cmd_remove_family
int cmd_remove_family(const VSTRING& param)
{
int32_t flag = DELETE_FAMILY_IN_STORE | DELETE_FAMILY_IN_MEMORY;
if (param.size() < 1)
{
fprintf(stderr, "invalid parameter, param.empty\n");
return TFS_ERROR;
}
int64_t family_id = strtoull(param[0].c_str(), NULL, 10);
if (family_id <= 0)
{
fprintf(stderr, "invalid familyid %s\n", param[0].c_str());
return TFS_ERROR;
}
if (param.size() == 2)
flag = atoi(param[1].c_str());
ClientCmdMessage req_cc_msg;
req_cc_msg.set_cmd(CLIENT_CMD_DELETE_FAMILY);
req_cc_msg.set_value3(family_id);
req_cc_msg.set_value4(flag);
int32_t status = TFS_ERROR;
send_msg_to_server(g_tfs_client->get_server_id(), &req_cc_msg, status);
ToolUtil::print_info(status, "remove family %s, ret: %d", param[0].c_str(), status);
return status;
}
示例3: do_cmd
int32_t do_cmd(char* key)
{
key = strip_line(key);
if (!key[0])
{
return TFS_SUCCESS;
}
#ifdef _WITH_READ_LINE
// not blank line, add to history
add_history(key);
#endif
char* token = strchr(key, ' ');
if (token != NULL)
{
*token = '\0';
}
STR_FUNC_MAP_ITER it = g_cmd_map.find(Func::str_to_lower(key));
if (it == g_cmd_map.end())
{
fprintf(stderr, "unknown command. \n");
return TFS_ERROR;
}
// ok this is current command
g_cur_cmd = key;
if (token != NULL)
{
token++;
key = token;
}
else
{
key = NULL;
}
VSTRING param;
param.clear();
while ((token = strsep(&key, " ")) != NULL)
{
if ('\0' == token[0])
{
continue;
}
param.push_back(token);
}
// check param count
int32_t param_cnt = param.size();
if (param_cnt < it->second.min_param_cnt_ || param_cnt > it->second.max_param_cnt_)
{
fprintf(stderr, "%s\t\t%s\n\n", it->second.syntax_, it->second.info_);
return TFS_ERROR;
}
return it->second.func_(param);
}
示例4: cmd_ls
int cmd_ls(const VSTRING& param)
{
int32_t size = param.size();
const char* path = (1 == size) ? param.at(0).c_str() : ".";
char sys_cmd[MAX_CMD_SIZE];
// just use system tool ls, maybe DIY
snprintf(sys_cmd, MAX_CMD_SIZE, "ls -FCl %s", path);
return system(sys_cmd);
}
示例5: parse_cmd
//get the command
int parse_cmd(char* key, VSTRING & param)
{
int cmd = CMD_NOP;
char* token;
//remove the space
while (*key == ' ')
key++;
token = key + strlen(key);
while (*(token - 1) == ' ' || *(token - 1) == '\n' || *(token - 1) == '\r')
token--;
*token = '\0';
if (key[0] == '\0')
{
return cmd;
}
#ifdef _WITH_READ_LINE
// not blank line, add to history
add_history(key);
#endif
token = strchr(key, ' ');
if (token != NULL)
{
*token = '\0';
}
//find the command
STR_INT_MAP_ITER it = cmd_map.find(Func::str_to_lower(key));
if (it == cmd_map.end())
{
return CMD_UNKNOWN;
}
else
{
cmd = it->second;
}
if (token != NULL)
{
token++;
key = token;
}
else
{
key = NULL;
}
//get the parameters
param.clear();
while ((token = strsep(&key, " ")) != NULL)
{
if (token[0] == '\0')
{
continue;
}
param.push_back(token);
}
return cmd;
}
示例6: cmd_list_file_info
int cmd_list_file_info(const VSTRING& param)
{
uint64_t block_id = 0;
uint64_t attach_block_id = 0;
uint64_t server_id = 0;
int32_t show_detail = 0;
int ret = TFS_ERROR;
if ((block_id = strtoull(param[0].c_str(), (char**)NULL, 10)) <= 0)
{
fprintf(stderr, "invalid blockid: %"PRI64_PREFIX"u\n", block_id);
return ret;
}
if (param.size() > 3)
{
server_id = Func::get_host_ip(param[3].c_str());
}
else
{
VUINT64 ds_list;
ret = ToolUtil::get_block_ds_list_v2(g_tfs_client->get_server_id(), block_id, ds_list);
if (ret != TFS_SUCCESS)
{
fprintf(stderr, "get ds list failed. block_id: %"PRI64_PREFIX"u, ret: %d\n", block_id, ret);
return ret;
}
server_id = ds_list[0];
}
if (0 != server_id)
{
if (param.size() > 2 && 0 == strcmp(param[2].c_str(), "detail"))
{
show_detail = 1;
}
if (param.size() > 1)
{
attach_block_id = strtoull(param[1].c_str(), (char**)NULL, 10);
}
else
{
attach_block_id = block_id;
}
DsTask ds_task(server_id, g_tfs_client->get_cluster_id());
ds_task.block_id_ = block_id;
ds_task.attach_block_id_ = attach_block_id;
ds_task.mode_ = show_detail;
ret = DsLib::list_file(ds_task);
}
return ret;
}
示例7: cmd_remove_block
int cmd_remove_block(const VSTRING& param)
{
uint32_t flag = 0;
uint32_t block_id = atoi(param[0].c_str());
uint64_t server_id = 0;
if (param.empty())
{
fprintf(stderr, "invalid parameter, param.empty\n");
return TFS_ERROR;
}
if (param.size() == 1)
{
flag = 1;
}
else if (param.size() == 2 )
{
if (param[1].length() == 1)
flag = atoi(param[1].c_str());
else
{
server_id = Func::get_host_ip(param[1].c_str());
if (0 == server_id)
{
fprintf(stderr, "invalid addr %s\n", param[1].c_str());
return TFS_ERROR;
}
}
}
if (0 == block_id)
{
fprintf(stderr, "invalid blockid %s\n", param[0].c_str());
return TFS_ERROR;
}
ClientCmdMessage req_cc_msg;
req_cc_msg.set_cmd(CLIENT_CMD_EXPBLK);
req_cc_msg.set_value1(server_id);
req_cc_msg.set_value3(block_id);
req_cc_msg.set_value4(flag);
int32_t status = TFS_ERROR;
send_msg_to_server(g_tfs_client->get_server_id(), &req_cc_msg, status);
if (param.size() == 1)
ToolUtil::print_info(status, "removeblock %s", param[0].c_str());
else if (param.size() == 2)
ToolUtil::print_info(status, "removeblock %s %s", param[0].c_str(), param[1].c_str());
return status;
}
示例8: cmd_check_all
int cmd_check_all(const VSTRING&)
{
print_head();
// for uniformity, a little time waste
MSTR_VSTR::iterator it;
VSTRING param;
for (it = g_server_map.begin(); it != g_server_map.end(); it++)
{
param.clear();
param.push_back(it->first);
do_monitor(param, ADMIN_CMD_CHECK);
}
return TFS_SUCCESS;
}
示例9: cmd_rm_dir_meta
int cmd_rm_dir_meta(const VSTRING& param)
{
int ret = TFS_SUCCESS;
const char* dir_path = expand_path(const_cast<string&>(param[0]));
char appkey[257];
int size = param.size();
if (size > 1)
{
strncpy(appkey, param[1].c_str(), 256);
appkey[256] = '\0';
}
else
{
strcpy(appkey, app_key);
}
if (size > 2)
{
uid = strtoll(param[2].c_str(), NULL, 10);
}
RcClientImpl impl;
ret = impl.initialize(rc_addr, appkey, app_ip);
if (TFS_SUCCESS != ret)
{
TBSYS_LOG(DEBUG, "meta client init failed, ret: %d", ret);
}
else
{
ret = impl.rm_dir(uid, dir_path);
}
return ret;
}
示例10: readFilelist
int TestCommonUtils::readFilelist(char *filelist, VUINT32& crcSet, VSTRING& filenameSet)
{
FILE *fp = NULL;
if((fp = fopen(filelist,"r")) == NULL)
{
TBSYS_LOG(DEBUG,"open file_list failed.");
return -1;
}
uint32_t crc = 0;
char filename[64];
while(fgets(filename,sizeof(filename),fp))
{
if(filename[strlen(filename)-1] == '\n')
{
filename[strlen(filename)-1] = '\0';
} else {
filename[strlen(filename)] = '\0';
}
#if 0
TBSYS_LOG(ERROR,"line = %d, filename = %s, filelist = %s!!!",__LINE__,filename, filelist);
#endif
char *p = strchr(filename,' ');
*p++ = '\0';
sscanf(p,"%u",&crc);
filenameSet.push_back(filename);
crcSet.push_back(crc);
}
return 0;
}
示例11: cmd_get_file_raw
int cmd_get_file_raw(const VSTRING& param)
{
const char* tfs_name = canonical_param(param[0]);
const char* local_file = expand_path(const_cast<string&>(param[1]));
char appkey[257];
int size = param.size();
if (size > 2)
{
TBSYS_LOG(DEBUG, "appkey: %s", param[2].c_str());
strncpy(appkey, param[2].c_str(), 256);
appkey[256] = '\0';
}
else
{
strcpy(appkey, app_key);
}
int ret = TFS_SUCCESS;
RcClientImpl impl;
ret = impl.initialize(rc_addr, appkey, app_ip);
if (TFS_SUCCESS != ret)
{
TBSYS_LOG(DEBUG, "rc client init failed, ret: %d", ret);
}
else
{
ret = impl.fetch_file(local_file, tfs_name, NULL);
}
ToolUtil::print_info(ret, "fetch %s => %s", tfs_name, local_file);
return ret;
}
示例12: cmd_del_object
int cmd_del_object(const VSTRING& param)
{
const char* bucket_name = param[0].c_str();
const char* object_name = param[1].c_str();
char appkey[257];
int size = param.size();
if (size > 2)
{
strncpy(appkey, param[2].c_str(), 256);
appkey[256] = '\0';
}
else
{
strcpy(appkey, app_key);
}
UserInfo user_info;
RcClientImpl impl;
impl.set_kv_rs_addr(krs_addr);
int ret = impl.initialize(rc_addr, appkey, app_ip);
if (TFS_SUCCESS != ret)
{
TBSYS_LOG(DEBUG, "rc client init failed, ret: %d", ret);
}
else
{
ret = impl.del_object(bucket_name, object_name, user_info);
}
ToolUtil::print_info(ret, "del bucket: %s, object: %s", bucket_name, object_name);
return ret;
}
示例13: cmd_stat_blk
int cmd_stat_blk(const VSTRING& param)
{
int ret = TFS_ERROR;
uint64_t server_id = 0;
uint32_t block_id = 0;
if ((block_id = atoi(param[0].c_str())) <= 0)
{
fprintf(stderr, "invalid blockid: %u\n", block_id);
}
if (param.size() > 2)
{
server_id = Func::get_host_ip(param[1].c_str());
}
else
{
VUINT64 ds_list;
ret = ToolUtil::get_block_ds_list(g_tfs_client->get_server_id(), block_id, ds_list);
if (ret != TFS_SUCCESS)
{
fprintf(stderr, "get ds list failed. block_id: %u, ret: %d\n", block_id, ret);
return ret;
}
server_id = ds_list[0];
}
DsTask ds_task(server_id, g_tfs_client->get_cluster_id());
ds_task.block_id_ = block_id;
ret = DsLib::get_block_info(ds_task);
return ret;
}
示例14: cmd_stat_file_meta
int cmd_stat_file_meta(const VSTRING& param)
{
int ret = TFS_SUCCESS;
const char* file_path = expand_path(const_cast<string&>(param[0]));
char rs_addr[257];
FragInfo frag_info_;
int size = param.size();
if (size > 1)
{
strncpy(rs_addr, param[1].c_str(), 256);
rs_addr[256] = '\0';
printf("rs_addr: %s\n", rs_addr);
}
if (size > 2)
{
app_id = strtoll(param[2].c_str(), NULL, 10);
}
if (size > 3)
{
uid = strtoll(param[3].c_str(), NULL, 10);
}
NameMetaClientImpl impl;
ret = impl.initialize(rs_addr);
if (TFS_SUCCESS != ret)
{
TBSYS_LOG(DEBUG, "meta client login rs_addr: %s fail, ret: %d", rs_addr, ret);
}
else
{
ret = impl.read_frag_info(app_id, uid, file_path, frag_info_);
}
//stat the detail
ToolUtil::print_info(ret, "stat %s", file_path);
if (TFS_SUCCESS == ret)
{
int32_t cluster_id = frag_info_.cluster_id_;
std::vector<FragMeta> vFragMeta = frag_info_.v_frag_meta_;
std::vector<FragMeta>::iterator iter;
fprintf(stdout, " FILE_NAME\t BLOCK_ID\t FILE_ID\t OFFSET\t SIZE\n");
for (iter = vFragMeta.begin(); iter < vFragMeta.end(); iter++)
{
FSName fsname(iter->block_id_, iter->file_id_, cluster_id);
fprintf(stdout,
" %s\t"
" %u\t"
" %" PRI64_PREFIX "u\t"
" %"PRI64_PREFIX"d\t"
" %d\n",
fsname.get_name(), iter->block_id_, iter->file_id_, iter->offset_, iter->size_);
}
}
return ret;
}
示例15: sprintf
int TestCommonUtils::getFilelist(int partNo, int partSize, VUINT32& crcSet,
VUINT32& crcSetPerThread, VSTRING& filenameSet, VSTRING& filenameSetPerThread)
{
// total size less than thread count
if (partSize == 0)
{
partSize = 1;
}
int offset = partNo * partSize;
int end = (offset + partSize) > (int)crcSet.size()? crcSet.size():(offset + partSize);
for (; offset < end; offset++)
{
crcSetPerThread.push_back(crcSet[offset]);
filenameSetPerThread.push_back( filenameSet.at(offset).c_str() );
}
// the last thread eat the left
if (partNo == (TestGFactory::_threadCount - 1) )
{
for (; offset < (int)crcSet.size(); offset++)
{
crcSetPerThread.push_back(crcSet[offset]);
filenameSetPerThread.push_back( filenameSet.at(offset).c_str() );
}
}
//debug
/*
char fileListPerThread[20] = {0};
sprintf(fileListPerThread, "./read_file_list_%d.txt", partNo);
FILE *fp = fopen(fileListPerThread, "w");
VSTRING::iterator it = filenameSetPerThread.begin();
for (; it != filenameSetPerThread.end(); it++)
{
fprintf(fp, "%s\n", it->c_str());
}
fflush(fp);
fclose(fp);
*/
return 0;
}