[gnote] Remove boost::format and use Glib::ustring in XmlWriter
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Remove boost::format and use Glib::ustring in XmlWriter
- Date: Mon, 9 Jan 2017 21:37:05 +0000 (UTC)
commit 585b804cb4cd31d44cc9ff1da345d227a0998b8f
Author: Aurimas Černius <aurisc4 gmail com>
Date: Mon Jan 9 23:34:50 2017 +0200
Remove boost::format and use Glib::ustring in XmlWriter
src/sharp/xmlwriter.cpp | 30 ++++++++++++++----------------
src/sharp/xmlwriter.hpp | 22 +++++++++++-----------
2 files changed, 25 insertions(+), 27 deletions(-)
---
diff --git a/src/sharp/xmlwriter.cpp b/src/sharp/xmlwriter.cpp
index e587d85..a29c2f8 100644
--- a/src/sharp/xmlwriter.cpp
+++ b/src/sharp/xmlwriter.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2013 Aurimas Cernius
+ * Copyright (C) 2013,2017 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,7 +24,6 @@
*/
-#include <boost/format.hpp>
#include <glibmm/i18n.h>
#include <glibmm/ustring.h>
@@ -35,11 +34,10 @@
namespace {
- std::string make_write_failure_msg(const std::string & caller, const std::string & fail_func)
+ Glib::ustring make_write_failure_msg(const Glib::ustring & caller, const Glib::ustring & fail_func)
{
- boost::format fmt(_("%1% failed"));
- std::string msg = caller + ": ";
- msg += str(fmt % fail_func);
+ Glib::ustring msg = caller + ": ";
+ msg += Glib::ustring::compose(_("%1 failed"), fail_func);
return msg;
}
@@ -54,7 +52,7 @@ namespace sharp {
m_writer = xmlNewTextWriterMemory(m_buf, 0);
}
- XmlWriter::XmlWriter(const std::string & filename)
+ XmlWriter::XmlWriter(const Glib::ustring & filename)
: m_buf(NULL)
{
m_writer = xmlNewTextWriterFilename(filename.c_str(), 0);
@@ -98,8 +96,8 @@ namespace sharp {
}
- int XmlWriter::write_start_element(const std::string & prefix,
- const std::string & name, const std::string & nsuri)
+ int XmlWriter::write_start_element(const Glib::ustring & prefix,
+ const Glib::ustring & name, const Glib::ustring & nsuri)
{
int res = xmlTextWriterStartElementNS(m_writer, to_xmlchar(prefix),
(const xmlChar*)name.c_str(), to_xmlchar(nsuri));
@@ -134,7 +132,7 @@ namespace sharp {
}
- int XmlWriter::write_start_attribute(const std::string & name)
+ int XmlWriter::write_start_attribute(const Glib::ustring & name)
{
int res = xmlTextWriterStartAttribute(m_writer, (const xmlChar*)name.c_str());
if(res < 0) {
@@ -145,8 +143,8 @@ namespace sharp {
}
- int XmlWriter::write_attribute_string(const std::string & prefix,const std::string & local_name,
- const std::string & ns ,const std::string & value)
+ int XmlWriter::write_attribute_string(const Glib::ustring & prefix,const Glib::ustring & local_name,
+ const Glib::ustring & ns ,const Glib::ustring & value)
{
int res = xmlTextWriterWriteAttributeNS(m_writer, to_xmlchar(prefix),
(const xmlChar*)local_name.c_str(),
@@ -170,7 +168,7 @@ namespace sharp {
}
- int XmlWriter::write_raw(const std::string & raw)
+ int XmlWriter::write_raw(const Glib::ustring & raw)
{
int res = xmlTextWriterWriteRaw(m_writer, (const xmlChar*)raw.c_str());
if(res < 0) {
@@ -188,7 +186,7 @@ namespace sharp {
return xmlTextWriterWriteString(m_writer, (const xmlChar*)unistring.c_str());
}
- int XmlWriter::write_string(const std::string & s)
+ int XmlWriter::write_string(const Glib::ustring & s)
{
return xmlTextWriterWriteString(m_writer, (const xmlChar*)s.c_str());
}
@@ -202,12 +200,12 @@ namespace sharp {
}
- std::string XmlWriter::to_string()
+ Glib::ustring XmlWriter::to_string()
{
if(!m_buf) {
return "";
}
- std::string output((const char*)m_buf->content);
+ Glib::ustring output((const char*)m_buf->content);
return output;
}
diff --git a/src/sharp/xmlwriter.hpp b/src/sharp/xmlwriter.hpp
index 95f1ad2..fd5929e 100644
--- a/src/sharp/xmlwriter.hpp
+++ b/src/sharp/xmlwriter.hpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2013 Aurimas Cernius
+ * Copyright (C) 2013,2017 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -29,11 +29,11 @@
#ifndef __SHARP_XMLWRITER_HPP_
#define __SHARP_XMLWRITER_HPP_
-#include <string>
#include <boost/noncopyable.hpp>
#include <glib.h>
+#include <glibmm/ustring.h>
#include <libxml/xmlwriter.h>
@@ -41,7 +41,7 @@ namespace sharp {
inline
- const xmlChar * to_xmlchar(const std::string & s)
+ const xmlChar * to_xmlchar(const Glib::ustring & s)
{
return s.empty() ? NULL : (const xmlChar *)s.c_str();
}
@@ -51,24 +51,24 @@ namespace sharp {
{
public:
XmlWriter();
- XmlWriter(const std::string & filename);
+ XmlWriter(const Glib::ustring & filename);
XmlWriter(xmlDocPtr doc);
~XmlWriter();
int write_start_document();
int write_end_document();
- int write_start_element(const std::string & prefix, const std::string & name, const std::string & nsuri);
+ int write_start_element(const Glib::ustring & prefix, const Glib::ustring & name, const Glib::ustring &
nsuri);
int write_full_end_element();
int write_end_element();
- int write_start_attribute(const std::string & name);
- int write_attribute_string(const std::string & prefix,const std::string & local_name,
- const std::string & ns ,const std::string & value);
+ int write_start_attribute(const Glib::ustring & name);
+ int write_attribute_string(const Glib::ustring & prefix,const Glib::ustring & local_name,
+ const Glib::ustring & ns ,const Glib::ustring & value);
int write_end_attribute();
- int write_raw(const std::string & raw);
+ int write_raw(const Glib::ustring & raw);
int write_char_entity(gunichar ch);
- int write_string(const std::string & );
+ int write_string(const Glib::ustring & );
int close();
- std::string to_string();
+ Glib::ustring to_string();
private:
xmlTextWriterPtr m_writer;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]