File: XmlRpcClass.cpp

package info (click to toggle)
xmlrpc-c 1.06.27-1.1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 4,308 kB
  • ctags: 5,111
  • sloc: ansic: 39,324; sh: 8,284; cpp: 6,051; makefile: 1,339; perl: 494; xml: 134
file content (78 lines) | stat: -rw-r--r-- 2,173 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <iostream>
#include <stdexcept>
#include <vector>

using namespace std;

#include "xmlrpc-c/oldcppwrapper.hpp"

#include "DataType.hpp"
#include "XmlRpcFunction.hpp"
#include "XmlRpcClass.hpp"


//=========================================================================
//  XmlRpcClass
//=========================================================================
//  This class stores information about a proxy class, and knows how to
//  generate code.

XmlRpcClass::XmlRpcClass (string class_name)
    : mClassName(class_name)
{
}

XmlRpcClass::XmlRpcClass (const XmlRpcClass& c)
    : mClassName(c.mClassName),
      mFunctions(c.mFunctions)
{
}

XmlRpcClass& XmlRpcClass::operator= (const XmlRpcClass& c)
{
    if (this == &c)
	return *this;
    mClassName = c.mClassName;
    mFunctions = c.mFunctions;
    return *this;
}

void XmlRpcClass::addFunction (const XmlRpcFunction& function)
{
    mFunctions.push_back(function);
}

void XmlRpcClass::printDeclaration (ostream&)
{
    cout << "class " << mClassName << " {" << endl;
    cout << "    XmlRpcClient mClient;" << endl;
    cout << endl;
    cout << "public:" << endl;
    cout << "    " << mClassName << " (const XmlRpcClient& client)" << endl;
    cout << "        : mClient(client) {}" << endl;
    cout << "    " << mClassName << " (const string& server_url)" << endl;
    cout << "        : mClient(XmlRpcClient(server_url)) {}" << endl;
    cout << "    " << mClassName << " (const " << mClassName << "& o)" << endl;
    cout << "        : mClient(o.mClient) {}" << endl;
    cout << endl;
    cout << "    " << mClassName << "& operator= (const "
	 << mClassName << "& o) {" << endl;
    cout << "        if (this != &o) mClient = o.mClient;" << endl;
    cout << "        return *this;" << endl;
    cout << "    }" << endl;

    vector<XmlRpcFunction>::iterator f;
    for (f = mFunctions.begin(); f < mFunctions.end(); ++f) {
	f->printDeclarations(cout);
    }

    cout << "};" << endl;    
}

void XmlRpcClass::printDefinition (ostream&)
{
    vector<XmlRpcFunction>::iterator f;
    for (f = mFunctions.begin(); f < mFunctions.end(); ++f) {
	f->printDefinitions(cout, mClassName);
    }
}