vendredi 1 mars 2019

end of string while searching for ) or "

I have been working with xbmc(KODI) and was calling a cpp function from python.

xbmc.executebuiltin("XBMC.PlayerControl(branch_details,{0},{1}".format(device1,device2))

where,

device1 = "USB AUDIO Analog Stereo_ Analog Output (PULSEAUDIO)"
device2 = "Built-in Audio Analog Stereo_ Headphones (PULSEAUDIO)"

but after fetching the parameters in cpp and replacing underscore with comma, i am getting the output as:

std::vector<std::string> device;
if(!params.empty())
{
  std::string DeviceOne = params[1];
  std::string DeviceTwo = params[2];

  for(unsigned int i = 0; i<DeviceOne.length(); i++){
    if(DeviceOne[i] == '_')
        { 
          DeviceOne[i] = ',';
        }
   }

  for(unsigned int i = 0; i<DeviceTwo.length(); i++){

    if(DeviceTwo[i] == '_')
        {    
          DeviceTwo[i] = ',';
        }
    }

std::cout<<DeviceOne <<std::endl; //Getting correct output for DeviceOne 
std::cout<<DeviceTwo <<std::endl; //"Built-in Audio Analog Stereo_ Headphones (PULSEAUDIO

i.e for second device ) is missing.

Aucun commentaire:

Enregistrer un commentaire