/tags/rel-1-3-25/SWIG/Examples/test-suite/li_std_string.i
Swig | 84 lines | 63 code | 21 blank | 0 comment | 0 complexity | a074b5ea4c92ced503dc08d5799e9335 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
1%module li_std_string 2%include "std_string.i" 3 4%inline %{ 5 6std::string test_value(std::string x) { 7 return x; 8} 9 10const std::string& test_const_reference(const std::string &x) { 11 return x; 12} 13 14void test_pointer(std::string *x) { 15} 16 17std::string *test_pointer_out() { 18 static std::string x = "x"; 19 return &x; 20} 21 22void test_const_pointer(const std::string *x) { 23} 24 25const std::string *test_const_pointer_out() { 26 static std::string x = "x"; 27 return &x; 28} 29 30void test_reference(std::string &x) { 31} 32 33std::string& test_reference_out() { 34 static std::string x = "test_reference_out message"; 35 return x; 36} 37 38void test_throw() throw(std::string){ 39 static std::string x = "test_throw message"; 40 throw x; 41} 42 43void test_const_reference_throw() throw(const std::string &){ 44 static std::string x = "test_const_reference_throw message"; 45 throw x; 46} 47 48void test_pointer_throw() throw(std::string *) { 49 throw new std::string("foo"); 50} 51 52void test_const_pointer_throw() throw(const std::string *) { 53 throw new std::string("foo"); 54} 55 56%} 57 58%apply const std::string& { std::string *GlobalString2, 59 std::string *MemberString2, 60 std::string *Structure::StaticMemberString2 }; 61 62%inline %{ 63std::string GlobalString; 64std::string GlobalString2 = "global string 2"; 65 66struct Structure { 67 std::string MemberString; 68 std::string MemberString2; 69 static std::string StaticMemberString; 70 static std::string StaticMemberString2; 71 72 const std::string ConstMemberString; 73 static const std::string ConstStaticMemberString; 74 75 Structure() : MemberString2("member string 2"), ConstMemberString("const member string") {} 76}; 77%} 78 79%{ 80 std::string Structure::StaticMemberString = "static member string"; 81 std::string Structure::StaticMemberString2 = "static member string 2"; 82 const std::string Structure::ConstStaticMemberString = "const static member string"; 83%} 84