added example using generated and installed example library
[libt2n] / example-libusage / client.cpp
diff --git a/example-libusage/client.cpp b/example-libusage/client.cpp
new file mode 100644 (file)
index 0000000..7a98309
--- /dev/null
@@ -0,0 +1,30 @@
+/***************************************************************************
+ *   Copyright (C) 2004 by Intra2net AG                                    *
+ *   info@intra2net.com                                                    *
+ *                                                                         *
+ ***************************************************************************/
+
+#include <socket_client.hxx>
+
+// include generated library header
+#include "default_client.hxx"
+
+int main(int argc, char** argv)
+{
+  libt2n::socket_client_connection sc("./socket");
+  cmd_group_default_client cc(sc);
+
+  bool throwok=false;
+  try
+  {
+      cc.testfunc("throw");
+  }catch(libt2n::t2n_runtime_error &e){
+      throwok=(std::string(e.what())=="throw me around");
+  }
+
+  return ( throwok
+          && ( cc.testfunc("hello") == "hello, testfunc() was here" )
+          && ( cc.testfunc_ref("hello") == "hello, testfunc() was here" )
+          && ( cc.t2(10) == 10 ) )
+    ? EXIT_SUCCESS : EXIT_FAILURE;
+}