qt-interest@trolltech.com
[Top] [All Lists]

Re: undefined reference to vtable...

Subject: Re: undefined reference to vtable...
From:
Date: Wed, 02 Nov 2005 15:00:51 +0100
Caleb Tennis wrote:


> There's not much I can say without seeing the code (at least, the .h) for
> MachineServer.
:-) Just posted it in reply to another of your posts.

Source is below and it is generated by an inhouse tool.

Thanks, 
 Morten 


Header: 
#ifndef MACHINESERVER_H
#define MACHINESERVER_H

#include <string>
#include <vector>

class MachineServer {

private:
 std::string host;
 int port;

public:
 MachineServer(std::string host, int port);
 ~MachineServer();

 void test();
 std::string getForm(const std::string &form);

};

#endif /* MACHINESERVER_H */


Source:


#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
#include <network/connection.h>
#include <network/connexcept.h>
#include <network/xmlserver.h>
#include <reportings/runtimeexception.h>
#include <string>
#include <vector>
#include <ostream>

#include "machineserver.client.h"

using namespace std;

static void reservedCharsToXml(std::string &s) {
 std::string copy = s;
 s = "";
 for(long long int i=0; i < copy.length(); i++) {
  if(copy[i] == '&') {
   s += "&amp;";
  }
  else if(copy[i] == '<') {
   s += "&lt;";
  }
  else if(copy[i] == '>') {
   s += "&gt;";
  }  
  else {
   s += copy[i];
  } 
 }
}

static void xmlToReservedChars(std::string &s) {
 std::string copy = s;
 s = "";
 for(long long int i=0; i < copy.length(); i++) {
  if(copy[i] == '&') {
   if(copy[i+1] == 'a' && copy[i+2] == 'm' && copy[i+3] == 'p' && copy[i+4]
== ';') {
    s += "&";
    i+=4;   
   }
   if(copy[i+1] == 'g' && copy[i+2] == 't' && copy[i+3] == ';') {
    s += ">";
    i+=3;   
   }
   if(copy[i+1] == 'l' && copy[i+2] == 't' && copy[i+3] == ';') {
    s += "<";
    i+=3;   
   }
  }
  else {
   s += copy[i];
  }
 }
}

MachineServer::MachineServer(string host, int port)  {
 this->host = host;
 this->port = port;
}

MachineServer::~MachineServer() { }

void MachineServer::test() {
 char tempc[100];
 char *__enrig_cp;
 tempc[0] = 1; //To please compiler.
 int ec;
 ec = 1; //To please compiler.
 string xml, target;
 xml += "<invoke method=\"test\">\n";
 xml += "</invoke>";
 try {
  Connection server("MachineServer(Client)", host, port);
  server.setDebugLevel(0);
  server << xml;
  server >> xml;
 } catch(ConnectionException &ce) {
  throw new RuntimeException(1,
"MachineServer(client)::test():"+ce.toString());
 }
 if(xml == "") {
 throw new RuntimeException(1, "RemoteService(client)::setString(): Received
empty reply from server.");
 }
 xmlDocPtr doc;
 xmlNodePtr root;
 doc = xmlParseMemory(xml.c_str(), strlen(xml.c_str()));
 root = xmlDocGetRootElement(doc);
 if(xmlStrEqual(root->name, (const xmlChar *) "invocation" )) {
  if(!xmlStrEqual(xmlGetProp(root, (xmlChar*)"method"), (const xmlChar *)
"test" )) {
   std::cout << "Reply didn't match invocation." << std::endl;
  }
  else {
   ec = XmlServer::xPathContent(doc, "/invocation/success", target);
   if(ec != 1) {
    throw new RuntimeException(1, "MachineServer(client)::test: Reply
missing <success> tag.");
   }
   else {
    if(target == "no") {
     throw new RuntimeException(1, "MachineServer(client)::test: Invocation
failed serverside.");
    }
    else {
    }
   }
  }
 }
 else {
  throw new RuntimeException(1, "MachineServer(client)::test: Reply is not
an <invocation> message.");
 }
}

std::string MachineServer::getForm(const std::string &form) {
 std::string rval;
 char tempc[100];
 char *__enrig_cp;
 tempc[0] = 1; //To please compiler.
 int ec;
 ec = 1; //To please compiler.
 string xml, target;
 xml += "<invoke method=\"getForm\">\n";
 std::string __enrig_d_form = form;
 reservedCharsToXml(__enrig_d_form);
 xml += string("\t<parameter
name=\"form\">")+__enrig_d_form+string("</parameter>\n");
 xml += "</invoke>";
 try {
  Connection server("MachineServer(Client)", host, port);
  server.setDebugLevel(0);
  server << xml;
  server >> xml;
 } catch(ConnectionException &ce) {
  throw new RuntimeException(1,
"MachineServer(client)::getForm():"+ce.toString());
 }
 if(xml == "") {
 throw new RuntimeException(1, "RemoteService(client)::setString(): Received
empty reply from server.");
 }
 xmlDocPtr doc;
 xmlNodePtr root;
 doc = xmlParseMemory(xml.c_str(), strlen(xml.c_str()));
 root = xmlDocGetRootElement(doc);
 if(xmlStrEqual(root->name, (const xmlChar *) "invocation" )) {
  if(!xmlStrEqual(xmlGetProp(root, (xmlChar*)"method"), (const xmlChar *)
"getForm" )) {
   std::cout << "Reply didn't match invocation." << std::endl;
  }
  else {
   ec = XmlServer::xPathContent(doc, "/invocation/success", target);
   if(ec != 1) {
    throw new RuntimeException(1, "MachineServer(client)::getForm: Reply
missing <success> tag.");
   }
   else {
    if(target == "no") {
     throw new RuntimeException(1, "MachineServer(client)::getForm:
Invocation failed serverside.");
    }
    else {
    }
   }
  }
 }
 else {
  throw new RuntimeException(1, "MachineServer(client)::getForm: Reply is
not an <invocation> message.");
 }
 ec = XmlServer::xPathContent(doc, "/invocation/returnvalue", target); 
 if(ec != 1) { 
  throw new RuntimeException(1, "MachineServer: Reply missing <returnvalue>
tag."); 
 } 
 else { 
  rval = target; 
 }
 xmlCleanupParser();
 xmlFreeDoc(doc);
 return rval;
}


--
To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
"unsubscribe" in the subject.
List archive and information: http://lists.trolltech.com/qt-interest/

<Prev in Thread] Current Thread [Next in Thread>