2022-02-12 Fred Gleason <fredg@paravelsystems.com>

* Added CSV generation routines in 'lib/rdcsv.[cpp|h]'.
	* Added a 'Log Listing (CSV)' report to rdlogedit(1).

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2022-02-12 11:54:28 -05:00
parent b778114266
commit 1fd581a442
7 changed files with 237 additions and 6 deletions

View File

@@ -2,7 +2,7 @@
##
## Automake.am for rivendell/lib
##
## (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com>
## (C) Copyright 2002-2022 Fred Gleason <fredg@paravelsystems.com>
##
## 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
@@ -98,6 +98,7 @@ dist_librd_la_SOURCES = dbversion.h\
rdconfig.cpp rdconfig.h\
rdcopyaudio.cpp rdcopyaudio.h\
rdcoreapplication.cpp rdcoreapplication.h\
rdcsv.cpp rdcsv.h\
rdcueedit.cpp rdcueedit.h\
rdcueeditdialog.cpp rdcueeditdialog.h\
rdcut.cpp rdcut.h\

View File

@@ -2,7 +2,7 @@
#
# The lib/ QMake project file for Rivendell.
#
# (C) Copyright 2003-2021 Fred Gleason <fredg@paravelsystems.com>
# (C) Copyright 2003-2022 Fred Gleason <fredg@paravelsystems.com>
#
# 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
@@ -70,6 +70,7 @@ SOURCES += rdcombobox.cpp
SOURCES += rdconf.cpp
SOURCES += rdconfig.cpp
SOURCES += rdcoreapplication.cpp
SOURCES += rdcsv.cpp
SOURCES += rdcueedit.cpp
SOURCES += rdcueeditdialog.cpp
SOURCES += rdcut.cpp
@@ -259,6 +260,7 @@ HEADERS += rdcombobox.h
HEADERS += rdconf.h
HEADERS += rdconfig.h
HEADERS += rdcoreapplication.h
HEADERS += rdcsv.h
HEADERS += rdcueedit.h
HEADERS += rdcueeditdialog.h
HEADERS += rdcut_dialog.h

50
lib/rdcsv.cpp Normal file
View File

@@ -0,0 +1,50 @@
// rdcsv.cpp
//
// Routines for generating CSV files
//
// (C) Copyright 2022 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include "rdcsv.h"
QString RDCsvField(const QString &val,bool last)
{
QString ret=val;
if(val.contains(",")||val.contains("\"")) {
ret="\""+ret.replace("\"","\"\"")+"\"";
}
if(last) {
ret+="\r\n";
}
else {
ret+=",";
}
return ret;
}
QString RDCsvField(int val,bool last)
{
return RDCsvField(QString::asprintf("%d",val),last);
}
QString RDCsvField(unsigned val,bool last)
{
return RDCsvField(QString::asprintf("%u",val),last);
}

31
lib/rdcsv.h Normal file
View File

@@ -0,0 +1,31 @@
// rdcsv.h
//
// Routines for generating CSV files
//
// (C) Copyright 2022 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#ifndef RDCSV_H
#define RDCSV_H
#include <QString>
QString RDCsvField(const QString &val="",bool last=false);
QString RDCsvField(int val,bool last=false);
QString RDCsvField(unsigned val,bool last=false);
#endif // RDCSV_H