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


C++ acl::string类代码示例

本文整理汇总了C++中acl::string的典型用法代码示例。如果您正苦于以下问题:C++ string类的具体用法?C++ string怎么用?C++ string使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_zrangebylex

static bool test_zrangebylex(acl::redis_zset& redis, int n)
{
	acl::string key;
	const char* min = "[aaa", *max = "(g";
	std::vector<acl::string> result;

	for (int i = 0; i < n; i++)
	{
		key.format("%s_%d", __keypre.c_str(), i);
		redis.clear();
		int ret = redis.zrangebylex(key.c_str(), min, max, &result);
		if (ret < 0)
		{
			printf("zrangebylex error(%s), key: %s\r\n",
				redis.result_error(), key.c_str());
			return false;
		}
		if (i >= 10)
		{
			result.clear();
			continue;
		}

		std::vector<acl::string>::const_iterator cit;
		for (cit = result.begin(); cit != result.end(); ++cit)
		{
			if (cit != result.begin())
				printf(", ");
			printf("%s", (*cit).c_str());
		}
		printf("\r\n");
	}

	return true;
}
开发者ID:39608106,项目名称:acl,代码行数:35,代码来源:redis_zset.cpp

示例2: test_zincrby

static bool test_zincrby(acl::redis_zset& redis, int n)
{
	acl::string key;
	double inc = 2.5, result;
	acl::string member;

	for (int i = 0; i < n; i++)
	{
		key.format("%s_%d", __keypre.c_str(), i);

		for (int j = 0; j < 1000; j++)
		{
			member.format("member_%d", j);
			redis.clear();
			if (redis.zincrby(key.c_str(), inc, member.c_str(),
				&result) == false)
			{
				printf("zincrby error, key: %s\r\n", key.c_str());
				return false;
			}
			else if (j < 10 && i * j < 100)
				printf("zincrby ok key: %s, result: %.2f\r\n",
					key.c_str(), result);
		}
	}

	return true;
}
开发者ID:39608106,项目名称:acl,代码行数:28,代码来源:redis_zset.cpp

示例3: test_zscore

static bool test_zscore(acl::redis_zset& redis, int n)
{
	acl::string key;
	acl::string member;
	bool ret;
	double result;

	for (int i = 0; i < n; i++)
	{
		key.format("%s_%d", __keypre.c_str(), i);

		for (int j = 0; j < 1000; j++)
		{
			member.format("member_%d", j);
			redis.clear();
			ret = redis.zscore(key.c_str(), member.c_str(),
				result);
			if (ret == false)
			{
				printf("zscore error, key: %s\r\n",
					key.c_str());
				return false;
			}
			else if (j > 0 && j * i < 100)
				printf("zscore ok, key: %s, member:%s, "
					"score: %.2f\r\n", key.c_str(),
					member.c_str(), result);
		}
	}

	return true;
}
开发者ID:39608106,项目名称:acl,代码行数:32,代码来源:redis_zset.cpp

示例4: test_zadd

static bool test_zadd(acl::redis_zset& redis, int n)
{
	acl::string key;
	std::map<acl::string, double> members;
	acl::string member;

	for (int i = 0; i < n; i++)
	{
		key.format("%s_%d", __keypre.c_str(), i);

		for (int j = 0; j < 1000; j++)
		{
			member.format("member_%d", j);
			members[member] = j;
		}

		redis.clear();
		int ret = redis.zadd(key, members);
		if (ret < 0)
		{
			printf("add key: %s error\r\n", key.c_str());
			return false;
		}
		else if (i < 10)
			printf("add ok, key: %s, ret: %d\r\n",
				key.c_str(), ret);
		members.clear();
	}

	return true;
}
开发者ID:39608106,项目名称:acl,代码行数:31,代码来源:redis_zset.cpp

示例5: test_zrank

static bool test_zrank(acl::redis_zset& redis, int n)
{
	acl::string key;
	acl::string member;

	for (int i = 0; i < n; i++)
	{
		key.format("%s_%d", __keypre.c_str(), i);

		for (int j = 0; j < 1000; j++)
		{
			member.format("member_%d", j);
			redis.clear();
			int ret = redis.zrank(key.c_str(), member.c_str());
			if (ret < 0)
			{
				printf("zrank error, key: %s\r\n", key.c_str());
				return false;
			}
			else if (j > 0 && j * i < 100)
				printf("zrank ok, key: %s, member:%s, "
					"rank: %d\r\n", key.c_str(),
					member.c_str(), ret);
		}
	}

	return true;
}
开发者ID:39608106,项目名称:acl,代码行数:28,代码来源:redis_zset.cpp

示例6: test_zrem

static bool test_zrem(acl::redis_zset& redis, int n)
{
	acl::string key;
	acl::string member;
	std::vector<acl::string> members;

	for (int i = 0; i < n; i++)
	{
		key.format("%s_%d", __keypre.c_str(), i);

		for (int j = 900; j < 1000; j++)
		{
			member.format("member_%d", j);
			members.push_back(member);
		}

		redis.clear();
		int ret = redis.zrem(key.c_str(), members);
		if (ret < 0)
		{
			printf("zrem error, key: %s\r\n", key.c_str());
			return false;
		}
		else if (i < 10)
			printf("zrem ok, key: %s, ret: %d\r\n",
				key.c_str(), ret);
	}

	return true;
}
开发者ID:39608106,项目名称:acl,代码行数:30,代码来源:redis_zset.cpp

示例7: test_sdiffstore

static bool test_sdiffstore(acl::redis_set& redis, int n)
{
	acl::string key, dest_key("set_dest_key");
	std::vector<acl::string> keys;

	for (int i = 0; i < 10; i++)
	{
		key.format("%s_%d", __keypre.c_str(), i);
		keys.push_back(key);
	}

	for (int i = 0; i < n; i++)
	{
		redis.clear();
		int ret = redis.sdiffstore(dest_key.c_str(), keys);
		if (ret < 0)
		{
			printf("sdiffstore error, dest: %s\r\n",
				dest_key.c_str());
			return false;
		}
		else if (i >= 10)
			continue;

		printf("sdiffstore ok, dest: %s, count: %d\r\n",
			dest_key.c_str(), ret);
	}

	return true;
}
开发者ID:1514louluo,项目名称:acl,代码行数:30,代码来源:redis_set.cpp

示例8: acl_assert

void CMsnClient::OnDSOk(const acl::string& ns_addr)
{
	acl_assert(ds_client_);
	ns_addr_ = ns_addr;
	delete ds_client_;
	ds_client_ = NULL;

	acl::string addr(ns_addr_.c_str());
	char* ptr = strchr(addr.c_str(), ':');
	if (ptr == NULL || *(ptr + 1) == 0)
	{
		logger_error("invalid ns_addr(%s)", ns_addr.c_str());
		return;
	}
	*ptr++ = 0;
	unsigned short port = atoi(ptr);
	if (port == 0)
	{
		logger_error("invalid ns_port(0)");
		return;
	}

	ns_client_ = NEW CMsnNSClient(account_.c_str(), this);
	ns_client_->Open(addr.c_str(), port, timeout_);
}
开发者ID:bhassani,项目名称:msn_client,代码行数:25,代码来源:MsnClient.cpp

示例9: test_sdiff

static bool test_sdiff(acl::redis_set& redis, int n)
{
	acl::string key;
	std::vector<acl::string> keys;
	std::vector<acl::string> result;

	for (int i = 0; i < 10; i++)
	{
		key.format("%s_%d", __keypre.c_str(), i);
		keys.push_back(key);
	}

	for (int i = 0; i < n; i++)
	{
		redis.clear();
		int ret = redis.sdiff(keys, &result);
		if (ret < 0)
		{
			printf("sdiff error\r\n");
			return false;
		}
		else if (i < 10)
			printf("sdiff ok, count: %d\r\n", ret);
	}

	return true;
}
开发者ID:1514louluo,项目名称:acl,代码行数:27,代码来源:redis_set.cpp

示例10: test_sadd

static bool test_sadd(acl::redis_set& redis, int n)
{
	acl::string key;
	std::vector<acl::string> members;
	acl::string member;

	members.reserve(1000);

	for (int j = 0; j < 1000; j++)
	{
		member.format("member_%d", j);
		members.push_back(member);
	}

	for (int i = 0; i < n; i++)
	{
		key.format("%s_%d", __keypre.c_str(), i);

		redis.clear();
		int ret = redis.sadd(key, members);
		if (ret < 0)
		{
			printf("sadd key: %s error\r\n", key.c_str());
			return false;
		}
		else if (i >= 10)
			continue;

		printf("sadd ok, key: %s, ret: %d\r\n", key.c_str(), ret);
	}

	return true;
}
开发者ID:1514louluo,项目名称:acl,代码行数:33,代码来源:redis_set.cpp

示例11: test_spop

static bool test_spop(acl::redis_set& redis, int n)
{
	acl::string key;
	acl::string member;

	for (int i = 0; i < n; i++)
	{
		key.format("%s_%d", __keypre.c_str(), i);
		redis.clear();
		bool ret = redis.spop(key.c_str(), member);
		if (redis.eof())
		{
			printf("spop eof, key: %s\r\n", key.c_str());
			return false;
		}
		if (i >= 10)
			continue;

		printf("spop %s, key: %s, member: %s\r\n",
			ret ? "ok" : "empty", key.c_str(),
			ret ? member.c_str() : "");
	}

	return true;
}
开发者ID:1514louluo,项目名称:acl,代码行数:25,代码来源:redis_set.cpp

示例12: test_sismember

static bool test_sismember(acl::redis_set& redis, int n)
{
	bool ret;
	acl::string key, member;

	for (int i = 0; i < n; i++)
	{
		key.format("%s_%d", __keypre.c_str(), i);

		for (int j = 0; j < 1000; j++)
		{
			member.format("member_%d", j);
			redis.clear();
			ret = redis.sismember(key.c_str(), member.c_str());
			if (redis.eof())
			{
				printf("sismmeber eof, key: %s, member: %s\r\n",
					key.c_str(), member.c_str());
				return false;
			}
			if (i >= 10)
				continue;

			printf("sismember: %s, key: %s, member: %s\r\n",
				ret ? "true" : "false", key.c_str(),
				member.c_str());
		}
	}

	return true;
}
开发者ID:1514louluo,项目名称:acl,代码行数:31,代码来源:redis_set.cpp

示例13: do_copy

static void do_copy(const acl::string& from, const acl::string& to)
{
	acl::scan_dir scan;
	if (scan.open(from.c_str()) == false)
	{
		logger_error("open path: %s error: %s",
			from.c_str(), acl::last_serror());
		return;
	}

	const char* name;
	bool  is_file;
	int   nfiles = 0, ndirs = 0, nfiles_copied = 0, ndirs_copied = 0;
	while ((name = scan.next(false, &is_file)) != NULL)
	{
		SKIP(name);

		if (is_file)
		{
			if (cmp_copy(scan, name, to, &nfiles_copied) == false)
			{
				printf(">>cm_copy failed, name: %s\r\n", name);
				break;
			}
			nfiles++;
		}
		else if (check_dir(scan, to, &ndirs_copied) == false)
		{
			printf(">>check_dir failed, name: %s\r\n", name);
			break;
		}
		else
			ndirs++;

		if ((nfiles + ndirs) % 100 == 0)
		{
			printf("current file count: copied %d / scaned %d, "
				"dir count: copied %d / scaned %d\r",
				nfiles_copied, nfiles, ndirs_copied, ndirs);
			fflush(stdout);
		}
	}

	printf("total file count: copyied %d / scaned %d, dir count: "
		"copied %d / scaned %d\r\n", nfiles_copied, nfiles,
		ndirs_copied, ndirs);
}
开发者ID:1514louluo,项目名称:acl,代码行数:47,代码来源:main.cpp

示例14: http_hdr_res_static

void http_client::do_reply(int status, const char* cmd,
	const acl::string& body, bool save)
{
	HTTP_HDR_RES* hdr_res = http_hdr_res_static(status);
	http_hdr_set_keepalive(hdr_req_, hdr_res);
	http_hdr_put_str(&hdr_res->hdr, "Content-Type", "text/json");
	http_hdr_put_int(&hdr_res->hdr, "Content-Length", (int) body.size());

	acl::string buf(body.size() + 256);
	http_hdr_build(&hdr_res->hdr, buf.vstring());
	http_hdr_res_free(hdr_res);
	buf.append(body);

	if (save)
		logger("cmd=[%s], reply: [%s]", cmd, buf.c_str());
	acl_aio_writen(conn_, buf.c_str(), (int) buf.size());
}
开发者ID:iYefeng,项目名称:acl,代码行数:17,代码来源:http_client.cpp

示例15: test_publish

static bool test_publish(acl::redis_pubsub& redis, int n)
{
	acl::string channel, msg;
	int   ret, i;

	for (i = 0; i < n; i++)
	{
		channel.format("%s_1_%d", __channel_prefix.c_str(), i);
		msg.format("msg_1_%s", channel.c_str());

		redis.clear();
		ret = redis.publish(channel.c_str(), msg.c_str(), msg.length());
		if (ret <= 0)
		{
			printf("publish to %s %s error(%s), ret: %d\r\n",
				channel.c_str(), msg.c_str(),
				redis.result_error(), ret);
			return false;
		}
		else if (i < 10)
			printf("publish to %s %s ok\r\n", channel.c_str(),
				msg.c_str());

		channel.format("%s_2_%d", __channel_prefix.c_str(), i);
		msg.format("msg_2_%s", channel.c_str());
		redis.clear();

		ret = redis.publish(channel.c_str(), msg.c_str(), msg.length());
		if (ret <= 0)
		{
			printf("publish to %s %s error(%s), ret: %d\r\n",
				channel.c_str(), msg.c_str(),
				redis.result_error(), ret);
			return false;
		}
		else if (i < 10)
			printf("publish to %s %s ok\r\n", channel.c_str(),
				msg.c_str());
	}

	printf(">>>publish total: %d\r\n", i * 2);
	return true;
}
开发者ID:DayBreakZhang,项目名称:acl,代码行数:43,代码来源:redis_pubsub.cpp


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