Exemplo n.º 1
0
String join( StringRef sep, const VecString& vs )
{
  String j;
  VecString::const_iterator i = vs.begin();
  if( i != vs.end() ) j = *i++;
  while( i != vs.end() ) j += sep + *i++;
  return j;
}
Exemplo n.º 2
0
int getRefCount( const RegKey& dclass, const RegKey& key )
{
  int refcnt = 0;

  try
  {
    String symstr = key["Device Parameters"]("SymbolicName").data;
    VecString sym = split( "\\#", symstr );

    if( sym.size() >= 4 )
    {
      sym.erase( sym.begin(), sym.begin()+sym.size()-4 );
      String devstr = sym[3] +"\\##?#" + join("#",sym) + "\\Control";
      RegKey ctrl = dclass[devstr];
      refcnt = strtol( ctrl("ReferenceCount").data.c_str(), NULL, 0 );
    }
  }
  catch( std::runtime_error e ) { }

  return refcnt;
}
Exemplo n.º 3
0
 void CRedisClient::subscribeStart(const VecString &channel, int timeout)
 {
     Command cmd( "SUBSCRIBE" );
     VecString::const_iterator it = channel.begin();
     for ( ; it != channel.end(); ++it )
     {
         cmd << *it ;
     }
     Poco::Timespan t(timeout, 0);
     _socket.setReceiveTimeout(t);
     CResult result;
     _getArry(cmd, result);
 }
 uint64_t CRedisClient::psubnumsub( CRedisClient::MapString& value, const VecString& channel )
 {
	Command cmd( "PUBSUB" );
	cmd << "NUMSUB";
	if ( channel.size() != 0 )
	{
		VecString::const_iterator it = channel.begin();
		for ( ; it != channel.end(); ++it )
		{
			cmd << *it ;
		}
	}

	return _getArry( cmd, value );
 }
Exemplo n.º 5
0
ListDevice getDevices()
{
    ListDevice devs;

    String ccs = "SYSTEM\\CurrentControlSet\\";
    RegKey dclass( HKEY_LOCAL_MACHINE, ccs+"Control\\DeviceClasses" );
    RegKey ftdibus( HKEY_LOCAL_MACHINE, ccs+"Enum\\FTDIBUS" );
    RegKey usb6001( HKEY_LOCAL_MACHINE, ccs+"Enum\\USB\\Vid_0403&Pid_6001" );

    VecString fdev = ftdibus.getSubkeyNames();
    for( VecString::const_iterator i=fdev.begin(); i!=fdev.end(); i++ )
    {
        if( i->substr(0,18) == String("VID_0403+PID_6001+") )
        {
            Device d;
            d.id = i->substr(18,8);

            try
            {
                RegKey devkey = ftdibus[*i];
                VecString devsub = devkey.getSubkeyNames();
                d.comm = devkey[devsub[0]+"\\Device Parameters"]("PortName").data;
            }
            catch( std::runtime_error e )
            {
                d.comm = "no_comm";
            }

            try {
                d.info = usb6001[d.id]("LocationInformation").data;
            }
            catch( std::runtime_error e ) { }

            try {
                d.refcount = getRefCount( dclass, usb6001[d.id] );
            }
            catch( std::runtime_error e ) { }

            String::size_type ncomm = d.comm.find_first_of("0123456789");
            if( ncomm != String::npos )
                d.sortnum = atoi( d.comm.substr(ncomm).c_str() );

            devs.push_back(d);
        }
    }

    return devs;
}
 uint64_t CRedisClient::psubchannels( VecString& value, const VecString& pattern )
 {
	Command cmd( "PUBSUB" );
	cmd << "CHANNELS";

	if ( pattern.size() != 0 )
	{
		VecString::const_iterator it = pattern.begin();
		for ( ; it != pattern.end(); ++it )
		{
			cmd << *it ;
		}
	}

	return _getArry( cmd, value );
 }
Exemplo n.º 7
0
 void CRedisClient::punsubscribe( CResult& result, const VecString& pattern )
 {
	_socket.clearBuffer();

	Command cmd( "PUNSUBSCRIBE" );
	if ( pattern.size() != 0 )
	{
		VecString::const_iterator it = pattern.begin();
		for ( ; it != pattern.end(); ++it )
		{
			cmd << *it ;
		}
	}
	_sendCommand( cmd );

    _getReply( result );
 }
Exemplo n.º 8
0
 void CRedisClient::psubscribe( const VecString& pattern, CResult& result)
 {
	Command cmd( "PSUBSCRIBE" );
	VecString::const_iterator it = pattern.begin();
	for ( ; it != pattern.end(); ++it )
	{
		cmd << *it;
	}
	_socket.setReceiveTimeout(0);
	result.clear();
	_getArry( cmd, result );
	while(true)
	{
		result.clear();
		_getReply( result );
	}
 }
Exemplo n.º 9
0
 void CRedisClient::unsubscribe( CResult& result, const VecString& channel )
 {
	_socket.clearBuffer();

	Command cmd( "UNSUBSCRIBE" );
	if ( channel.size() != 0 )
	{
		VecString::const_iterator it = channel.begin();
		for ( ; it != channel.end(); ++it )
		{
			cmd << *it ;
		}
	}
	_sendCommand( cmd );

    _getResult( cmd, result );
 }