本文整理汇总了C++中BaseString::split方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseString::split方法的具体用法?C++ BaseString::split怎么用?C++ BaseString::split使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseString
的用法示例。
在下文中一共展示了BaseString::split方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
add_hosts(Vector<SimpleCpcClient*> & hosts, BaseString list){
Vector<BaseString> split;
list.split(split);
for(size_t i = 0; i<split.size(); i++){
add_host(hosts, split[i]);
}
}
示例2: type
bool
Logger::addHandler(const BaseString &logstring, int *err, int len, char* errStr) {
size_t i;
Vector<BaseString> logdest;
Vector<LogHandler *>loghandlers;
DBUG_ENTER("Logger::addHandler");
logstring.split(logdest, ";");
for(i = 0; i < logdest.size(); i++) {
DBUG_PRINT("info",("adding: %s",logdest[i].c_str()));
Vector<BaseString> v_type_args;
logdest[i].split(v_type_args, ":", 2);
BaseString type(v_type_args[0]);
BaseString params;
if(v_type_args.size() >= 2)
params = v_type_args[1];
LogHandler *handler = NULL;
#ifndef NDB_WIN32
if(type == "SYSLOG")
{
handler = new SysLogHandler();
} else
#endif
if(type == "FILE")
handler = new FileLogHandler();
else if(type == "CONSOLE")
handler = new ConsoleLogHandler();
if(handler == NULL)
{
snprintf(errStr,len,"Could not create log destination: %s",
logdest[i].c_str());
DBUG_RETURN(false);
}
if(!handler->parseParams(params))
{
*err= handler->getErrorCode();
if(handler->getErrorStr())
strncpy(errStr, handler->getErrorStr(), len);
DBUG_RETURN(false);
}
loghandlers.push_back(handler);
}
for(i = 0; i < loghandlers.size(); i++)
addHandler(loghandlers[i]);
DBUG_RETURN(true); /* @todo handle errors */
}
示例3: atoi
void
add_host(Vector<SimpleCpcClient*> & hosts, BaseString tmp){
Vector<BaseString> split;
tmp.split(split, ":");
short port = g_settings.m_port;
if(split.size() > 1)
port = atoi(split[1].c_str());
hosts.push_back(new SimpleCpcClient(split[0].c_str(), port));
}
示例4: atoi
static
int
set_ulimit(const BaseString & pair){
#ifdef HAVE_GETRLIMIT
errno = 0;
Vector<BaseString> list;
pair.split(list, ":");
if(list.size() != 2){
logger.error("Unable to process ulimit: split >%s< list.size()=%d",
pair.c_str(), list.size());
return -1;
}
int res;
rlim_t value = RLIM_INFINITY;
if(!(list[1].trim() == "unlimited")){
value = atoi(list[1].c_str());
}
struct rlimit rlp;
#define _RLIMIT_FIX(x) { res = getrlimit(x,&rlp); if(!res){ rlp.rlim_cur = value; res = setrlimit(x, &rlp); }}
if(list[0].trim() == "c"){
_RLIMIT_FIX(RLIMIT_CORE);
} else if(list[0] == "d"){
_RLIMIT_FIX(RLIMIT_DATA);
} else if(list[0] == "f"){
_RLIMIT_FIX(RLIMIT_FSIZE);
} else if(list[0] == "n"){
_RLIMIT_FIX(RLIMIT_NOFILE);
} else if(list[0] == "s"){
_RLIMIT_FIX(RLIMIT_STACK);
} else if(list[0] == "t"){
_RLIMIT_FIX(RLIMIT_CPU);
} else {
res= -11;
errno = EINVAL;
}
if(res){
logger.error("Unable to process ulimit: %s res=%d error=%d(%s)",
pair.c_str(), res, errno, strerror(errno));
return -1;
}
#endif
return 0;
}
示例5: BaseString
BaseString
set_env_var(const BaseString& existing,
const BaseString& name,
const BaseString& value)
{
/* Split existing on space
* (may have issues with env vars with spaces)
* Split assignments on =
* Where name == name, output new value
*/
BaseString newEnv;
Vector<BaseString> assignments;
int assignmentCount = existing.split(assignments, BaseString(" "));
for (int i=0; i < assignmentCount; i++)
{
Vector<BaseString> terms;
int termCount = assignments[i].split(terms, BaseString("="));
if (termCount)
{
if (strcmp(name.c_str(), terms[0].c_str()) == 0)
{
/* Found element */
newEnv.append(name);
newEnv.append('=');
newEnv.append(value);
}
else
{
newEnv.append(assignments[i]);
}
}
newEnv.append(' ');
}
return newEnv;
}
示例6: call
bool call(const char* cmd, const Properties& args,
const char* cmd_reply, Properties& reply,
const char* bulk = NULL,
bool name_value_pairs = true){
if (!is_connected()){
error("call: not connected");
return false;
}
SocketOutputStream out(socket());
if (out.println(cmd)){
error("call: println failed at line %d", __LINE__);
return false;
}
Properties::Iterator iter(&args);
const char *name;
while((name = iter.next()) != NULL) {
PropertiesType t;
Uint32 val_i;
Uint64 val_64;
BaseString val_s;
args.getTypeOf(name, &t);
switch(t) {
case PropertiesType_Uint32:
args.get(name, &val_i);
if (out.println("%s: %d", name, val_i)){
error("call: println failed at line %d", __LINE__);
return false;
}
break;
case PropertiesType_Uint64:
args.get(name, &val_64);
if (out.println("%s: %Ld", name, val_64)){
error("call: println failed at line %d", __LINE__);
return false;
}
break;
case PropertiesType_char:
args.get(name, val_s);
if (out.println("%s: %s", name, val_s.c_str())){
error("call: println failed at line %d", __LINE__);
return false;
}
break;
default:
case PropertiesType_Properties:
/* Illegal */
abort();
break;
}
}
// Emtpy line terminates argument list
if (out.print("\n")){
error("call: print('\n') failed at line %d", __LINE__);
return false;
}
// Send any bulk data
if (bulk && out.println(bulk)){
error("call: print('<bulk>') failed at line %d", __LINE__);
return false;
}
BaseString buf;
SocketInputStream2 in(socket());
if (cmd_reply)
{
// Read the reply header and compare against "cmd_reply"
if (!in.gets(buf)){
error("call: could not read reply command");
return false;
}
// 1. Check correct reply header
if (buf != cmd_reply){
error("call: unexpected reply command, expected: '%s', got '%s'",
cmd_reply, buf.c_str());
return false;
}
}
// 2. Read lines until empty line
int line = 1;
while(in.gets(buf)){
// empty line -> end of reply
if (buf == "")
return true;
if (name_value_pairs)
{
// 3a. Read colon separated name value pair, split
// the name value pair on first ':'
Vector<BaseString> name_value_pair;
if (buf.split(name_value_pair, ":", 2) != 2){
//.........这里部分代码省略.........