commit changes to build
[libt2n] / example-codegen / server.hxx
1 #include <string>
2 // serialization of string
3 #include <boost/serialization/string.hpp>
4 // serialization of pair
5 #include <boost/serialization/utility.hpp>
6
7 // std::vector
8 #include <vector>
9 #include <boost/serialization/vector.hpp>
10
11 #include "foo.hxx"
12
13 #include "codegen_common.hxx"
14
15 LIBT2N_SET_DEFAULTGROUP(default);
16
17 //! test pass by copy
18 LIBT2N_EXPORT std::string testfunc(std::string str) 
19 {
20     std::string ret;
21     if (str=="throw")
22         throw libt2n::t2n_runtime_error("throw me around");
23     if (str=="big")
24         ret.insert(0,100*1024,'x');
25     else
26         ret=str+", testfunc() was here";
27     return ret;
28 }
29
30 //! test pass by const reference
31 LIBT2N_EXPORT std::string testfunc_ref(const std::string &str) 
32 {
33     std::string ret;
34     if (str=="throw")
35         throw libt2n::t2n_runtime_error("throw me around");
36     if (str=="big")
37         ret.insert(0,100*1024,'x');
38     else
39         ret=str+", testfunc() was here";
40     return ret;
41 }
42
43 //! test builtin type
44 LIBT2N_EXPORT int t2(int i) 
45 {
46     return i;
47 }
48
49 using namespace std;
50
51 //! test pair, multiple arguments and namespace
52 LIBT2N_EXPORT_GROUP(other) bool t3(int i, float f, const string &s, const pair<int, float> &p)
53 {
54     return (i==p.first) && (f==p.second) && (s=="hello");
55 }
56
57 //! test function overload
58 LIBT2N_EXPORT_GROUP(other) int t3(int i)
59 {
60     return i;
61 }
62
63 //! test std::vector
64 LIBT2N_EXPORT_GROUP(other) bool t3(const std::vector<int> &i)
65 {
66     return (i.size()==1) && (i[0]==10);
67 }
68
69 //! test own type and seperate declaration and definition
70 LIBT2N_EXPORT_GROUP(other) bool t3(const Foo &foo);