2
0

XmlRpcClass.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #include <iostream>
  2. #include <stdexcept>
  3. #include <vector>
  4. using namespace std;
  5. #include "xmlrpc-c/oldcppwrapper.hpp"
  6. #include "DataType.hpp"
  7. #include "XmlRpcFunction.hpp"
  8. #include "XmlRpcClass.hpp"
  9. XmlRpcClass::XmlRpcClass(string const& className) :
  10. mClassName(className) {}
  11. XmlRpcClass::XmlRpcClass(XmlRpcClass const& c) :
  12. mClassName(c.mClassName),
  13. mFunctions(c.mFunctions) {}
  14. XmlRpcClass&
  15. XmlRpcClass::operator= (XmlRpcClass const& c) {
  16. if (this != &c) {
  17. this->mClassName = c.mClassName;
  18. this->mFunctions = c.mFunctions;
  19. }
  20. return *this;
  21. }
  22. void
  23. XmlRpcClass::addFunction(XmlRpcFunction const& function) {
  24. mFunctions.push_back(function);
  25. }
  26. void
  27. XmlRpcClass::printDeclaration(ostream & out) const {
  28. out << "class " << mClassName << " {" << endl;
  29. out << " XmlRpcClient mClient;" << endl;
  30. out << endl;
  31. out << "public:" << endl;
  32. out << " " << mClassName << " (const XmlRpcClient& client)" << endl;
  33. out << " : mClient(client) {}" << endl;
  34. out << " " << mClassName << " (const std::string& server_url)" << endl;
  35. out << " : mClient(XmlRpcClient(server_url)) {}" << endl;
  36. out << " " << mClassName << " (const " << mClassName << "& o)" << endl;
  37. out << " : mClient(o.mClient) {}" << endl;
  38. out << endl;
  39. out << " " << mClassName << "& operator= (const "
  40. << mClassName << "& o) {" << endl;
  41. out << " if (this != &o) mClient = o.mClient;" << endl;
  42. out << " return *this;" << endl;
  43. out << " }" << endl;
  44. vector<XmlRpcFunction>::const_iterator f;
  45. for (f = mFunctions.begin(); f < mFunctions.end(); ++f) {
  46. f->printDeclarations(out);
  47. }
  48. out << "};" << endl;
  49. }
  50. void
  51. XmlRpcClass::printDefinition(ostream & out) const {
  52. vector<XmlRpcFunction>::const_iterator f;
  53. for (f = mFunctions.begin(); f < mFunctions.end(); ++f) {
  54. f->printDefinitions(out, mClassName);
  55. }
  56. }