本文整理汇总了C++中StrVec::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ StrVec::empty方法的具体用法?C++ StrVec::empty怎么用?C++ StrVec::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StrVec
的用法示例。
在下文中一共展示了StrVec::empty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HMGet
StrMap RedisClient::HMGet(const std::string& key, const StrVec& vec){
StrMap map;
if( key.empty() || vec.empty()) {
return map;
}
std::stringstream sm;
sm << "HMGET " << key;
for(auto & i : vec) {
sm << " " << i;
}
redisReply *redis_reply = RedoCommand(sm.str(),REDIS_REPLY_ARRAY);
if( redis_reply ) {
for (size_t i=0; i<redis_reply->elements; ++i) {
auto reply = redis_reply->element[i];
if (reply->type == REDIS_REPLY_STRING) {
map[vec[i]] = redis_reply->element[i]->str;
}
else if (reply->type == REDIS_REPLY_NIL) {
LOGW("HMGet element" << vec[i] <<" is REDIS_REPLY_NIL! command=");
map[vec[i]] ="";
}
}
}
freeReplyObject_Safe(redis_reply);
return map;
}
示例2: update
void Console::update()
{
StrVec tmpLog = Logger::getLog();
Logger::clearLog();
if(!tmpLog.empty() && tmpLog.at(0) != "")
{
for(unsigned int i = 0; i < tmpLog.size(); i++)
{
while(tmpLog.at(i).find("\n") != std::string::npos)
tmpLog.at(i).erase(tmpLog.at(i).find("\n"), 1);
addString(tmpLog.at(i));
}
}
}
示例3: ifs
Option(int argc, const char *const argv[])
{
cybozu::Option opt;
std::string charSetFile;
std::string dicFile;
bool debug;
opt.appendOpt(&charSetFile, "", "cf", "char set file");
opt.appendOpt(&threadNum, 4, "t", "thread num");
opt.appendOpt(&dicFile, "", "d", "dictionary file");
opt.appendOpt(&passLen, 0, "l", "length of pass");
opt.appendBoolOpt(&debug, "v", "verbose message");
opt.appendHelp("h");
opt.appendParam(&encFile, "encrypted file");
if (!opt.parse(argc, argv)) {
opt.usage();
exit(1);
}
if (debug) ms::setDebug(1);
if (charSetFile.empty()) {
charSet = "abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789-_";
} else {
std::ifstream ifs(charSetFile.c_str(), std::ios::binary);
if (!std::getline(ifs, charSet)) {
fprintf(stderr, "can't read char set file [%s]\n", charSetFile.c_str());
exit(1);
}
trim(charSet);
}
if (!dicFile.empty()) {
std::ifstream ifs(dicFile.c_str(), std::ios::binary);
std::string line;
while (std::getline(ifs, line)) {
trim(line);
toUtf8(line);
passSet.push_back(line);
}
if (passSet.empty()) {
fprintf(stderr, "can't read dicFile [%s]\n", dicFile.c_str());
exit(1);
}
std::sort(passSet.begin(), passSet.end(), &lessByLength);
}
if (ms::isDebug()) {
opt.put();
}
}
示例4: HDel
void RedisClient::HDel(const std::string & hask_name, const StrVec & keys){
if( keys.empty() ) {
LOGE("HDEL warning : keys is empty vector");
return ;
}
std::stringstream sm;
sm << "HDEL "<< hask_name ;
bool avaliad_param = false ;
for( const auto & key : keys ) {
if(key.empty())
continue;
sm<<" "<<key;
avaliad_param = true ;
}
if( !avaliad_param ) {
LOGE("HDEL warning :all key are empty string .keys has " <<keys.size());
return ;
}
redisReply *redis_reply = RedoCommand(sm.str(),REDIS_REPLY_INTEGER);
freeReplyObject_Safe(redis_reply);
}
示例5: SAdd
int RedisClient::SAdd(const std::string& key, const StrVec& value){
int result = 0;
if(key.empty() || value.empty())
return result;
std::stringstream sm;
sm << "SADD " << key ;
bool valid_param = false;
for(auto & a : value) {
if(a.empty())
continue;
valid_param = true;
sm<<" "<<a;
}
if(!valid_param){
LOGW("SAdd got zero valid param for set : "<<key);
return 0;
}
redisReply *redis_reply = RedoCommand(sm.str(),REDIS_REPLY_INTEGER);
if ( redis_reply ) {
result = redis_reply->integer;
}
freeReplyObject_Safe(redis_reply);
return result;
}