bool xRedisClient::zscore(const RedisDBIdx& dbi,  const string& key, const string &member, string& score ){
     if (0==key.length()) {
         return false;
     }
     SETDEFAULTIOTYPE(SLAVE);
     return command_string(dbi, score, "ZSCORE %s %s", key.c_str(), member.c_str());
 }
Exemplo n.º 2
0
bool xRedisClient::spop(const RedisDBIdx& dbi,  const KEY& key, VALUE& member) {
	if (0 == key.length()) {
		return false;
	}
	SETDEFAULTIOTYPE(MASTER);
	return command_string(dbi, member, "SPOP %s", key.c_str());
}
Exemplo n.º 3
0
bool xRedisClient::rpop(const RedisDBIdx& dbi,    const string& key, string& value) {
	if (0 == key.length()) {
		return false;
	}
	SETDEFAULTIOTYPE(MASTER);
	return command_string(dbi, value, "RPOP %s", key.c_str());
}
Exemplo n.º 4
0
bool xRedisClient::rpoplpush(const RedisDBIdx& dbi,    const string& key_src, const string& key_dest, string& value) {
	if ((0 == key_src.length()) || (0 == key_dest.length())) {
		return false;
	}
	SETDEFAULTIOTYPE(MASTER);
	return command_string(dbi, value, "RPOPLPUSH %s %s", key_src.c_str(), key_dest.c_str());
}
bool xRedisClient::mget(const DBIArray &vdbi,   const KEYS &  keys, ReplyData& vDdata) {
    bool bRet = false;
    size_t n = vdbi.size();
    if (n!=keys.size()) {
        return bRet;
    }
    
    DataItem item;
    DBIArray::const_iterator iter_dbi = vdbi.begin();
    KEYS::const_iterator iter_key = keys.begin();
    for (;iter_key!=keys.end();++iter_key, ++iter_dbi) {
        const RedisDBIdx& dbi = *iter_dbi;
        SETDEFAULTIOTYPE(SLAVE);
        const string &key = *iter_key;
        if (key.length()>0) {
            bool ret = command_string(*iter_dbi, item.str, "GET %s", key.c_str());
            if (!ret) {
                item.type = REDIS_REPLY_NIL;
                item.str  = "";
            } else {
                item.type = REDIS_REPLY_STRING;
                bRet = true;
            }
            vDdata.push_back(item);
        }
    }
    return bRet;
}
Exemplo n.º 6
0
bool xRedisClient::lindex(const RedisDBIdx& dbi,    const string& key, int64_t index, VALUE& value) {
	if (0 == key.length()) {
		return false;
	}
	SETDEFAULTIOTYPE(SLAVE);
	return command_string(dbi, value, "LINDEX %s %lld", key.c_str(), index);
}
bool xRedisClient::zincrby(const RedisDBIdx& dbi,  const string& key, const double &increment, const string& member, string& value ) {
    if (0==key.length()) {
        return false;
    }
    SETDEFAULTIOTYPE(MASTER);
    return command_string(dbi, value, "ZINCRBY %s %f %s", key.c_str(), increment, member.c_str());
}
bool xRedisClient::echo(const RedisDBIdx& dbi, const string& str, std::string &value)
{
	if (0==str.length()) {
        return false;
    }
    SETDEFAULTIOTYPE(MASTER);
    return command_string(dbi, value, "echo %s", str.c_str());
}
Exemplo n.º 9
0
void program_print(Program* program)
{
  int i;
  char code[64];
  for(i = 0; i < program->size; i++)
  {
    command_string(program->commands[i], code);
    printf("%d: %s\n", i, code);
  }
}
Exemplo n.º 10
0
char* get_command_proposal(char* name) {
	static char ans[100];
	command* c;

	if(strcmp(name, "MCA") == 0) {
		c = init_command(name, "PWMD", "PWMI");
	} else if(strcmp(name, "MCA") == 0) {
		c = init_command(name, "PWMF", "PWMB");
	} else {
		c = init_command(name, "", "");
	}
	
	strcpy(ans, command_string(c));
	destroy_command(c);

	return ans;
}
Exemplo n.º 11
0
bool xRedisClient::spop(const RedisDBIdx& dbi,  const KEY& key, VALUE& member) {
    return command_string(dbi, member, "SPOP %s", key.c_str());
}
Exemplo n.º 12
0
bool CRedisClient::zscore(const CString &key, const CString &member, CString &score)
{
	return command_string(score, "ZSCORE %s %s", (LPCSTR)key, (LPCSTR)member);
}
Exemplo n.º 13
0
bool CRedisClient::rpop(const CString &key, CString &value)
{
	return command_string(value, "RPOP %s", (LPCSTR)key);
}
Exemplo n.º 14
0
bool xRedisClient::getrange(const RedisDBIdx& dbi,const string& key,  int start, int end, string& out) {
    SETDEFAULTIOTYPE(SLAVE);
    return command_string(dbi, out, "GETRANGE %s %d %d", key.c_str(), start, end);
}
Exemplo n.º 15
0
bool CRedisClient::get(const CString &key, CString &value)
{
	return command_string(value, "GET %s", (LPCSTR)key);
}
Exemplo n.º 16
0
bool xRedisClient::hget(const RedisDBIdx& dbi,    const string& key, const string& field, string& value) {
    SETDEFAULTIOTYPE(SLAVE);
    return command_string(dbi, value, "HGET %s %s", key.c_str(), field.c_str());
}
Exemplo n.º 17
0
		int32 EnterCommand(const char* command_list
			, _Out_opt_ std::string* arguments_string
			, const char* line_start)
		{
			std::vector<std::string> command_array;
			std::string commands(command_list);

			bool newline_command = false;

			// split the command list into an array
			while(commands.length())
			{
				std::string segment;
				// get the next command in the list and add it to the command array
				StringEditing::GetStringSegment(commands, segment, nullptr, ";");
				command_array.push_back(segment);

				// remove the command from the commands string
				StringEditing::RemoveStringSegment(commands, nullptr, ";");

				// if the user can just press enter, we need to know to interpret that as a command
				if(!segment.compare("\n") && !newline_command)
				{
					newline_command = true;
				}
			}

			char command[128];
			puts("");
			// get the users command
			Console::ColorPrintF(Enums::_console_color_lightyellow, "%s: ", line_start);
			do
			{
				fgets(command, sizeof(command), stdin);
				//ignore newlines unless it is a valid command
			}while(!newline_command && command[0] == '\n');

			// seperate into command and arguments
			std::string command_string(command);

			// if the command is just a newline no parsing is necessary
			if(command[0] != '\n')
			{
				StringEditing::GetStringSegment(command_string, command_string, nullptr, " \n");
			}

			// if arguments are requested, set the passed strings value
			if(arguments_string)
			{
				// set the arguments string to the whole string, then remove the command
				arguments_string->assign(command);
				StringEditing::RemoveStringSegment(*arguments_string, nullptr, " ");
				StringEditing::GetStringSegment(*arguments_string, *arguments_string, nullptr, "\n");
			}

			int index = 0;
			bool command_found = false;

			// iterate through the commands until a matching one is/is not found
			for( auto& command : command_array )
			{
				if(!command_string.compare(command))
				{
					command_found = true;
					break;
				}
				index++;
			}

			// return the index of the matching command, or -1 if it did not match
			return command_found ? index : -1;
		}
Exemplo n.º 18
0
bool CRedisClient::lindex(const CString &key, int index, CString &value)
{
	CString sIndex;
	sIndex.Format("%d", index);
	return command_string(value, "LINDEX %s %s", (LPCSTR)key, (LPCSTR)sIndex);
}
Exemplo n.º 19
0
bool CRedisClient::hget(const CString &key, const CString &field, CString &value)
{
	return command_string(value, "HGET %s %s", (LPCSTR)key, (LPCSTR)field);
}
Exemplo n.º 20
0
bool xRedisClient::getset(const RedisDBIdx& dbi, const string& key,  const string& newValue, string& oldValue) {
    SETDEFAULTIOTYPE(MASTER);
    return command_string(dbi, oldValue, "GETSET %s %s", key.c_str(), newValue.c_str());
}