473,378 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

boost::python and automatic conversion for const std::string&

I have a lot of functions returning "const std::string&". Every time I
wrap one of those I have to do it like this:

class_.def("name", &someclass::bla,
boost::python::return_value_policy<boost::python:: copy_const_reference>()
);

Is there a way to register a return value conversion for "const
std::string&" so I can omit it every time I have to wrap functions
returning "const std::string&" ? I wan't those strings to be copied to
python as new strings (I don't want to hold a pointer to them).
Thanks

Dec 21 '06 #1
1 1956
On 21 Dec 2006 07:30:41 -0800, ga****************@gmail.com
<ga****************@gmail.comwrote:
I have a lot of functions returning "const std::string&". Every time I
wrap one of those I have to do it like this:

class_.def("name", &someclass::bla,
boost::python::return_value_policy<boost::python:: copy_const_reference>()
);

Is there a way to register a return value conversion for "const
std::string&" so I can omit it every time I have to wrap functions
returning "const std::string&" ? I wan't those strings to be copied to
python as new strings (I don't want to hold a pointer to them).
I am not sure, you'd better ask this question o Boost.Python mailing list:
http://mail.python.org/mailman/listinfo/c++-sig/
Py++, Boost.Python code generator, does it for you: http://tinyurl.com/ygwdkz
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
Dec 21 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: AzizMandar | last post by:
There is probably a better way to do this and if so I'm just as happy to see that way. I have a program where I have factories that each create various objects abstracted from a base class. ...
3
by: asclearuc | last post by:
Hello Is it possible to use map<string&, string&>? Why I need it. I have a large amount of data obtained from XML file. I should do processing of this data. The processing takes many...
7
by: mscava | last post by:
Hi... Today I was trying to find the best way to handle elements in Containers. I've found 3 appraoches but all do have pros and cons... 1. std::vector<MyClass> - inefficient - you have to...
30
by: Alf P. Steinbach | last post by:
I once suggested in that SomeOne Else(TM) should propose a string value class that accepted literals and char pointers and so on, with possible custom deleter, and in case of literal strings just...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.