473,383 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

[Linker error] undefined reference to `CGI::query'

Damn, what's wrong here?

CGI cgi;
map<string,stringcgiParam = cgi.analyseCgiParam();
cout << cgiParam["plz1"] << endl;
cout << cgiParam["vorname1"] << endl;

///////////////////////

#include <iostream>
#include <string>
#include <list>
#include <map>
#include <sstream>
using namespace std;

class CGI
{
private:
static std::string query;
char* input;
const char **names;
const char **values;
int number;
int val;
protected:
public:
list<stringsplit(string str, char tr)
{
list<stringstrElemente; // Ergebnis: Liste von Teilstrings
string::iterator pos1, // Anfang/Ende von
pos2; // Teilstrings
pos1 = str.begin(); // Beginn eines Teilstrings
pos2 = find (pos1, str.end(), tr); // Ende eines Teilstrings
while ( pos2 != str.end())
{
// Trenner als Ende gefunden
assert(*pos2==tr);
string elem; // Teilstring
copy (pos1, pos2, back_inserter(elem)); // Teilstring kopieren
strElemente.push_back(elem); // Teilstring speichern
pos1 = pos2;
++pos1; // neuer Anfang hinter altem Ende
pos2 = find (pos1, str.end(), tr); // neue Suche
}
// pos2 zeigt auf das Ende. pos1 zeigt auf den Beginn
// des letzten Teilstrings vor dem Ende.
// Letzten Teilstring extrahieren:
//
string last;
copy (pos1, str.end(), back_inserter(last));
strElemente.push_back(last);
return strElemente;
}
map<string, stringanalyseCgiParam()
{
std::string meth_s = null_to_empty(std::getenv("REQUEST_METHOD"));
if (meth_s == "")
{
cout << "EMPTY" << endl;
}
else if (meth_s == "GET")
{
query = null_to_empty(getenv("QUERY_STRING"));
cout << "GET" << endl;
cout << query << endl;
}
else if (meth_s == "POST")
{
int len = atoi(getenv("CONTENT_LENGTH"));
// MIME getenv("CONTENT_TYPE") application/x-www-form-urlencoded
//std::string input[len+1];
input = new char[len+1];
fread(input, 1, len, stdin);
input[len] = 0;
cout << "POST" << endl;
query = input;
cout << query << endl;
delete input;
//fflush ( stdin );
}
else cout << "NONE" << endl;
list<stringfeldListe = split(query, '&'); // in Felder zerlegen
map<string,stringfelder; // Ergebnis
// Felder in Paare aus Feldnamen und Wert splitten
for ( list<string>::iterator i = feldListe.begin(); i !=
feldListe.end(); ++i)
{
list<stringfeldStr = split(*i, '=');
pair< string, string feld;
feld.first = feldStr.front(); // Feldname
feldStr.pop_front();
feld.second = feldStr.front(); // Feldwert
felder[feld.first] = feld.second; // Paar speichern
}
return felder; // Abbildung Feld-Name -Feld-Wert zurueck geben
}
inline const char * null_to_empty(const char * str)
{
if (! str)
return "";
return str;
}
int string2Int(string str)
{
istringstream istr (str);
int i;
istr >i;
return i;
}
CGI()
{
}
virtual ~CGI()
{
}
};
Nov 29 '06 #1
1 2686
"Oliver Bleckmann" <Ol**************@freenet.dewrites:
Damn, what's wrong here?

CGI cgi;
map<string,stringcgiParam = cgi.analyseCgiParam();
cout << cgiParam["plz1"] << endl;
cout << cgiParam["vorname1"] << endl;

///////////////////////

#include <iostream>
#include <string>
#include <list>
#include <map>
#include <sstream>
using namespace std;

class CGI
{
private:
static std::string query;
^^^^
Here you declare a static variable. Somewhere in your program in a
compile unit you must also define and initialize it, like a global
variable.

[snipped rest of posted code]

somewhere in a .cc:

std::string CGI::query = "";

HTH,
Rudiger
Nov 30 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jeremy | last post by:
In IIS5 with ASP when I try to run an SSI command: <!--#include virtual="/asp_scripts/template.asp?section=1&sub=Main" --> I get "404 Object Not Found" But if I remove the query string like...
3
by: Jeremy | last post by:
Is this possible - I imagine so but cannot at the moment fathom out how to do it! Entering into the URL field in a browser the name of a cgi program like this: http://myserver/cgi-bin/prog ...
0
by: M Fadhilah via DBMonster.com | last post by:
Dear All, I am newbie in postgresql, i am using postgressql 8.0 for windows and i try using crosstab for my table. my table structure is account_id text account_parent text...
0
by: jgabbai | last post by:
Hi, I am looking to pick up the relationship between items in a cross-reference table. For example, searching for c OR f (bracketed below to highlight them), I want to list the other right hand...
3
by: maffonso | last post by:
Hi guys, I have built a cross reference query (columns is year). I would like to change the caption and adjust others things. The best way would be to wrap the query in a form, but soon 2007 will...
1
by: chitara | last post by:
is there any posibility to block mysql port or someting? I am getting "Error ,query failed" during adding any data through the admin panel of that website:-( same softwares(php, mysql and IIS)...
0
by: chetankhatri | last post by:
Hi Everybody, I have just joined this community, i hope you all will give me instant reply to my question.... I have a query related to Exchange Server 2003 EnterPrise Edition. Whenever...
5
by: jaishu | last post by:
Hi , I am using a form based on a query. The form is locked and the fields are not editable, but when i just tried typing something, the contents on the form didnt change, but when i closed and...
1
by: daver28 | last post by:
Can anyone help with this error as I know very little ASP and even less French! Roughly translated it states 'Index table is outside the limits' Objet Request erreur 'ASP 0105 : 80004005' ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.