copy includes from input file to common_hpp file
[libt2n] / example-codegen / server.hxx
CommitLineData
86c1c2e9 1#include <string>
e5bc4700
JT
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
86c1c2e9
JT
11#include "codegen_common.hxx"
12
472456ca 13LIBT2N_SET_DEFAULTGROUP(default);
86c1c2e9 14
e5bc4700 15//! test pass by copy
86c1c2e9
JT
16LIBT2N_EXPORT std::string testfunc(std::string str)
17{
71ae912c
JT
18 std::string ret;
19 if (str=="throw")
20 throw libt2n::t2n_runtime_error("throw me around");
21 if (str=="big")
22 ret.insert(0,100*1024,'x');
23 else
24 ret=str+", testfunc() was here";
25 return ret;
26}
27
e5bc4700 28//! test pass by const reference
71ae912c
JT
29LIBT2N_EXPORT std::string testfunc_ref(const std::string &str)
30{
31 std::string ret;
86c1c2e9
JT
32 if (str=="throw")
33 throw libt2n::t2n_runtime_error("throw me around");
34 if (str=="big")
35 ret.insert(0,100*1024,'x');
36 else
37 ret=str+", testfunc() was here";
38 return ret;
39}
71ae912c 40
e5bc4700 41//! test builtin type
71ae912c
JT
42LIBT2N_EXPORT int t2(int i)
43{
44 return i;
45}
46
47using namespace std;
48
e5bc4700 49//! test pair, multiple arguments and namespace
29ba0e97 50LIBT2N_EXPORT_GROUP(other) bool t3(int i, float f, const string &s, const pair<int, float> &p)
71ae912c
JT
51{
52 return (i==p.first) && (f==p.second) && (s=="hello");
53}
472456ca 54
e5bc4700 55//! test function overload
472456ca
JT
56LIBT2N_EXPORT_GROUP(other) int t3(int i)
57{
58 return i;
59}
e5bc4700
JT
60
61//! test std::vector
62LIBT2N_EXPORT_GROUP(other) bool t3(const std::vector<int> &i)
63{
64 return (i.size()==1) && (i[0]==10);
65}