* 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 | 23 ++++++++++++------- scribo/sandbox/arthur/xml_transform/image_crop.hh | 12 ++++++++++ scribo/sandbox/arthur/xml_transform/loader.cc | 12 +++++----- scribo/sandbox/arthur/xml_transform/loader.hh | 23 ++++++++++--------- scribo/sandbox/arthur/xml_transform/main.cc | 2 + .../sandbox/arthur/xml_transform/xml_transform.cc | 2 +- .../sandbox/arthur/xml_transform/xml_transform.hh | 3 +- 10 files changed, 67 insertions(+), 32 deletions(-)
diff --git a/scribo/sandbox/ChangeLog b/scribo/sandbox/ChangeLog index 78c55d6..c1d5540 100644 --- a/scribo/sandbox/ChangeLog +++ b/scribo/sandbox/ChangeLog @@ -1,3 +1,17 @@ +2010-09-02 Guillaume Lazzara z@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@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 50fadd8..702d49f 100644 --- a/scribo/sandbox/arthur/xml_transform/image_crop.cc +++ b/scribo/sandbox/arthur/xml_transform/image_crop.cc @@ -37,10 +37,11 @@ #include <mln/io/magick/load.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) { }
@@ -48,8 +49,9 @@ ImageCrop::~ImageCrop() { }
+ /* Save image to PNG format in output_dir/img. */ -void ImageCrop::save_image(QString out) +void ImageCrop::save_image(const QString& out) { using namespace mln;
@@ -72,8 +74,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) + +/* 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;
@@ -84,7 +88,8 @@ bool ImageCrop::img_from_base64(QString str, QString img) return ima.save(output_dir_ + img); }
-/* 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_); @@ -125,7 +130,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 ee5ca56..598143b 100644 --- a/scribo/sandbox/arthur/xml_transform/image_crop.hh +++ b/scribo/sandbox/arthur/xml_transform/image_crop.hh @@ -36,6 +36,7 @@ class ImageCrop : public QObject Q_OBJECT public:
+<<<<<<< HEAD ImageCrop(QString, QString, QString); ~ImageCrop();
@@ -45,6 +46,17 @@ class ImageCrop : public QObject QString img_to_base64(); bool img_from_base64(QString, QString); void to_base64(QString, bool); +======= + ImageCrop(const QString&, const QString&, const QString&); + ~ImageCrop(); + + void save_image(const QString&); + bool crop_regions(bool temp = false); + + QString img_to_base64(); + bool img_from_base64(const QString&, const QString&); + void to_base64(const QString&, bool); +>>>>>>> 6f0918c... Add missing const references to function arguments.
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 687f53c..0dfb84e 100644 --- a/scribo/sandbox/arthur/xml_transform/main.cc +++ b/scribo/sandbox/arthur/xml_transform/main.cc @@ -2,10 +2,12 @@ #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 be5a137..be5c1e4 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 ee06907..fa22c07 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();
QString out() { return output_dir_; }