You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Matt Broadstone <mb...@gmail.com> on 2016/04/01 16:30:25 UTC

Re: Need Help!: Example of the use of Variant Type

On Fri, Apr 1, 2016 at 10:21 AM, Flores, Paul A. <PA...@saic.com>
wrote:

> Specifically I am looking at example for either how to "extract" a map
> from a Variant  (map<string,string>) or to use map.find()?
>
>
>
> Could not find example on how to use/access Variant type data.
>
>
>
> Any help is appreciated.
>
>
>
> Paul
>
>
>
Hey Paul,

I've got two example utilities we use for testing in our system posted on
this gist: https://gist.github.com/mbroadst/d7bfefb0589a3296ecca55f36af6b3f9.
They convert between JSON and the variant types using the qpid messaging
c++ libraries, hopefully this should give some insight into how to play
around with the variant types.

Regards,
Matt

RE: Need Help!: Example of the use of Variant Type

Posted by "Flores, Paul A." <PA...@SAIC.COM>.
An adaptation of what was shared with me by Matt (Thanks!) it compiles and appears to work!

std::map<std::string,std::string> rtnMapfromVar(const Variant::Map &map){
   std::map<std::string,std::string> results;
   Variant::Map::const_iterator it;
   for (it =map.begin(); it != map.end();++it){
       std::string key=(*it).first;
      Variant variant=(*it).second;
       results[key]=variant.asString();
  }
  return results;
}

________________________________________
From: Gordon Sim [gsim@redhat.com]
Sent: Friday, April 01, 2016 10:13 AM
To: users@qpid.apache.org
Subject: Re: Need Help!: Example of the use of Variant Type

On 01/04/16 15:45, Flores, Paul A. wrote:
> Thanks for the example.  I was hoping for something a whole lot simpler.  It appears to be a royal pain!
>
> Hopefully there is a simplistic example I can implement for my client!  Anyone else?

https://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/Variant.cpp?view=markup#l699


It doesn't explicitly use find but that would be something like (I
haven't tried to compile this!):

     Variant v = ...;//egt map from somewhere
     Variant::Map::const_iterator i = value.asMap().find("foo");
     if (i != value.asMap().end()) {
         std::string value = i->second;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org

________________________________

This communication (including any attachments) may contain information that is proprietary, confidential or exempt from disclosure. If you are not the intended recipient, please note that further dissemination, distribution, use or copying of this communication is strictly prohibited. Anyone who received this message in error should notify the sender immediately by telephone or by return email and delete it from his or her computer.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Need Help!: Example of the use of Variant Type

Posted by Gordon Sim <gs...@redhat.com>.
On 01/04/16 15:45, Flores, Paul A. wrote:
> Thanks for the example.  I was hoping for something a whole lot simpler.  It appears to be a royal pain!
>
> Hopefully there is a simplistic example I can implement for my client!  Anyone else?

https://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/Variant.cpp?view=markup#l699 


It doesn't explicitly use find but that would be something like (I 
haven't tried to compile this!):

     Variant v = ...;//egt map from somewhere
     Variant::Map::const_iterator i = value.asMap().find("foo");
     if (i != value.asMap().end()) {
         std::string value = i->second;
     }	



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


RE: Need Help!: Example of the use of Variant Type

Posted by "Flores, Paul A." <PA...@SAIC.COM>.
Thanks for the example.  I was hoping for something a whole lot simpler.  It appears to be a royal pain!

Hopefully there is a simplistic example I can implement for my client!  Anyone else?

________________________________________
From: Matt Broadstone [mbroadst@gmail.com]
Sent: Friday, April 01, 2016 9:30 AM
To: users
Subject: Re: Need Help!: Example of the use of Variant Type

On Fri, Apr 1, 2016 at 10:21 AM, Flores, Paul A. <PA...@saic.com>
wrote:

> Specifically I am looking at example for either how to "extract" a map
> from a Variant  (map<string,string>) or to use map.find()?
>
>
>
> Could not find example on how to use/access Variant type data.
>
>
>
> Any help is appreciated.
>
>
>
> Paul
>
>
>
Hey Paul,

I've got two example utilities we use for testing in our system posted on
this gist: https://gist.github.com/mbroadst/d7bfefb0589a3296ecca55f36af6b3f9.
They convert between JSON and the variant types using the qpid messaging
c++ libraries, hopefully this should give some insight into how to play
around with the variant types.

Regards,
Matt
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org