* arthur/xml_transform/common.cc,
* arthur/xml_transform/common.hh,
* arthur/xml_transform/image_crop.cc,
* arthur/xml_transform/image_crop.hh,
* arthur/xml_transform/loader.cc,
* arthur/xml_transform/loader.hh,
* arthur/xml_transform/main.cc,
* arthur/xml_transform/xml_transform.cc,
* arthur/xml_transform/xml_transform.hh: Here.
---
scribo/sandbox/ChangeLog | 14 +++++++++++
scribo/sandbox/arthur/xml_transform/common.cc | 4 +-
scribo/sandbox/arthur/xml_transform/common.hh | 4 +-
scribo/sandbox/arthur/xml_transform/image_crop.cc | 25 ++++++++++++--------
scribo/sandbox/arthur/xml_transform/image_crop.hh | 10 ++++----
scribo/sandbox/arthur/xml_transform/loader.cc | 12 ++++----
scribo/sandbox/arthur/xml_transform/loader.hh | 23 +++++++++--------
scribo/sandbox/arthur/xml_transform/main.cc | 6 ++++-
.../sandbox/arthur/xml_transform/xml_transform.cc | 2 +-
.../sandbox/arthur/xml_transform/xml_transform.hh | 3 +-
10 files changed, 64 insertions(+), 39 deletions(-)
diff --git a/scribo/sandbox/ChangeLog b/scribo/sandbox/ChangeLog
index 052bd6d..485cc02 100644
--- a/scribo/sandbox/ChangeLog
+++ b/scribo/sandbox/ChangeLog
@@ -1,3 +1,17 @@
+2010-09-02 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Add missing const references to function arguments.
+
+ * arthur/xml_transform/common.cc,
+ * arthur/xml_transform/common.hh,
+ * arthur/xml_transform/image_crop.cc,
+ * arthur/xml_transform/image_crop.hh,
+ * arthur/xml_transform/loader.cc,
+ * arthur/xml_transform/loader.hh,
+ * arthur/xml_transform/main.cc,
+ * arthur/xml_transform/xml_transform.cc,
+ * arthur/xml_transform/xml_transform.hh: Here.
+
2010-08-06 Arthur Crepin-Leblond <crepin(a)lrde.epita.fr>
Open Document bug warning.
diff --git a/scribo/sandbox/arthur/xml_transform/common.cc
b/scribo/sandbox/arthur/xml_transform/common.cc
index 05117b2..d1f3a6c 100644
--- a/scribo/sandbox/arthur/xml_transform/common.cc
+++ b/scribo/sandbox/arthur/xml_transform/common.cc
@@ -1,13 +1,13 @@
# include "common.hh"
-QString Common::get_file_name(QString image)
+QString Common::get_file_name(const QString& image)
{
QString tmp = image.mid(image.lastIndexOf("/") + 1);
tmp.chop(tmp.size() - tmp.lastIndexOf("."));
return tmp;
}
-QString Common::get_file_ext(QString image)
+QString Common::get_file_ext(const QString& image)
{
return image.right(image.size() - image.lastIndexOf("."));
}
diff --git a/scribo/sandbox/arthur/xml_transform/common.hh
b/scribo/sandbox/arthur/xml_transform/common.hh
index f72218f..21b984a 100644
--- a/scribo/sandbox/arthur/xml_transform/common.hh
+++ b/scribo/sandbox/arthur/xml_transform/common.hh
@@ -9,8 +9,8 @@ class Common : public QObject
public:
Common() {}
~Common() {}
- static QString get_file_name(QString image);
- static QString get_file_ext(QString image);
+ static QString get_file_name(const QString& image);
+ static QString get_file_ext(const QString& image);
};
#endif // ! COMMON_HH
diff --git a/scribo/sandbox/arthur/xml_transform/image_crop.cc
b/scribo/sandbox/arthur/xml_transform/image_crop.cc
index ffe2b44..f691b57 100644
--- a/scribo/sandbox/arthur/xml_transform/image_crop.cc
+++ b/scribo/sandbox/arthur/xml_transform/image_crop.cc
@@ -36,10 +36,11 @@
#include <mln/io/magick/save.hh>
#include <mln/io/ppm/all.hh>
-ImageCrop::ImageCrop(QString xml, QString img, QString output) :
- xml_(xml),
- image_(img),
- output_dir_(output)
+ImageCrop::ImageCrop(const QString& xml, const QString& img,
+ const QString& output)
+ : xml_(xml),
+ image_(img),
+ output_dir_(output)
{
}
@@ -47,8 +48,9 @@ ImageCrop::~ImageCrop()
{
}
-/* Save PPM image to PNG format in output_dir/img. */
-void ImageCrop::save_image(QString file)
+
+/* Save image to PNG format in output_dir/img. */
+void ImageCrop::save_image(const QString& out)
{
using namespace mln;
@@ -82,8 +84,10 @@ QString ImageCrop::img_to_base64()
return file_content.toBase64();
}
-/* Decode the base 64 string str and save into output_dir_/img/img_name. */
-bool ImageCrop::img_from_base64(QString str, QString img_name, QString mime)
+
+/* Decode the base 64 string str and save into
+ * output_dir_/img/img_name. */
+bool ImageCrop::img_from_base64(const QString& str, const QString& img)
{
QByteArray ba;
@@ -94,7 +98,8 @@ bool ImageCrop::img_from_base64(QString str, QString img_name, QString
mime)
return ima.save(output_dir_ + "img/" + img_name + "." + mime);
}
-/* Read all regions of the XML file and save all base 64 data into output_dir/img */
+/* Read all regions of the XML file and save all base 64 data into
+ * output_dir/img */
void ImageCrop::from_base64()
{
QFile f_in(xml_);
@@ -134,7 +139,7 @@ void ImageCrop::from_base64()
/* Tranfsorm the input XML file associated with images into a single
XML output containing datas if images in base 64. */
-void ImageCrop::to_base64(QString out_file, bool no_crop)
+void ImageCrop::to_base64(const QString& out_file, bool no_crop)
{
QFile file(xml_);
file.open(QIODevice::ReadOnly);
diff --git a/scribo/sandbox/arthur/xml_transform/image_crop.hh
b/scribo/sandbox/arthur/xml_transform/image_crop.hh
index 9b034cc..1644373 100644
--- a/scribo/sandbox/arthur/xml_transform/image_crop.hh
+++ b/scribo/sandbox/arthur/xml_transform/image_crop.hh
@@ -36,15 +36,15 @@ class ImageCrop : public QObject
Q_OBJECT
public:
- ImageCrop(QString xml, QString img, QString output);
+ ImageCrop(const QString&, const QString&, const QString&);
~ImageCrop();
- void save_image(QString file = QString::Null());
- bool crop_regions();
+ void save_image(const QString&);
+ bool crop_regions(bool temp = false);
QString img_to_base64();
- bool img_from_base64(QString str, QString img_name, QString mime);
- void to_base64(QString out_file, bool no_crop);
+ bool img_from_base64(const QString&, const QString&);
+ void to_base64(const QString&, bool);
void from_base64();
diff --git a/scribo/sandbox/arthur/xml_transform/loader.cc
b/scribo/sandbox/arthur/xml_transform/loader.cc
index d4778a9..f9316f2 100644
--- a/scribo/sandbox/arthur/xml_transform/loader.cc
+++ b/scribo/sandbox/arthur/xml_transform/loader.cc
@@ -33,7 +33,7 @@ Loader::~Loader()
{
}
-QDomDocument* Loader::xml_to_dom(QString xml_file)
+QDomDocument* Loader::xml_to_dom(const QString& xml_file)
{
QFile file(xml_file);
@@ -68,7 +68,7 @@ bool Loader::set_output(QString& output)
}
-void Loader::add_html_templates(bool base64, QString output)
+void Loader::add_html_templates(bool base64, const QString& output)
{
QFile gen("templates/html/html_generator.sh");
gen.copy(output + "html_generator.sh");
@@ -88,7 +88,7 @@ void Loader::add_html_templates(bool base64, QString output)
}
}
-void Loader::add_pdf_templates(bool crop, bool base64, QString output)
+void Loader::add_pdf_templates(bool crop, bool base64, const QString& output)
{
if (base64)
{
@@ -126,7 +126,7 @@ void Loader::add_pdf_templates(bool crop, bool base64, QString
output)
}
}
-void Loader::add_svg_templates(QString output)
+void Loader::add_svg_templates(const QString& output)
{
QFile regions("templates/pdf/regions_svg.xsl");
regions.copy(output + "regions.xsl");
@@ -141,7 +141,7 @@ void Loader::add_svg_templates(QString output)
xsl.copy(output + "main.xsl");
}
-void Loader::add_open_templates(QString output)
+void Loader::add_open_templates(const QString& output)
{
QFile css("templates/opendoc/css.css");
css.copy(output + "css.css");
@@ -153,7 +153,7 @@ void Loader::add_open_templates(QString output)
xsl.copy(output + "xsl.xsl");
}
-bool Loader::xml_output(QString xml_file, bool html, QString output)
+bool Loader::xml_output(const QString& xml_file, bool html, const QString&
output)
{
QFile file(xml_file);
diff --git a/scribo/sandbox/arthur/xml_transform/loader.hh
b/scribo/sandbox/arthur/xml_transform/loader.hh
index a5c3637..a66af2d 100644
--- a/scribo/sandbox/arthur/xml_transform/loader.hh
+++ b/scribo/sandbox/arthur/xml_transform/loader.hh
@@ -23,11 +23,11 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef LOADER_HH
-# define LOADER_HH
+#ifndef LOADER_HH
+# define LOADER_HH
# include <QtCore>
-#include <QDomDocument>
+# include <QDomDocument>
class Loader : public QObject
{
@@ -37,14 +37,15 @@ class Loader : public QObject
Loader();
~Loader();
- // void merge(QString in, QString other, QString output = "output.xml");
- bool xml_output(QString xml_file, bool html, QString output);
- QDomDocument* xml_to_dom(QString xml_file);
+ // void merge(const QString& in, const QString& other, const
+ // QString& output = "output.xml");
+ bool xml_output(const QString& xml_file, bool html, const QString& output);
+ QDomDocument* xml_to_dom(const QString& xml_file);
bool set_output(QString& output);
- void add_pdf_templates(bool crop, bool base64, QString output);
- void add_svg_templates(QString output);
- void add_open_templates(QString output);
- void add_html_templates(bool base64, QString output);
+ void add_pdf_templates(bool crop, bool base64, const QString& output);
+ void add_svg_templates(const QString& output);
+ void add_open_templates(const QString& output);
+ void add_html_templates(bool base64, const QString& output);
};
-#endif /* !LOADER_HH */
+#endif /* !LOADER_HH */
diff --git a/scribo/sandbox/arthur/xml_transform/main.cc
b/scribo/sandbox/arthur/xml_transform/main.cc
index 8489376..2280b7d 100644
--- a/scribo/sandbox/arthur/xml_transform/main.cc
+++ b/scribo/sandbox/arthur/xml_transform/main.cc
@@ -1,9 +1,13 @@
#include <iostream>
-#include <QDomDocument>
+#include <string>
+#include <string>
+#include <cstdlib>
+#include <Magick++.h>
#include "xml_transform.hh"
int main(int argc, char **argv)
{
+ Magick::InitializeMagick(argv[0]);
std::string man;
man = "xml_transform\n"
diff --git a/scribo/sandbox/arthur/xml_transform/xml_transform.cc
b/scribo/sandbox/arthur/xml_transform/xml_transform.cc
index 90af5a5..7149bdf 100644
--- a/scribo/sandbox/arthur/xml_transform/xml_transform.cc
+++ b/scribo/sandbox/arthur/xml_transform/xml_transform.cc
@@ -29,7 +29,7 @@
# include "common.hh"
# include <iostream>
-XmlTransform::XmlTransform(QString xml_file, QString image_file, QString output, QString
file) :
+XmlTransform::XmlTransform(const QString& xml_file, const QString& image_file,
const QString& output, const QString& file) :
xml_file_(xml_file),
image_(image_file),
loader_(new Loader()),
diff --git a/scribo/sandbox/arthur/xml_transform/xml_transform.hh
b/scribo/sandbox/arthur/xml_transform/xml_transform.hh
index ad83fd5..c5dfc49 100644
--- a/scribo/sandbox/arthur/xml_transform/xml_transform.hh
+++ b/scribo/sandbox/arthur/xml_transform/xml_transform.hh
@@ -37,7 +37,8 @@ class XmlTransform : public QObject
Q_OBJECT
public:
- XmlTransform(QString xml_file, QString image_file, QString output, QString file =
QString::Null());
+ XmlTransform(const QString& xml_file, const QString& image_file,
+ const QString& output, const QString& file = QString::Null());
~XmlTransform();
void createHTML(bool base64);
--
1.5.6.5