~ubuntu-branches/ubuntu/quantal/zeroc-ice/quantal

« back to all changes in this revision

Viewing changes to cpp/demo/Ice/invoke/Client.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cleto Martin Angelina
  • Date: 2011-04-25 18:44:24 UTC
  • mfrom: (6.1.14 sid)
  • Revision ID: james.westby@ubuntu.com-20110425184424-sep9i9euu434vq4c
Tags: 3.4.1-7
* Bug fix: "libdb5.1-java.jar was renamed to db.jar", thanks to Ondřej
  Surý (Closes: #623555).
* Bug fix: "causes noise in php5", thanks to Jayen Ashar (Closes:
  #623533).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// **********************************************************************
2
2
//
3
 
// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
 
3
// Copyright (c) 2003-2010 ZeroC, Inc. All rights reserved.
4
4
//
5
5
// This copy of Ice is licensed to you under the terms described in the
6
6
// ICE_LICENSE file included in this distribution.
13
13
using namespace std;
14
14
using namespace Demo;
15
15
 
 
16
static ostream&
 
17
operator<<(ostream& out, Demo::Color c)
 
18
{
 
19
    switch(c)
 
20
    {
 
21
    case Demo::red:
 
22
        out << "red";
 
23
        break;
 
24
    case Demo::green:
 
25
        out << "green";
 
26
        break;
 
27
    case Demo::blue:
 
28
        out << "blue";
 
29
        break;
 
30
    }
 
31
    return out;
 
32
}
 
33
 
16
34
class InvokeClient : public Ice::Application
17
35
{
18
36
public:
22
40
 
23
41
private:
24
42
 
 
43
    void usage(const string&);
25
44
    void menu();
26
45
};
27
46
 
32
51
    return app.main(argc, argv, "config.client");
33
52
}
34
53
 
35
 
static ostream&
36
 
operator<<(ostream& out, Demo::Color c)
37
 
{
38
 
    switch(c)
39
 
    {
40
 
    case Demo::red:
41
 
        out << "red";
42
 
        break;
43
 
    case Demo::green:
44
 
        out << "green";
45
 
        break;
46
 
    case Demo::blue:
47
 
        out << "blue";
48
 
        break;
49
 
    }
50
 
    return out;
51
 
}
52
 
 
53
54
InvokeClient::InvokeClient() :
54
55
    //
55
56
    // Since this is an interactive demo we don't want any signal
86
87
                //
87
88
                Ice::ByteSeq inParams, outParams;
88
89
                Ice::OutputStreamPtr out = Ice::createOutputStream(communicator());
89
 
                out->writeString("The streaming API works!");
 
90
                out->write("The streaming API works!");
90
91
                out->finished(inParams);
91
92
 
92
93
                //
109
110
                arr.push_back("streaming");
110
111
                arr.push_back("API");
111
112
                arr.push_back("works!");
112
 
                out->writeStringSeq(arr);
 
113
                out->write(arr);
113
114
                out->finished(inParams);
114
115
 
115
116
                //
130
131
                Demo::StringDict dict;
131
132
                dict["The"] = "streaming";
132
133
                dict["API"] = "works!";
133
 
                Demo::ice_writeStringDict(out, dict);
 
134
                out->write(dict);
134
135
                out->finished(inParams);
135
136
 
136
137
                //
148
149
                //
149
150
                Ice::ByteSeq inParams, outParams;
150
151
                Ice::OutputStreamPtr out = Ice::createOutputStream(communicator());
151
 
                Demo::ice_writeColor(out, Demo::green);
 
152
                out->write(Demo::green);
152
153
                out->finished(inParams);
153
154
 
154
155
                //
169
170
                Demo::Structure s;
170
171
                s.name = "red";
171
172
                s.value = Demo::red;
172
 
                Demo::ice_writeStructure(out, s);
 
173
                out->write(s);
173
174
                out->finished(inParams);
174
175
 
175
176
                //
197
198
                arr.push_back(Demo::Structure());
198
199
                arr.back().name = "blue";
199
200
                arr.back().value = Demo::blue;
200
 
                Demo::ice_writeStructureSeq(out, arr);
 
201
                out->write(arr);
201
202
                out->finished(inParams);
202
203
 
203
204
                //
218
219
                Demo::CPtr c = new Demo::C;
219
220
                c->s.name = "blue";
220
221
                c->s.value = Demo::blue;
221
 
                Demo::ice_writeC(out, c);
 
222
                out->write(c);
222
223
                out->writePendingObjects();
223
224
                out->finished(inParams);
224
225
 
247
248
                //
248
249
                Ice::InputStreamPtr in = Ice::createInputStream(communicator(), outParams);
249
250
                Demo::CPtr c;
250
 
                Demo::ice_readC(in, c);
251
 
                string str = in->readString();
 
251
                in->read(c);
 
252
                string str;
 
253
                in->read(str);
252
254
                in->readPendingObjects();
253
255
                cout << "Got string `" << str << "' and class: s.name=" << c->s.name
254
256
                     << ", s.value=" << c->s.value << endl;