コード例 #1
0
ファイル: factory.hpp プロジェクト: DmitrySigaev/ncbi
int CFactory<Type>::CgiFactory(const TCgiEntries& Cgi,
                               SFactoryList<Type>* List)
{
    int i = 0;
    TCgiEntriesCI iRange, iPageCgi;
    pair<TCgiEntriesCI, TCgiEntriesCI> Range;
    TCgiEntries PageCgi;

    while ( !string(List[i].MatchString).empty() ) {
        PageCgi.erase(PageCgi.begin(), PageCgi.end());
        // Parse the MatchString
        CCgiRequest::ParseEntries(List[i].MatchString, PageCgi);
        bool ThisPage = true;
        for ( iPageCgi = PageCgi.begin(); iPageCgi != PageCgi.end(); iPageCgi++) { 
            Range = Cgi.equal_range(iPageCgi->first);
            for ( iRange = Range.first; iRange != Range.second; iRange++ ) {
                if ( iRange->second == iPageCgi->second)
                    goto equality;
                if ( iPageCgi->second.empty())
                    goto equality;  // wildcard
            }
            ThisPage = false;
        equality:
            ;
        }
        if ( ThisPage ) {
            break;
        }
        i++;
    }
    return i;
}
コード例 #2
0
int main(int argc, char *argv[]) 
{
    CCgiRequest Request(argc, argv);
    CCgiResponse Response;

    // write out the Content-type header
    Response.WriteHeader();

    // Get the multimap.  see http://www.sgi.com/Technology/STL/Multimap.html
    // on how to manipulate multimaps
    TCgiEntries Entries = Request.GetEntries();

    // this program expects queries of the form cgidemo?name=Fred
    // the following line extracts the "Fred"
    string Name;
    TCgiEntries::const_iterator iName = Entries.find("name");
    if (iName == Entries.end()) Name = "World"; 
    else Name = iName->second;

    // print out the results
    Response.out() << "<html><body>Hello, " << Name;
    Response.out() << "</body></html>" << endl;
    Response.Flush();

    return 0;  
}
コード例 #3
0
string s_GetRequestParam(const TCgiEntries &entries,const string &paramName)
{
    string param = "";

    TCgiEntries::const_iterator iter  = entries.find(paramName);
    
    if (iter != entries.end()){
        param = iter->second;        
    }  
    return param;
}