copy includes from input file to common_hpp file
[libt2n] / example-codegen / server.hxx
... / ...
CommitLineData
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 "codegen_common.hxx"
12
13LIBT2N_SET_DEFAULTGROUP(default);
14
15//! test pass by copy
16LIBT2N_EXPORT std::string testfunc(std::string str)
17{
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
28//! test pass by const reference
29LIBT2N_EXPORT std::string testfunc_ref(const std::string &str)
30{
31 std::string ret;
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}
40
41//! test builtin type
42LIBT2N_EXPORT int t2(int i)
43{
44 return i;
45}
46
47using namespace std;
48
49//! test pair, multiple arguments and namespace
50LIBT2N_EXPORT_GROUP(other) bool t3(int i, float f, const string &s, const pair<int, float> &p)
51{
52 return (i==p.first) && (f==p.second) && (s=="hello");
53}
54
55//! test function overload
56LIBT2N_EXPORT_GROUP(other) int t3(int i)
57{
58 return i;
59}
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}