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


C++ BaseString::c_str方法代码示例

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


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

示例1: if

int
Match::eval(const Iter& iter)
{
  Uint32 val32;
  Uint64 val64;
  const char* valc;
  if (iter.get(m_key, &val32) == 0)
  {
    if(atoi(m_value.c_str()) != (int)val32)
      return 0;
  } 
  else if(iter.get(m_key, &val64) == 0)
  {
    if(strtoll(m_value.c_str(), (char **)NULL, 10) != (long long)val64)
      return 0;
  }
  else if(iter.get(m_key, &valc) == 0)
  {
    if(strcmp(m_value.c_str(), valc) != 0)
      return 0;
  }
  else
  {
    return 0;
  }
  return 1;
}
开发者ID:Abner-Sun,项目名称:mysql5.1-vx-pre1,代码行数:27,代码来源:ndb_config.cpp

示例2: strdup

char *
find_bin_path(const char * prefix, const char * exe)
{
  if (exe == 0)
    return 0;

  if (exe[0] == '/')
  {
    /**
     * Trust that path is correct...
     */
    return strdup(exe);
  }

  for (int i = 0; g_search_path[i] != 0; i++)
  {
    BaseString p;
    p.assfmt("%s/%s/%s", prefix, g_search_path[i], exe);
    if (File_class::exists(p.c_str()))
    {
      return strdup(p.c_str());
    }
  }
  return 0;
}
开发者ID:ForcerKing,项目名称:ShaoqunXu-mysql5.7,代码行数:25,代码来源:setup.cpp

示例3: master

bool
verifySlaveLoad(BaseString &table)
{
  //BaseString  sqlStm;
  BaseString  db;
  unsigned int masterCount = 0;
  unsigned int slaveCount  = 0;
 
  db.assign("TEST_DB");
  //sqlStm.assfmt("SELECT COUNT(*) FROM %s", table);

  //First thing to do is sync slave
  printf("Calling syncSlave\n");
  if(!syncSlaveWithMaster())
  {
    g_err << "Verify Load -> Syncing with slave failed" << endl;
    return false;
  }

  //Now that slave is sync we can verify load
  DbUtil master(db.c_str());

  //Login to Master
  if (!master.connect())
  {
    g_err << "Verify Load -> connect to master failed" << endl;
    return false;
  }

  if((masterCount = master.selectCountTable(table.c_str())) == 0 )
  {
    g_err << "Verify Load -> masterCount == ZERO!" << endl;
    return false;
  }
  
  //Create a DB Object for slave
  DbUtil slave(db.c_str(), ".1.slave");

  //Login to slave
  if (!slave.connect())
  {
    g_err << "Verify Load -> connect to master failed" << endl;
    return false;
  }

  if((slaveCount = slave.selectCountTable(table.c_str())) == 0 )
  {
    g_err << "Verify Load -> slaveCount == ZERO" << endl;
    return false;
  }
  
  if(slaveCount != masterCount)
  {
    g_err << "Verify Load -> Slave Count != Master Count "
          << endl;
    return false;
  }
  return true;
}
开发者ID:Cona19,项目名称:mysql5.6.24-improve,代码行数:59,代码来源:NdbRepStress.cpp

示例4: update_prefix

 int update_prefix()
 {
   if (!m_prefix.assfmt("%s%c%s%c", m_dbname.c_str(), table_name_separator,
                        m_schemaname.c_str(), table_name_separator))
   {
     return -1;
   }
   return 0;
 }
开发者ID:isleon,项目名称:Jaxer,代码行数:9,代码来源:NdbImpl.hpp

示例5: connect

  bool connect(const Properties& config,
               int num_retries = 60, int retry_delay_in_seconds = 1)
  {
    BaseString constr = connectstring(config);
    g_info << "Connecting to " << name() << " @ " << constr.c_str() << endl;

    return m_mgmd_client.connect(constr.c_str(),
                                 num_retries,
                                 retry_delay_in_seconds);
  }
开发者ID:,项目名称:,代码行数:10,代码来源:

示例6: strtol

bool
FileLogHandler::setMaxFiles(const BaseString &files) {
  char *end;
  long val = strtol(files.c_str(), &end, 0);
  if(files.c_str() == end || val < 1)
  {
    setErrorStr("Invalid maximum number of files");
    return false;
  }
  m_maxNoFiles = val;

  return true;
}
开发者ID:ForcerKing,项目名称:ShaoqunXu-mysql5.7,代码行数:13,代码来源:FileLogHandler.cpp

示例7: getenv

  NDBT_Workingdir(const char* dirname)
  {
    const char* tmp_path = m_temp.path();
    char* ndbt_tmp = getenv("NDBT_TMP_DIR");
    if (ndbt_tmp)
      tmp_path = ndbt_tmp;
    require(tmp_path);

    m_wd.assfmt("%s%s%s%d", tmp_path, DIR_SEPARATOR, dirname,
                (int)NdbProcess::getpid());
    if (access(m_wd.c_str(), F_OK) == 0)
      NdbDir::remove_recursive(m_wd.c_str());
    if (!NdbDir::create(m_wd.c_str()))
      abort();
  }
开发者ID:ForcerKing,项目名称:ShaoqunXu-mysql5.7,代码行数:15,代码来源:NDBT_Workingdir.hpp

示例8: it

  static bool
  create_directories(const char* path, Properties & config)
  {
    Properties::Iterator it(&config);

    while (const char* name = it.next())
    {
      BaseString dir;
      dir.assfmt("%s/%s", path, name);
      printf("Creating %s...\n", dir.c_str());
      if (!NdbDir::create(dir.c_str()))
        return false;
    }
    return true;
  }
开发者ID:ForcerKing,项目名称:ShaoqunXu-mysql5.7,代码行数:15,代码来源:ConfigFactory.hpp

示例9: connect_ndb_mgmd

/**
 * Given a SocketClient, creates a NdbMgmHandle, turns it into a transporter
 * and returns the socket.
 */
NDB_SOCKET_TYPE TransporterRegistry::connect_ndb_mgmd(SocketClient *sc)
{
  NdbMgmHandle h= ndb_mgm_create_handle();

  if ( h == NULL )
  {
    return NDB_INVALID_SOCKET;
  }

  /**
   * Set connectstring
   */
  {
    BaseString cs;
    cs.assfmt("%s:%u",sc->get_server_name(),sc->get_port());
    ndb_mgm_set_connectstring(h, cs.c_str());
  }

  if(ndb_mgm_connect(h, 0, 0, 0)<0)
  {
    ndb_mgm_destroy_handle(&h);
    return NDB_INVALID_SOCKET;
  }

  return connect_ndb_mgmd(&h);
}
开发者ID:A-eolus,项目名称:mysql,代码行数:30,代码来源:TransporterRegistry.cpp

示例10:

void
MgmApiSession::stopAll(Parser<MgmApiSession>::Context &,
                       Properties const &args) {
  int stopped[2] = {0,0};
  Uint32 abort;
  args.get("abort", &abort);

  BaseString stop;
  const char* tostop= "db";
  int ver=1;
  if (args.get("stop", stop))
  {
    tostop= stop.c_str();
    ver= 2;
  }

  int result= 0;
  if(strstr(tostop,"db"))
    result= m_mgmsrv.shutdownDB(&stopped[0], abort != 0);
  if(!result && strstr(tostop,"mgm"))
    result= m_mgmsrv.shutdownMGM(&stopped[1], abort!=0, &m_stopSelf);

  m_output->println("stop reply");
  if(result != 0)
    m_output->println("result: %s", get_error_text(result));
  else
    m_output->println("result: Ok");
  m_output->println("stopped: %d", stopped[0]+stopped[1]);
  if(ver >1)
    m_output->println("disconnect: %d", (m_stopSelf)?1:0);
  m_output->println("");
}
开发者ID:Abner-Sun,项目名称:mysql5.1-vx-pre1,代码行数:32,代码来源:Services.cpp

示例11:

int
SimpleCpcClient::undefine_process(Uint32 id, Properties& reply){
  const ParserRow_t stop_reply[] = {
    CPC_CMD("undefine process", NULL, ""),
    CPC_ARG("status", Int, Mandatory, ""),
    CPC_ARG("id", Int, Optional, ""),
    CPC_ARG("errormessage", String, Optional, ""),
    
    CPC_END()
  };

  Properties args;
  args.put("id", id);
  
  const Properties* ret = cpc_call("undefine process", args, stop_reply);
  if(ret == 0){
    reply.put("status", (Uint32)0);
    reply.put("errormessage", "unknown error");
    return -1;
  }

  Uint32 status = 0;
  ret->get("status", &status);
  reply.put("status", status);
  if(status != 0) {
    BaseString msg;
    ret->get("errormessage", msg);
    reply.put("errormessage", msg.c_str());
  }

  return status;
}
开发者ID:isleon,项目名称:Jaxer,代码行数:32,代码来源:CpcClient.cpp

示例12: insert

//*****************************************************************************
inline bool OpenFiles::insert(AsyncFile* file, Uint16 id){
  // Check if file has already been opened
  for (unsigned i = 0; i < m_files.size(); i++){
    if(m_files[i].m_file == NULL)
      continue;

    if(strcmp(m_files[i].m_file->theFileName.c_str(), 
	      file->theFileName.c_str()) == 0)
    {
      BaseString names;
      names.assfmt("open: >%s< existing: >%s<",
		   file->theFileName.c_str(),
		   m_files[i].m_file->theFileName.c_str());
      ERROR_SET(fatal, NDBD_EXIT_AFS_ALREADY_OPEN, names.c_str(),
		"OpenFiles::insert()");    
    }
  }
  
  // Insert the file into vector
  OpenFileItem openFile;
  openFile.m_id = id;
  openFile.m_file = file;
  m_files.push_back(openFile);
  
  return true;
}
开发者ID:ForcerKing,项目名称:ShaoqunXu-mysql5.7,代码行数:27,代码来源:OpenFiles.hpp

示例13: readFile

bool LocalConfig::readFile(const char * filename, bool &fopenError)
{
  char line[1024];
  
  fopenError = false;
  
  FILE * file = fopen(filename, "r");
  if(file == 0){
    BaseString::snprintf(line, sizeof(line),
	     "Unable to open local config file: %s", filename);
    setError(0, line);
    fopenError = true;
    return false;
  }

  BaseString theString;

  while(fgets(line, sizeof(line), file)){
    BaseString tmp(line);
    tmp.trim(" \t\n\r");
    if(tmp.length() > 0 && tmp.c_str()[0] != '#'){
      theString.append(tmp);
      break;
    }
  }
  while (fgets(line, sizeof(line), file)) {
    BaseString tmp(line);
    tmp.trim(" \t\n\r");
    if(tmp.length() > 0 && tmp.c_str()[0] != '#'){
      theString.append(";");
      theString.append(tmp);
    }
  }
  
  BaseString err;
  bool return_value = parseString(theString.c_str(), err);

  if (!return_value) {
    BaseString tmp;
    tmp.assfmt("Reading %s: %s", filename, err.c_str());
    setError(0, tmp.c_str());
  }

  fclose(file);
  return return_value;
}
开发者ID:A-eolus,项目名称:mysql,代码行数:46,代码来源:LocalConfig.cpp

示例14: open

bool
FileLogHandler::setFilename(const BaseString &filename) {
  close();
  if(m_pLogFile)
    delete m_pLogFile;
  m_pLogFile = new File_class(filename.c_str(), "a+");
  return open();
}
开发者ID:ForcerKing,项目名称:ShaoqunXu-mysql5.7,代码行数:8,代码来源:FileLogHandler.cpp

示例15:

int
startPostUpgradeChecks(NDBT_Context* ctx, NDBT_Step* step)
{
    /**
     * This will restart *self* in new version
     */

    BaseString extraArgs;
    if (ctx->getProperty("RestartNoDDL", Uint32(0)))
    {
        /* Ask post-upgrade steps not to perform DDL
         * (e.g. for 6.3->7.0 upgrade)
         */
        extraArgs.append(" --noddl ");
    }

    /**
     * mysql-getopt works so that passing "-n X -n Y" is ok
     *   and is interpreted as "-n Y"
     *
     * so we restart ourselves with testcase-name and "--post-upgrade" appended
     * e.g if testcase is "testUpgrade -n X"
     *     this will restart it as "testUpgrade -n X -n X--post-upgrade"
     */
    BaseString tc;
    tc.assfmt("-n %s--post-upgrade %s",
              ctx->getCase()->getName(),
              extraArgs.c_str());

    ndbout << "About to restart self with extra arg: " << tc.c_str() << endl;

    AtrtClient atrt;
    int process_id = atrt.getOwnProcessId();
    if (process_id == -1)
    {
        g_err << "Failed to find own process id" << endl;
        return NDBT_FAILED;
    }

    if (!atrt.changeVersion(process_id, tc.c_str()))
        return NDBT_FAILED;

    // Will not be reached...

    return NDBT_OK;
}
开发者ID:,项目名称:,代码行数:46,代码来源:


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