Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) TestQrcFile

 

TestQrcFile is a tool to test the QrcFile class.

 

 

 

 

 

Downloads

 

Technical facts

 

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ./ToolTestQrcFile/ToolTestQrcFileConsole.pro

 

include(../../ConsoleApplication.pri)

include(../../Libraries/Boost.pri)

include(../../Classes/CppAbout/CppAbout.pri)
include(../../Classes/CppFileIo/CppFileIo.pri)
include(../../Classes/CppHelp/CppHelp.pri)
include(../../Classes/CppMenuDialog/CppMenuDialog.pri)
include(../../Classes/CppRichelBilderbeekProgram/CppRichelBilderbeekProgram.pri)
include(../../Classes/CppTrace/CppTrace.pri)

#Specific, console
include(../../Classes/CppQtCreatorProFile/CppQtCreatorProFile.pri)
include(../../Classes/CppQrcFile/CppQrcFile.pri)

include(../../Tools/ToolTestQrcFile/ToolTestQrcFileConsole.pri)

SOURCES += main.cpp

 

 

 

 

 

Qt project file: ./ToolTestQrcFile/ToolTestQrcFileDesktop.pro

 

include(../../DesktopApplication.pri)

include(../../Libraries/Boost.pri)
include(../../Libraries/GeneralConsole.pri)
include(../../Libraries/GeneralDesktop.pri)

#Specific for this application
include(../../Classes/CppQtCreatorProFile/CppQtCreatorProFile.pri)
include(../../Classes/CppQrcFile/CppQrcFile.pri)
include(../../Tools/ToolTestQrcFile/ToolTestQrcFileDesktop.pri)

SOURCES += qtmain.cpp

 

 

 

 

 

./ToolTestQrcFile/ToolTestQrcFileConsole.pri

 

INCLUDEPATH += \
    ../../Tools/ToolTestQrcFile

SOURCES += \
    ../../Tools/ToolTestQrcFile/testqrcfilemenudialog.cpp

HEADERS += \
    ../../Tools/ToolTestQrcFile/testqrcfilemenudialog.h

OTHER_FILES += \
    ../../Tools/ToolTestQrcFile/Licence.txt

 

 

 

 

 

./ToolTestQrcFile/ToolTestQrcFileDesktop.pri

 

include(../../Tools/ToolTestQrcFile/ToolTestQrcFileConsole.pri)

RESOURCES += \
    ../../Tools/ToolTestQrcFile/ToolTestQrcFile.qrc

FORMS += \
    ../../Tools/ToolTestQrcFile/qttestqrcfilemenudialog.ui \
    ../../Tools/ToolTestQrcFile/qttestqrcfilemaindialog.ui

SOURCES += \
    ../../Tools/ToolTestQrcFile/qttestqrcfilemenudialog.cpp \
    ../../Tools/ToolTestQrcFile/qttestqrcfilemaindialog.cpp

HEADERS += \
    ../../Tools/ToolTestQrcFile/qttestqrcfilemenudialog.h \
    ../../Tools/ToolTestQrcFile/qttestqrcfilemaindialog.h

 

 

 

 

 

./ToolTestQrcFile/ToolTestQrcFileWebsite.pri

 

include(../../Tools/ToolTestQrcFile/ToolTestQrcFileConsole.pri)
SOURCES +=
HEADERS +=

 

 

 

 

 

./ToolTestQrcFile/main.cpp

 

//---------------------------------------------------------------------------
/*
TestQrcFile, tool to test the QrcFile class
Copyright (C) 2012-2014 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

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, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolTestQrcFile.htm
//---------------------------------------------------------------------------
#include "testqrcfilemenudialog.h"

int main(int argc, char* argv[])
{
  const std::vector<std::string> args { ribi::MenuDialog::ConvertArguments(argc,argv) };
  return ribi::TestQrcFileMenuDialog().Execute(args);
}

 

 

 

 

 

./ToolTestQrcFile/qtmain.cpp

 

//---------------------------------------------------------------------------
/*
TestQrcFile, tool to test the QrcFile class
Copyright (C) 2012-2013 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

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, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolTestQrcFile.htm
//---------------------------------------------------------------------------
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include <QApplication>
#include "qttestqrcfilemenudialog.h"
#include "trace.h"
#pragma GCC diagnostic pop

int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  START_TRACE();
  ribi::QtTestQrcFileMenuDialog w;
  w.show();
  return a.exec();
}

 

 

 

 

 

./ToolTestQrcFile/qttestqrcfilemaindialog.h

 

//---------------------------------------------------------------------------
/*
TestQrcFile, tool to test the QrcFile class
Copyright (C) 2012-2015 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

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, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolTestQrcFile.htm
//---------------------------------------------------------------------------
#ifndef QTTESTQRCFILEMAINDIALOG_H
#define QTTESTQRCFILEMAINDIALOG_H

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#include "qthideandshowdialog.h"
#pragma GCC diagnostic pop

namespace Ui {
  class QtTestQrcFileMainDialog;
}

namespace ribi {

class QtTestQrcFileMainDialog : public QtHideAndShowDialog
{
  Q_OBJECT

public:
  explicit QtTestQrcFileMainDialog(QWidget *parent = 0);
  QtTestQrcFileMainDialog(const QtTestQrcFileMainDialog&) = delete;
  QtTestQrcFileMainDialog& operator=(const QtTestQrcFileMainDialog&) = delete;
  ~QtTestQrcFileMainDialog() noexcept;

private slots:
  void on_edit_textChanged(const QString &arg1);

private:
  Ui::QtTestQrcFileMainDialog *ui;

  #ifndef NDEBUG
  static void Test() noexcept;
  #endif

};

} //~namespace ribi

#endif // QTTESTQRCFILEMAINDIALOG_H

 

 

 

 

 

./ToolTestQrcFile/qttestqrcfilemaindialog.cpp

 

//---------------------------------------------------------------------------
/*
TestQrcFile, tool to test the QrcFile class
Copyright (C) 2012-2015 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

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, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolTestQrcFile.htm
//---------------------------------------------------------------------------
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#include "qttestqrcfilemaindialog.h"

#include <fstream>
#include <sstream>

#include <QFileDialog>

#include "fileio.h"
#include "qrcfile.h"
#include "testtimer.h"
#include "testqrcfilemenudialog.h"
#include "trace.h"
#include "ui_qttestqrcfilemaindialog.h"
#pragma GCC diagnostic pop

ribi::QtTestQrcFileMainDialog::QtTestQrcFileMainDialog(QWidget *parent) :
  QtHideAndShowDialog(parent),
  ui(new Ui::QtTestQrcFileMainDialog)
{
  #ifndef NDEBUG
  Test();
  #endif
  ui->setupUi(this);

  ui->edit->setText("Tools/ToolTestQrcFile/ToolTestQrcFile.qrc");
}

ribi::QtTestQrcFileMainDialog::~QtTestQrcFileMainDialog() noexcept
{
  delete ui;
}

void ribi::QtTestQrcFileMainDialog::on_edit_textChanged(const QString &arg1)
{
  const std::string filename = "../../" + arg1.toStdString();
  if (!fileio::FileIo().IsRegularFile(filename))
  {
    ui->text_result->clear();
    const std::string text = "File '" + filename + "' does not exist.";
    ui->text_result->setPlainText(text.c_str());
    return;
  }

  QrcFile p(filename);

  std::stringstream s;
  s << p;

  ui->text_result->clear();
  ui->text_result->setPlainText(s.str().c_str());
}

#ifndef NDEBUG
void ribi::QtTestQrcFileMainDialog::Test() noexcept
{
  {
    static bool is_tested{false};
    if (is_tested) return;
    is_tested = true;
  }
  const TestTimer test_timer(__func__,__FILE__,1.0);
}
#endif

 

 

 

 

 

./ToolTestQrcFile/qttestqrcfilemenudialog.h

 

//---------------------------------------------------------------------------
/*
TestQrcFile, tool to test the QrcFile class
Copyright (C) 2012-2015 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

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, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolTestQrcFile.htm
//---------------------------------------------------------------------------
#ifndef QTTESTQRCFILEMENUDIALOG_H
#define QTTESTQRCFILEMENUDIALOG_H

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#include "qthideandshowdialog.h"
#pragma GCC diagnostic pop

namespace Ui {
  class QtTestQrcFileMenuDialog;
}

namespace ribi {

class QtTestQrcFileMenuDialog : public QtHideAndShowDialog
{
  Q_OBJECT

public:
  explicit QtTestQrcFileMenuDialog(QWidget *parent = 0);
  QtTestQrcFileMenuDialog(const QtTestQrcFileMenuDialog&) = delete;
  QtTestQrcFileMenuDialog& operator=(const QtTestQrcFileMenuDialog&) = delete;
  ~QtTestQrcFileMenuDialog() noexcept;

private slots:
  void on_button_start_clicked();
  void on_button_about_clicked();
  void on_button_quit_clicked();

private:
  Ui::QtTestQrcFileMenuDialog *ui;

  #ifndef NDEBUG
  static void Test() noexcept;
  #endif
};

} //~namespace ribi

#endif // QTTESTQRCFILEMENUDIALOG_H

 

 

 

 

 

./ToolTestQrcFile/qttestqrcfilemenudialog.cpp

 

//---------------------------------------------------------------------------
/*
TestQrcFile, tool to test the QrcFile class
Copyright (C) 2012-2015 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

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, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolTestQrcFile.htm
//---------------------------------------------------------------------------
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#include "qttestqrcfilemenudialog.h"

#include "qtaboutdialog.h"
#include "qttestqrcfilemaindialog.h"
#include "testqrcfilemenudialog.h"
#include "testtimer.h"
#include "trace.h"
#include "ui_qttestqrcfilemenudialog.h"
#pragma GCC diagnostic pop

ribi::QtTestQrcFileMenuDialog::QtTestQrcFileMenuDialog(QWidget *parent) :
  QtHideAndShowDialog(parent),
  ui(new Ui::QtTestQrcFileMenuDialog)
{
  #ifndef NDEBUG
  Test();
  #endif
  ui->setupUi(this);
}

ribi::QtTestQrcFileMenuDialog::~QtTestQrcFileMenuDialog() noexcept
{
  delete ui;
}

void ribi::QtTestQrcFileMenuDialog::on_button_start_clicked()
{
  QtTestQrcFileMainDialog d;
  this->ShowChild(&d);
}

void ribi::QtTestQrcFileMenuDialog::on_button_about_clicked()
{
  this->hide();
  About a = TestQrcFileMenuDialog().GetAbout();
  //a.AddLibrary("QtRichelBilderbeekGalleryDialog version: " + QtRichelBilderbeekGalleryDialog::GetVersion());
  //a.AddLibrary("QtRichelBilderbeekResources version: " + RichelBilderbeek::QtResources::GetVersion());
  QtAboutDialog d(a);
  this->ShowChild(&d);
}

void ribi::QtTestQrcFileMenuDialog::on_button_quit_clicked()
{
  close();
}

#ifndef NDEBUG
void ribi::QtTestQrcFileMenuDialog::Test() noexcept
{
  {
    static bool is_tested{false};
    if (is_tested) return;
    is_tested = true;
  }
  const TestTimer test_timer(__func__,__FILE__,1.0);
}
#endif

 

 

 

 

 

./ToolTestQrcFile/testqrcfilemenudialog.h

 

//---------------------------------------------------------------------------
/*
TestQrcFile, tool to test the QrcFile class
Copyright (C) 2012-2015 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

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, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolTestQrcFile.htm
//---------------------------------------------------------------------------
#ifndef TESTQRCFILEMENUDIALOG_H
#define TESTQRCFILEMENUDIALOG_H

#include "menudialog.h"

namespace ribi {

struct TestQrcFileMenuDialog final : public MenuDialog
{
  TestQrcFileMenuDialog();
  About GetAbout() const noexcept override;
  Help GetHelp() const noexcept override;
  boost::shared_ptr<const Program> GetProgram() const noexcept override;
  std::string GetVersion() const noexcept override;
  std::vector<std::string> GetVersionHistory() const noexcept override;

  private:
  int ExecuteSpecific(const std::vector<std::string>& argv) noexcept override;

  #ifndef NDEBUG
  static void Test() noexcept;
  #endif
};

} //~namespace ribi

#endif // TESTQRCFILEMENUDIALOG_H

 

 

 

 

 

./ToolTestQrcFile/testqrcfilemenudialog.cpp

 

//---------------------------------------------------------------------------
/*
TestQrcFile, tool to test the QrcFile class
Copyright (C) 2012-2015 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

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, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolTestQrcFile.htm
//---------------------------------------------------------------------------
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#include "testqrcfilemenudialog.h"

#include <cassert>
#include <iostream>

#include <QFile>

#include "fileio.h"
#include "qrcfile.h"
#include "richelbilderbeekprogram.h"
#include "trace.h"

#pragma GCC diagnostic pop

ribi::TestQrcFileMenuDialog::TestQrcFileMenuDialog()
{
  #ifndef NDEBUG
  Test();
  #endif
}

int ribi::TestQrcFileMenuDialog::ExecuteSpecific(const std::vector<std::string>& argv) noexcept
{
  const int argc = static_cast<int>(argv.size());
  if (argc == 3 && (argv[1] == "-f" || argv[1] == "--filename"))
  {
    const std::string filename = argv[2];
    if (filename.empty())
    {
      std::cout << "Please specify a filename.\n";
    }
    else if (filename.size() < 5)
    {
      std::cout << "Please specify a full Qt Creator (.qrc) project filename.\n";
    }
    else if (filename.substr(filename.size() - 4,4) != ".qrc")
    {
      std::cout << "Please specify a filename ending on .qrc.\n";
    }
    else if (!fileio::FileIo().IsRegularFile(filename))
    {
      std::cout << "Please specify a Qt Creator Resource (.qrc) filename that exists.\n";
    }
    else
    {
      QrcFile p(filename);
      std::cout << p << '\n';
      return 0;
    }
    return 1;
  }
  std::cout << GetHelp() << '\n';
  return 1;
}

ribi::About ribi::TestQrcFileMenuDialog::GetAbout() const noexcept
{
  About a(
    "Richel Bilderbeek",
    "TestQrcFile",
    "tool to test the QrcFile class",
    "the 20th of May 2013",
    "2012-2015",
    "http://www.richelbilderbeek.nl/ToolTestQrcFile.htm",
    GetVersion(),
    GetVersionHistory());
  a.AddLibrary("QrcFile version: " + QrcFile::GetVersion());
  a.AddLibrary("Trace version: " + Trace::GetVersion());

  return a;
}

ribi::Help ribi::TestQrcFileMenuDialog::GetHelp() const noexcept
{
  return Help(
    GetAbout().GetFileTitle(),
    this->GetAbout().GetFileDescription(),
    {
      Help::Option('f',"filename","filename of the Qt Resource file (.qrc) file")
    },
    {
      GetAbout().GetFileTitle() + " -f somefile.qrc",
      GetAbout().GetFileTitle() + " --filename somefile.qrc"
    }
  );
}

boost::shared_ptr<const ribi::Program> ribi::TestQrcFileMenuDialog::GetProgram() const noexcept
{
  const boost::shared_ptr<const Program> p {
    new ProgramTestQrcFile
  };
  assert(p);
  return p;
}

std::string ribi::TestQrcFileMenuDialog::GetVersion() const noexcept
{
  return "1.3";
}

std::vector<std::string> ribi::TestQrcFileMenuDialog::GetVersionHistory() const noexcept
{
  return {
    "2012-06-13: version 1.0: initial version",
    "2013-05-20: version 1.1: some GUI modifications",
    "2013-11-05: version 1.2: conformized for ProjectRichelBilderbeekConsole",
    "2014-01-27: version 1.3: removed use of Boost.Filesystem and Boost.Program_Options",
  };
}

#ifndef NDEBUG
void ribi::TestQrcFileMenuDialog::Test() noexcept
{
  //Test exactly once
  {
    static bool is_tested{false};
    if (is_tested) return;
    is_tested = true;
  }
  assert(fileio::FileIo().IsRegularFile("../../Tools/ToolTestQrcFile/ToolTestQrcFile.qrc"));
  {
    QrcFile f("../../Tools/ToolTestQrcFile/ToolTestQrcFile.qrc");
    assert(f.GetFiles().count("R.png"));
  }
}
#endif

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml