Copy from a stl string to a pj_str_t struct

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

 

This is probably a very simple question, but I'm still finding it hard
to figure out the best approach.

 

I'm making a c++ wrapper for the pjsip stack and receives the username,
password etc in a function as stl strings.

I then want to set them in the pjsua_acc_config struct.

For example: The username stl string into pjsua_acc_config.id. What is
the most efficient and best way to do this?

 

I tried (among other solutions) this one: 

pj_strcpy2(&pjsuaAccountConfig.id, username.c_str());

but the pointer to pjsuaAccountConfig.id.ptr is null, so it can't be
used by memcpy.

 

I've figured out this one, but it feels a bit clumsy

 

      char* tmpUsername = new char[username.size()];

      strcpy(tmpUsername, username.c_str());

 

      pjsua_acc_config pjsuaAccountConfig;

pjsua_acc_config_default(&pjsuaAccountConfig);

      pjsuaAccountConfig.id = pj_str(tmpUserId);

 

Any other ideas?

 

 

Br,

Andreas Backman

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20080207/2fb8094f/attachment.html 


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux