Add cxx{in,out}type typemaps and use them for std::string
This makes using returning strings much simpler to use from C++ code as the returned pointers don't have to be deleted manually -- although, of course, this does require an extra allocation and copy and so should be avoided for the very long strings. Add a new runtime test showing how simple and convenient it is to use the functions working with string using the C++ wrappers now.
This commit is contained in:
parent
8b871b10fe
commit
fd11a591a3
5 changed files with 135 additions and 30 deletions
|
|
@ -5,11 +5,11 @@
|
|||
int main(int argc, const char *argv[]) {
|
||||
{
|
||||
li_boost_shared_ptr::Klass k("me oh my");
|
||||
assert( strcmp(k.getValue(), "me oh my") == 0 );
|
||||
assert( k.getValue() == "me oh my" );
|
||||
}
|
||||
|
||||
{
|
||||
li_boost_shared_ptr::Klass k{li_boost_shared_ptr_factorycreate()};
|
||||
assert( strcmp(k.getValue(), "factorycreate") == 0 );
|
||||
assert( k.getValue() == "factorycreate" );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
26
Examples/test-suite/c/li_std_string_runme.cxx
Normal file
26
Examples/test-suite/c/li_std_string_runme.cxx
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#include "li_std_string_wrap.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
using namespace li_std_string;
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
Structure st;
|
||||
assert( st.MemberString().empty() );
|
||||
|
||||
st.MemberString("bloordyblop");
|
||||
assert( st.MemberString() == "bloordyblop" );
|
||||
|
||||
assert( st.MemberString2() == "member string 2" );
|
||||
|
||||
assert( st.ConstMemberString() == "const member string" );
|
||||
|
||||
st.StaticMemberString(std::string("static bloordyblop"));
|
||||
assert( st.StaticMemberString() == "static bloordyblop" );
|
||||
|
||||
assert( Structure::StaticMemberString2() == "static member string 2" );
|
||||
assert( Structure::ConstStaticMemberString() == "const static member string" );
|
||||
|
||||
Foo f;
|
||||
assert( f.test("1+") == "1+1" );
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue