Habe jetzt den Konstruktor rausgenommen cgi.cpp in die klasse anfrage gesteckt jetzt kommt
gcc output:
Code:
ex.cpp:19: error: cannot call member function ‘std::string htmlformselect::formselect(std::string, std::string, std::string)’ without object
make: *** [all] Error 1
libhtml++.h
Code:
#include <iostream>
#include <string>
#include <sstream>
class cgi
{
public:
std::string anfrage(std::string methodform);
std::string formselectoutput;
std::string methodform;
};
class htmlformselect : public cgi
{
private:
std::string formselectinputprint;
std::string formselectname;
std::string formselectinput;
std::string formselectdisplay(std::string formselectname, std::string formselectinput, std::string methodform);
public:
std::string formselect(std::string formselectname, std::string formselectinput, std::string methodform);
};
formselect.cpp
Code:
#include <iostream>
#include <string>
#include <fstream>
#include <stdio.h>
#include <cstdlib>
#include "include/libhtml++.h"
using namespace std;
string htmlformselect::formselectdisplay (std::string formselectname, std::string formselectinput, std::string methodform)
{
formselectinputprint = formselectinput;
int pos = 0;
do
{
pos = formselectinputprint.find("[F]");
if(pos != string::npos)
formselectinputprint.replace(pos,strlen("[F]"),"<option>");
}
while(pos != string::npos);
do
{
pos = formselectinputprint.find("[/F]");
if(pos != string::npos)
formselectinputprint.replace(pos,strlen("[/F]"),"</option>");
}
while(pos != string::npos);
cout << "<select name=" << '"' << formselectname << '"' << formselectinputprint << "method=" << '"' << methodform << '"' << "action=" << '"' << "http://tuxist.de/cgi-bin/index.cgi" << '"' << ">" << endl;
}
string htmlformselect::formselect (std::string formselectname, std::string formselectinput, std::string methodform)
{
anfrage(methodform);
formselectdisplay(formselectname, formselectinput, methodform);
}
Code:
std::string cgi::anfrage(std::string methodform )
{
char* buffer = 0;
unsigned int len;
if (methodform == "GET")
{
len = strlen(getenv("QUERY_STRING"));
buffer = new char[len+1];
strcpy(buffer,getenv("QUERY_STRING"));
}
else if (methodform =="POST")
{
len = atoi(getenv("CONTENT_LENGTH"));
buffer = new char[len+1];
for(unsigned int i=0; i<len; i++)
cin.get(buffer[i]);
}
buffer[len] = 0;
formselectoutput = buffer;
delete[] buffer;
return formselectoutput;
}
index.cpp
Code:
#include <iostream>
#include "index.h"
#include <dlfcn.h>
#include <tuxcms/css.h>
#include <tuxcms/libhtml++.h>
#include <string>
using namespace std;
int main(int argc, char **argv)
{
string sitename;
sitename = "tuxist.de";
cout << "Content-Type:text/html\n\n" << endl
<< "<html>" << endl
<< "<head>" << endl
<< "<title>" << sitename << "</title>" << endl
<< "</head>" << endl;
htmlformselect::formselect("Formselect1", "[F]Forminput[/F] [F]Forminput1[/F] [F]Forminput2[/F]", "GET");
cout << "<body>" << endl
<< "<h1><em>" << endl
<< "Im Aufbau" << endl
<< "</em></h1>" << endl
<< "</body>" << endl
<< "</html>"<< endl;
}
Lesezeichen