summaryrefslogtreecommitdiff
path: root/cpp/demo/Freeze/transform/create.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/create.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/create.cpp')
-rw-r--r--cpp/demo/Freeze/transform/create.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/cpp/demo/Freeze/transform/create.cpp b/cpp/demo/Freeze/transform/create.cpp
new file mode 100644
index 00000000000..4ceeb6b869b
--- /dev/null
+++ b/cpp/demo/Freeze/transform/create.cpp
@@ -0,0 +1,61 @@
+// **********************************************************************
+//
+// 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 <Contacts.h>
+
+using namespace std;
+using namespace Demo;
+using namespace Freeze;
+
+class Create : public Ice::Application
+{
+public:
+
+ virtual int run(int, char*[]);
+};
+
+int main(int argc, char* argv[])
+{
+ Create app;
+ return app.main(argc, argv);
+}
+
+int
+Create::run(int argc, char* argv[])
+{
+ const string names[] = { "don", "ed", "frank", "gary", "arnold", "bob", "carlos" };
+ const string phoneNumbers[] = { "(777)777-7777", "(666)666-6666", "(555)555-5555",
+ "(444)444-4444", "(333)333-3333", "(222)222-2222", "(111)111-1111" };
+ const size_t size = 7;
+
+
+ ConnectionPtr connection = createConnection(communicator(), "db");
+ Contacts contacts(connection, "contacts");
+
+
+ //
+ // Create a bunch of contacts within one transaction, and commit it
+ //
+
+ TransactionHolder txh(connection);
+ for(size_t i = 0; i < size; ++i)
+ {
+ ContactData data = { phoneNumbers[i] };
+
+ contacts.put(Contacts::value_type(names[i], data));
+ }
+
+ txh.commit();
+
+ cout << size << " contacts were successfully created or updated" << endl;
+
+ return 0;
+}