mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-07-15 08:07:43 +02:00
2024-04-02 Fred Gleason <fredg@paravelsystems.com>
* Removed JSON generation methods. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
parent
5e61a36076
commit
afe00c12f4
@ -24690,3 +24690,5 @@
|
|||||||
* Refactored the PAD subsystem to use native Qt JSON methods.
|
* Refactored the PAD subsystem to use native Qt JSON methods.
|
||||||
2024-04-02 Fred Gleason <fredg@paravelsystems.com>
|
2024-04-02 Fred Gleason <fredg@paravelsystems.com>
|
||||||
* Modified the Sound Panel classes to use native Qt JSON methods.
|
* Modified the Sound Panel classes to use native Qt JSON methods.
|
||||||
|
2024-04-02 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Removed JSON generation methods.
|
||||||
|
159
lib/rdweb.cpp
159
lib/rdweb.cpp
@ -3,7 +3,7 @@
|
|||||||
// Functions for interfacing with web components using the
|
// Functions for interfacing with web components using the
|
||||||
// Common Gateway Interface (CGI) Standard
|
// Common Gateway Interface (CGI) Standard
|
||||||
//
|
//
|
||||||
// (C) Copyright 1996-2021 Fred Gleason <fredg@paravelsystems.com>
|
// (C) Copyright 1996-2024 Fred Gleason <fredg@paravelsystems.com>
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License version 2 as
|
||||||
@ -195,163 +195,6 @@ QString RDXmlUnescape(const QString &str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString RDJsonPadding(int padding)
|
|
||||||
{
|
|
||||||
QString ret="";
|
|
||||||
|
|
||||||
for(int i=0;i<padding;i++) {
|
|
||||||
ret+=" ";
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString RDJsonEscape(const QString &str)
|
|
||||||
{
|
|
||||||
QString ret;
|
|
||||||
|
|
||||||
for(int i=0;i<str.length();i++) {
|
|
||||||
QChar c=str.at(i);
|
|
||||||
switch(c.category()) {
|
|
||||||
case QChar::Other_Control:
|
|
||||||
ret+=QString::asprintf("\\u%04X",c.unicode());
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
switch(c.unicode()) {
|
|
||||||
case 0x22: // Quote
|
|
||||||
ret+="\\\"";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x5C: // Backslash
|
|
||||||
ret+="\\\\";
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
ret+=c;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString RDJsonNullField(const QString &name,int padding,bool final)
|
|
||||||
{
|
|
||||||
QString comma=",";
|
|
||||||
|
|
||||||
if(final) {
|
|
||||||
comma="";
|
|
||||||
}
|
|
||||||
|
|
||||||
return RDJsonPadding(padding)+"\""+name+"\": null"+comma+"\r\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString RDJsonField(const QString &name,bool value,int padding,bool final)
|
|
||||||
{
|
|
||||||
QString comma=",";
|
|
||||||
|
|
||||||
if(final) {
|
|
||||||
comma="";
|
|
||||||
}
|
|
||||||
|
|
||||||
if(value) {
|
|
||||||
return RDJsonPadding(padding)+"\""+name+"\": true"+comma+"\r\n";
|
|
||||||
}
|
|
||||||
return RDJsonPadding(padding)+"\""+name+"\": false"+comma+"\r\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString RDJsonField(const QString &name,int value,int padding,bool final)
|
|
||||||
{
|
|
||||||
QString comma=",";
|
|
||||||
|
|
||||||
if(final) {
|
|
||||||
comma="";
|
|
||||||
}
|
|
||||||
|
|
||||||
return RDJsonPadding(padding)+"\""+name+"\": "+QString::asprintf("%d",value)+
|
|
||||||
comma+"\r\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString RDJsonField(const QString &name,unsigned value,int padding,bool final)
|
|
||||||
{
|
|
||||||
QString comma=",";
|
|
||||||
|
|
||||||
if(final) {
|
|
||||||
comma="";
|
|
||||||
}
|
|
||||||
|
|
||||||
return RDJsonPadding(padding)+"\""+name+"\": "+QString::asprintf("%u",value)+
|
|
||||||
comma+"\r\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString RDJsonField(const QString &name,const QString &value,int padding,
|
|
||||||
bool final)
|
|
||||||
{
|
|
||||||
QString ret;
|
|
||||||
QString comma=",";
|
|
||||||
|
|
||||||
if(final) {
|
|
||||||
comma="";
|
|
||||||
}
|
|
||||||
|
|
||||||
ret=RDJsonEscape(value);
|
|
||||||
/*
|
|
||||||
for(int i=0;i<value.length();i++) {
|
|
||||||
QChar c=value.at(i);
|
|
||||||
switch(c.category()) {
|
|
||||||
case QChar::Other_Control:
|
|
||||||
ret+=QString::asprintf("\\u%04X",c.unicode());
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
switch(c.unicode()) {
|
|
||||||
case 0x22: // Quote
|
|
||||||
ret+="\\\"";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x5C: // Backslash
|
|
||||||
ret+="\\\\";
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
ret+=c;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
return RDJsonPadding(padding)+"\""+name+"\": \""+ret+"\""+comma+"\r\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString RDJsonField(const QString &name,const QDateTime &value,int padding,
|
|
||||||
bool final)
|
|
||||||
{
|
|
||||||
QString comma=",";
|
|
||||||
|
|
||||||
if(final) {
|
|
||||||
comma="";
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!value.isValid()) {
|
|
||||||
return RDJsonNullField(name,padding,final);
|
|
||||||
}
|
|
||||||
return RDJsonPadding(padding)+"\""+name+"\": \""+
|
|
||||||
RDWriteXmlDateTime(value)+"\""+
|
|
||||||
comma+"\r\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString RDUrlEscape(const QString &str)
|
QString RDUrlEscape(const QString &str)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
16
lib/rdweb.h
16
lib/rdweb.h
@ -3,7 +3,7 @@
|
|||||||
// Functions for interfacing with web components using the
|
// Functions for interfacing with web components using the
|
||||||
// Common Gateway Interface (CGI) Standard
|
// Common Gateway Interface (CGI) Standard
|
||||||
//
|
//
|
||||||
// (C) Copyright 1996-2021 Fred Gleason <fredg@paravelsystems.com>
|
// (C) Copyright 1996-2024 Fred Gleason <fredg@paravelsystems.com>
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License version 2 as
|
||||||
@ -53,20 +53,6 @@ extern QString RDXmlField(const QString &tag,const QTime &value,
|
|||||||
extern QString RDXmlField(const QString &tag);
|
extern QString RDXmlField(const QString &tag);
|
||||||
extern QString RDXmlEscape(const QString &str);
|
extern QString RDXmlEscape(const QString &str);
|
||||||
extern QString RDXmlUnescape(const QString &str);
|
extern QString RDXmlUnescape(const QString &str);
|
||||||
extern QString RDJsonPadding(int padding);
|
|
||||||
extern QString RDJsonEscape(const QString &str);
|
|
||||||
extern QString RDJsonNullField(const QString &name,int padding=0,
|
|
||||||
bool final=false);
|
|
||||||
extern QString RDJsonField(const QString &name,bool value,int padding=0,
|
|
||||||
bool final=false);
|
|
||||||
extern QString RDJsonField(const QString &name,int value,int padding=0,
|
|
||||||
bool final=false);
|
|
||||||
extern QString RDJsonField(const QString &name,unsigned value,int padding=0,
|
|
||||||
bool final=false);
|
|
||||||
extern QString RDJsonField(const QString &name,const QString &value,
|
|
||||||
int padding=0,bool final=false);
|
|
||||||
extern QString RDJsonField(const QString &name,const QDateTime &value,
|
|
||||||
int padding=0,bool final=false);
|
|
||||||
extern QString RDUrlEscape(const QString &str);
|
extern QString RDUrlEscape(const QString &str);
|
||||||
extern QString RDUrlUnescape(const QString &str);
|
extern QString RDUrlUnescape(const QString &str);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user