X-Git-Url: http://developer.intra2net.com/git/?p=libt2n;a=blobdiff_plain;f=example-codegen%2Fdefault.cpp;fp=example-codegen%2Fdefault.cpp;h=38b936b770c4d4144646f9cbf6a4eb7301c4ed7d;hp=0000000000000000000000000000000000000000;hb=a96ab6288873059274d783980f70899e24bb46ce;hpb=6f6d24c02ef3e3a7600432bed1c801a611c3c918 diff --git a/example-codegen/default.cpp b/example-codegen/default.cpp new file mode 100644 index 0000000..38b936b --- /dev/null +++ b/example-codegen/default.cpp @@ -0,0 +1,43 @@ +#include +// serialization of string +#include +// serialization of pair +#include + +// std::vector +#include +#include + +#include "default_common.hxx" + +//! test pass by copy +LIBT2N_EXPORT std::string testfunc(std::string str) +{ + std::string ret; + if (str=="throw") + throw libt2n::t2n_runtime_error("throw me around"); + if (str=="big") + ret.insert(0,100*1024,'x'); + else + ret=str+", testfunc() was here"; + return ret; +} + +//! test pass by const reference +LIBT2N_EXPORT std::string testfunc_ref(const std::string &str) +{ + std::string ret; + if (str=="throw") + throw libt2n::t2n_runtime_error("throw me around"); + if (str=="big") + ret.insert(0,100*1024,'x'); + else + ret=str+", testfunc() was here"; + return ret; +} + +//! test builtin type +LIBT2N_EXPORT int t2(int i) +{ + return i; +}