diff --git a/ChangeLog b/ChangeLog index 04b06c31..2a388abf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20468,3 +20468,5 @@ * Added a 'RDApplication::logAuthenticationFailure()' method. * Added a sample Fail2Ban jail filter for the WebAPI in 'conf/rivendell-webapi.conf'. +2020-10-15 Fred Gleason + * Modified 'RDFormPost' to use 'QMap' instead of 'std::map'. diff --git a/lib/rdformpost.cpp b/lib/rdformpost.cpp index 269aeb2f..d1369e6a 100644 --- a/lib/rdformpost.cpp +++ b/lib/rdformpost.cpp @@ -2,7 +2,7 @@ // // Handle data from an HTML form. // -// (C) Copyright 2009 Fred Gleason +// (C) Copyright 2009-2020 Fred Gleason // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as @@ -123,10 +123,10 @@ RDFormPost::RDFormPost(RDFormPost::Encoding encoding,unsigned maxsize, RDFormPost::~RDFormPost() { if(post_auto_delete) { - for(std::map::const_iterator ci=post_filenames.begin(); + for(QMap::const_iterator ci=post_filenames.begin(); ci!=post_filenames.end();ci++) { - if(ci->second) { - unlink(post_values.at(ci->first).toString()); + if(ci.value()) { + unlink(post_values.value(ci.key()).toString()); } } if(post_tempdir!=NULL) { @@ -154,9 +154,9 @@ QHostAddress RDFormPost::clientAddress() const QStringList RDFormPost::names() const { QStringList list; - for(std::map::const_iterator ci=post_values.begin(); + for(QMap::const_iterator ci=post_values.begin(); ci!=post_values.end();ci++) { - list.push_back(ci->first); + list.push_back(ci.key()); } return list; } @@ -166,7 +166,7 @@ QVariant RDFormPost::value(const QString &name,bool *ok) { QVariant v; if(post_values.count(name)>0) { - v=post_values.at(name); + v=post_values.value(name); } if(ok!=NULL) { *ok=(post_values.count(name)>0); @@ -193,7 +193,7 @@ bool RDFormPost::getValue(const QString &name,QHostAddress *addr,bool *ok) bool RDFormPost::getValue(const QString &name,QString *str,bool *ok) { if(post_values.count(name)>0) { - *str=post_values.at(name).toString(); + *str=post_values.value(name).toString(); return true; } return false; @@ -203,7 +203,7 @@ bool RDFormPost::getValue(const QString &name,QString *str,bool *ok) bool RDFormPost::getValue(const QString &name,int *n,bool *ok) { if(post_values.count(name)>0) { - *n=post_values.at(name).toInt(ok); + *n=post_values.value(name).toInt(ok); return true; } return false; @@ -213,7 +213,7 @@ bool RDFormPost::getValue(const QString &name,int *n,bool *ok) bool RDFormPost::getValue(const QString &name,long *n,bool *ok) { if(post_values.count(name)>0) { - *n=post_values.at(name).toLongLong(ok); + *n=post_values.value(name).toLongLong(ok); return true; } *n=0; @@ -224,7 +224,7 @@ bool RDFormPost::getValue(const QString &name,long *n,bool *ok) bool RDFormPost::getValue(const QString &name,unsigned *n,bool *ok) { if(post_values.count(name)>0) { - *n=post_values.at(name).toUInt(ok); + *n=post_values.value(name).toUInt(ok); return true; } return false; @@ -303,7 +303,7 @@ bool RDFormPost::getValue(const QString &name,QTime *time,bool *ok) bool RDFormPost::getValue(const QString &name,bool *state,bool *ok) { if(post_values.count(name)>0) { - *state=post_values.at(name).toInt(ok); + *state=post_values.value(name).toInt(ok); return true; } return false; @@ -349,13 +349,13 @@ void RDFormPost::dump() printf("FILE\n"); printf("\n"); - for(std::map::const_iterator ci=post_values.begin(); + for(QMap::const_iterator ci=post_values.begin(); ci!=post_values.end();ci++) { printf("\n"); - printf("|%s|\n",(const char *)ci->first.utf8()); + printf("|%s|\n",ci.key().toUtf8().constData()); printf("|%s|\n", - (const char *)ci->second.toString().utf8()); - if(post_filenames[ci->first]) { + ci.value().toString().toUtf8().constData()); + if(post_filenames[ci.key()]) { printf("Yes\n"); } else { diff --git a/lib/rdformpost.h b/lib/rdformpost.h index 9b3c9466..8e650118 100644 --- a/lib/rdformpost.h +++ b/lib/rdformpost.h @@ -2,7 +2,7 @@ // // Handle POST data from an HTML form. // -// (C) Copyright 2009-2018 Fred Gleason +// (C) Copyright 2009-2020 Fred Gleason // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as @@ -21,13 +21,12 @@ #ifndef RDFORMPOST_H #define RDFORMPOST_H -#include - -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include @@ -71,8 +70,8 @@ class RDFormPost QHostAddress post_client_address; RDFormPost::Encoding post_encoding; RDFormPost::Error post_error; - std::map post_values; - std::map post_filenames; + QMap post_values; + QMap post_filenames; RDTempDirectory *post_tempdir; bool post_auto_delete; unsigned post_content_length;