proxyClass.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #include <iostream>
  2. #include <stdexcept>
  3. #include <vector>
  4. using namespace std;
  5. #include "xmlrpc-c/client_simple.hpp"
  6. #include "xmlrpcType.hpp"
  7. #include "xmlrpcMethod.hpp"
  8. #include "proxyClass.hpp"
  9. proxyClass::proxyClass(string const& className) :
  10. _className(className) {}
  11. proxyClass::proxyClass(proxyClass const& c) :
  12. _className(c._className),
  13. functions(c.functions) {}
  14. string
  15. proxyClass::className() const {
  16. return this->_className;
  17. }
  18. void
  19. proxyClass::addFunction(xmlrpcMethod const& function) {
  20. functions.push_back(function);
  21. }
  22. void
  23. proxyClass::printDeclaration(ostream & out) const {
  24. out << "class " << this->_className << " {" << endl;
  25. out << endl;
  26. out << "public:" << endl;
  27. // emit the constructor prototype:
  28. out << " " << this->_className << "(std::string const& serverUrl) "
  29. << endl
  30. << " : serverUrl(serverUrl) {}"
  31. << endl;
  32. // emit the XML-RPC method method prototypes:
  33. vector<xmlrpcMethod>::const_iterator f;
  34. for (f = this->functions.begin(); f < this->functions.end(); ++f) {
  35. f->printDeclarations(out);
  36. }
  37. // emit the private data:
  38. out << "private:" << endl;
  39. out << " xmlrpc_c::clientSimple client;" << endl;
  40. out << " std::string const serverUrl;" << endl;
  41. out << " // The URL for the server for which we are proxy" << endl;
  42. // emit the class closing:
  43. out << "};" << endl;
  44. }
  45. void
  46. proxyClass::printDefinition(ostream & out) const {
  47. vector<xmlrpcMethod>::const_iterator f;
  48. for (f = this->functions.begin(); f < this->functions.end(); ++f) {
  49. f->printDefinitions(out, this->_className);
  50. }
  51. }