summaryrefslogtreecommitdiff
path: root/cpp/demo/Ice/pickle/Writer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/demo/Ice/pickle/Writer.cpp')
-rw-r--r--cpp/demo/Ice/pickle/Writer.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/cpp/demo/Ice/pickle/Writer.cpp b/cpp/demo/Ice/pickle/Writer.cpp
new file mode 100644
index 00000000000..9319db1a184
--- /dev/null
+++ b/cpp/demo/Ice/pickle/Writer.cpp
@@ -0,0 +1,69 @@
+// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#include <Ice/Ice.h>
+#include <Pickle.h>
+#include <fstream>
+
+using namespace std;
+
+int
+run(int argc, char* argv[], Ice::CommunicatorPtr communicator)
+{
+ PersistentPtr persistent = new Persistent;
+ persistent->aString = "this is the persistent string";
+ persistent->aDouble = 3.14;
+
+ ofstream out("persistent");
+ if (!out)
+ {
+ cerr << argv[0] << ": can't open file \"persistent\" for writing: "
+ << strerror(errno) << endl;
+ return EXIT_FAILURE;
+ }
+
+ Ice::PicklerPtr pickler = communicator->getPickler();
+ pickler->pickle(persistent.get(), out);
+
+ return EXIT_SUCCESS;
+}
+
+int
+main(int argc, char* argv[])
+{
+ int status;
+ Ice::CommunicatorPtr communicator;
+
+ try
+ {
+ communicator = Ice::initialize(argc, argv);
+ status = run(argc, argv, communicator);
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ cerr << ex << endl;
+ status = EXIT_FAILURE;
+ }
+
+ if (communicator)
+ {
+ try
+ {
+ communicator->destroy();
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ cerr << ex << endl;
+ status = EXIT_FAILURE;
+ }
+ }
+
+ return status;
+}