summaryrefslogtreecommitdiff
path: root/cpp/demo/Freeze/transform/readnew.cpp
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2007-11-14 15:26:38 -0500
committerBernard Normier <bernard@zeroc.com>2007-11-14 15:26:38 -0500
commit7d6cfecf8c80394934f49c7d3201583fc8f8abf4 (patch)
tree6b387892fd50559bbc1226c05ee20f53a73be1a0 /cpp/demo/Freeze/transform/readnew.cpp
parentMerge branch 'master' of ssh://cvs.zeroc.com/home/git/ice (diff)
downloadice-7d6cfecf8c80394934f49c7d3201583fc8f8abf4.tar.bz2
ice-7d6cfecf8c80394934f49c7d3201583fc8f8abf4.tar.xz
ice-7d6cfecf8c80394934f49c7d3201583fc8f8abf4.zip
New Map::recreate and Freeze/transform demo
Diffstat (limited to 'cpp/demo/Freeze/transform/readnew.cpp')
-rw-r--r--cpp/demo/Freeze/transform/readnew.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/cpp/demo/Freeze/transform/readnew.cpp b/cpp/demo/Freeze/transform/readnew.cpp
new file mode 100644
index 00000000000..518b52b8a82
--- /dev/null
+++ b/cpp/demo/Freeze/transform/readnew.cpp
@@ -0,0 +1,63 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#include <Ice/Ice.h>
+#include <Freeze/Freeze.h>
+#include <NewContacts.h>
+
+using namespace std;
+using namespace Demo;
+using namespace Freeze;
+
+class ReadNew : public Ice::Application
+{
+public:
+
+ virtual int run(int, char*[]);
+};
+
+int main(int argc, char* argv[])
+{
+ ReadNew app;
+ return app.main(argc, argv);
+}
+
+int
+ReadNew::run(int argc, char* argv[])
+{
+ ConnectionPtr connection = createConnection(communicator(), "dbnew");
+ bool createDb = true;
+ const NewContacts contacts(connection, "contacts", createDb);
+
+ NewContacts::const_iterator p;
+
+ try
+ {
+ cout << "All contacts (default order)" << endl;
+ for(p = contacts.begin(); p != contacts.end(); ++p)
+ {
+ cout << p->first << ":\t\t" << p->second.phoneNumber
+ << " " << p->second.emailAddress << endl;
+ }
+
+ cout << endl << "All contacts (ordered by phone number)" << endl;
+ for(p = contacts.beginForPhoneNumber(); p != contacts.endForPhoneNumber(); ++p)
+ {
+ cout << p->first << ":\t\t" << p->second.phoneNumber
+ << " " << p->second.emailAddress << endl;
+ }
+ }
+ catch(const Ice::UnmarshalOutOfBoundsException&)
+ {
+ cerr << "Error: you need to transform the contacts database to the new format" << endl;
+ return 1;
+ }
+
+ return 0;
+}