当前位置: 首页>>代码示例>>C++>>正文


C++ VSTRING::size方法代码示例

本文整理汇总了C++中VSTRING::size方法的典型用法代码示例。如果您正苦于以下问题:C++ VSTRING::size方法的具体用法?C++ VSTRING::size怎么用?C++ VSTRING::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VSTRING的用法示例。


在下文中一共展示了VSTRING::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:yinzhigang,项目名称:tfs,代码行数:28,代码来源:admintool.cpp

示例2: 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;
}
开发者ID:keoyeop,项目名称:tfs,代码行数:56,代码来源:tfstool.cpp

示例3: 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;
}
开发者ID:0huah0,项目名称:tfs,代码行数:50,代码来源:admintool.cpp

示例4: 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)";
	}
开发者ID:BRAHMS-SystemML,项目名称:brahms,代码行数:32,代码来源:loader.cpp

示例5: 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;
}
开发者ID:LinxiaHu,项目名称:tfs,代码行数:35,代码来源:tfstool.cpp

示例6: 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;
}
开发者ID:keoyeop,项目名称:tfs,代码行数:34,代码来源:tfstool.cpp

示例7: 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;
}
开发者ID:LinxiaHu,项目名称:tfs,代码行数:34,代码来源:tfstool.cpp

示例8: 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;
}
开发者ID:LinxiaHu,项目名称:tfs,代码行数:33,代码来源:tfstool.cpp

示例9: 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);
}
开发者ID:alimy,项目名称:tfs,代码行数:60,代码来源:adminservertool.cpp

示例10: 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;
}
开发者ID:LinxiaHu,项目名称:tfs,代码行数:59,代码来源:tfstool.cpp

示例11: 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);
}
开发者ID:LinxiaHu,项目名称:tfs,代码行数:9,代码来源:tfstool.cpp

示例12: cmd_ls_file_meta

int cmd_ls_file_meta(const VSTRING& param)
{
    int ret = TFS_SUCCESS;
    char appkey[257];
    if (!g_use_meta)
    {
        TBSYS_LOG(WARN, "sorry, this commond is for name meta!!!");
    }
    else
    {
        const char* file_path = expand_path(const_cast<string&>(param[0]));
        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)
        {
            app_id = strtoll(param[2].c_str(), NULL, 10);
        }
        if (size > 3)
        {
            uid = strtoll(param[3].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
        {
            FileMetaInfo file_info;
            ret = impl.ls_file(app_id, uid, file_path, file_info);
            if (TFS_SUCCESS == ret)
            {
                if (file_info.name_.size() > 0)
                    fprintf(stdout, "name:%s\n", file_info.name_.data());
                fprintf(stdout, "pid %"PRI64_PREFIX"d id %"PRI64_PREFIX
                        "d create_time %s modify_time %s size %"PRI64_PREFIX"d ver_no %d\n",
                        file_info.pid_, file_info.id_, Func::time_to_str(file_info.create_time_).c_str(),
                        Func::time_to_str(file_info.modify_time_).c_str(), file_info.size_, file_info.ver_no_);
            }
        }
    }
    return ret;
}
开发者ID:LinxiaHu,项目名称:tfs,代码行数:55,代码来源:tfstool.cpp

示例13: cmd_ls_dir_meta

int cmd_ls_dir_meta(const VSTRING& param)
{
    int ret = TFS_SUCCESS;
    const char* dir_path = expand_path(const_cast<string&>(param[0]));
    int size = param.size();
    char appkey[257];
    TBSYS_LOG(DEBUG, "size: %d", size);
    if (size > 1)
    {
        TBSYS_LOG(DEBUG, "appkey: %s", param[1].c_str());
        strncpy(appkey, param[1].c_str(), 256);
        appkey[256] = '\0';
    }
    else
    {
        strcpy(appkey, app_key);
    }

    if (size > 2)
    {
        app_id = strtoll(param[2].c_str(), NULL, 10);
    }
    if (size > 3)
    {
        uid = strtoll(param[3].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
    {
        std::vector<FileMetaInfo> meta_info;
        std::vector<FileMetaInfo>::const_iterator it;
        ret = impl.ls_dir(app_id, uid, dir_path, meta_info);
        if (TFS_SUCCESS == ret)
        {
            for (it = meta_info.begin(); it != meta_info.end(); it++)
            {
                if (it->name_.size() > 0)
                    fprintf(stdout, "name:%s\n", it->name_.data());
                fprintf(stdout, "pid %"PRI64_PREFIX"d id %"PRI64_PREFIX
                        "d create_time %d modify_time %d size %"PRI64_PREFIX"d ver_no %d\n",
                        it->pid_, it->id_, it->create_time_, it->modify_time_, it->size_, it->ver_no_);
            }
        }
    }
    return ret;
}
开发者ID:LinxiaHu,项目名称:tfs,代码行数:53,代码来源:tfstool.cpp

示例14: cmd_set_bpr

int cmd_set_bpr(const VSTRING& param)
{
  int32_t size = param.size();
  int32_t iret = 2 != size ? EXIT_PARAMETER_ERROR : TFS_SUCCESS;
  if (TFS_SUCCESS != iret)
  {
    fprintf(stderr, "parameter size: %d is invalid, must be 2\n", size);
  }
  else
  {
    int32_t value3 = atoi(param[0].c_str());
    int32_t value4;
    iret = (value3 > 1 || value3 < 0 || param[1].length() > 6 || ((value4 = atoi(param[1].c_str())) != 0 && 1 == value3)) ? EXIT_PARAMETER_ERROR : TFS_SUCCESS;
    if (TFS_SUCCESS != iret)
    {
      fprintf(stderr, "parameter is invalid, value1: (0|1), value2.length should <= 6. but input value1: %d, value2: %s\n", value3, param[1].c_str());
    }
    else
    {
      ClientCmdMessage req_cc_msg;
      req_cc_msg.set_cmd(CLIENT_CMD_SET_BALANCE_PERCENT);
      req_cc_msg.set_value3(value3);
      req_cc_msg.set_value4(value4);

      tbnet::Packet* ret_message = NULL;
      NewClient* client = NewClientManager::get_instance().create_client();
      iret = send_msg_to_server(g_tfs_client->get_server_id(), client, &req_cc_msg, ret_message);
      string ret_value = "successful";
      if (TFS_SUCCESS != iret)
      {
        ret_value = "setbpr failed";
      }
      else
      {
        if (ret_message->getPCode() == STATUS_MESSAGE)
        {
          StatusMessage* s_msg = dynamic_cast<StatusMessage*> (ret_message);
          iret = s_msg->get_status();
          if (iret != STATUS_MESSAGE_OK)
          {
            ret_value = s_msg->get_error();
          }
        }
      }
      ToolUtil::print_info(iret, "%s", ret_value.c_str());

      NewClientManager::get_instance().destroy_client(client);
    }
  }
  return iret;
}
开发者ID:yinzhigang,项目名称:tfs,代码行数:51,代码来源:admintool.cpp

示例15: put_file_raw_ex

int put_file_raw_ex(const VSTRING& param, const bool is_large)
{
    int32_t size = param.size();
    const char* local_file = expand_path(const_cast<string&>(param[0]));
    char* tfs_name = NULL;
    const char* suffix = NULL;
    char appkey[257];
    //int32_t flag = T_DEFAULT;
    int ret = TFS_SUCCESS;
    char ret_tfs_name[TFS_FILE_LEN];
    ret_tfs_name[0] = '\0';

    if (size > 1)
    {
        suffix = canonical_param(param[1]);
    }

    if (size > 2)
    {
        //TBSYS_LOG(DEBUG, "app_key: %s", param[2].c_str());
        strncpy(appkey, canonical_param(param[2]), 256);
        appkey[256] = '\0';
    }
    else
    {
        // default app_key = "tfscom"
        strcpy(appkey, app_key);
    }

    //login with rc and app_key
    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.save_file(local_file, ret_tfs_name, TFS_FILE_LEN, suffix, is_large) < 0 ? TFS_ERROR : TFS_SUCCESS;
    }

    //printf("tfs_name: %s, ret_tfs_name: %s\n", tfs_name, ret_tfs_name);

    ToolUtil::print_info(ret, "put %s => %s", local_file, tfs_name != NULL ? FSName(tfs_name, suffix).get_name() : ret_tfs_name);
    return ret;
}
开发者ID:LinxiaHu,项目名称:tfs,代码行数:47,代码来源:tfstool.cpp


注:本文中的VSTRING::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。