summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2016-02-21 10:28:37 +0100
committerDavid Tardon <dtardon@redhat.com>2016-02-21 15:39:28 +0100
commit2cf59007fd920d8b477a2e19d43ffb5a9262a788 (patch)
treef84a6e8d5e895ce8b3407f32a6f3fd97ff3be3a0
parent7a449d30aa788dc03973924e1e1f4fb255488483 (diff)
drop RVNGInputStreamPtr typedef
In C++11 it is more natural to use either shared_ptr or unique_ptr depending on purpose. We don't require C++11 yet, but we will eventually :-)
-rw-r--r--src/lib/Software602Document.cpp18
-rw-r--r--src/lib/WinText602Parser.cpp19
-rw-r--r--src/lib/WinText602Parser.h6
-rw-r--r--src/lib/libsw602_utils.h4
4 files changed, 26 insertions, 21 deletions
diff --git a/src/lib/Software602Document.cpp b/src/lib/Software602Document.cpp
index 5e4f0aa..4750b5d 100644
--- a/src/lib/Software602Document.cpp
+++ b/src/lib/Software602Document.cpp
@@ -9,11 +9,17 @@
#include <libsw602/Software602Document.h>
+#include <boost/shared_ptr.hpp>
+
#include <librevenge-stream/librevenge-stream.h>
#include "WinText602Header.h"
#include "WinText602Parser.h"
+using boost::shared_ptr;
+
+using librevenge::RVNGInputStream;
+
using std::string;
namespace libsw602
@@ -22,11 +28,11 @@ namespace libsw602
namespace
{
-RVNGInputStreamPtr getContent(librevenge::RVNGInputStream *const ip)
+shared_ptr<RVNGInputStream> getContent(librevenge::RVNGInputStream *const ip)
{
- const RVNGInputStreamPtr input(ip, SW602_shared_ptr_noop_deleter<librevenge::RVNGInputStream>());
+ const shared_ptr<RVNGInputStream> input(ip, SW602_shared_ptr_noop_deleter<librevenge::RVNGInputStream>());
- RVNGInputStreamPtr strm;
+ shared_ptr<RVNGInputStream> strm;
if (input->isStructured())
strm.reset(input->getSubStreamByName("CONTENTS"));
@@ -40,7 +46,7 @@ Software602Document::Confidence Software602Document::isSupported(librevenge::RVN
if (!input)
return CONFIDENCE_NONE;
- RVNGInputStreamPtr content = getContent(input);
+ shared_ptr<RVNGInputStream> content = getContent(input);
if (bool(content))
{
content->seek(0, librevenge::RVNG_SEEK_SET);
@@ -98,11 +104,11 @@ Software602Document::Result Software602Document::parse(librevenge::RVNGInputStre
{
case TYPE_WINTEXT602:
{
- RVNGInputStreamPtr content = getContent(input);
+ shared_ptr<RVNGInputStream> content = getContent(input);
if (bool(content))
{
content->seek(0, librevenge::RVNG_SEEK_SET);
- WinText602Parser parser(content.get(), document);
+ WinText602Parser parser(content, document);
return parser.parse() ? RESULT_OK : RESULT_PARSE_ERROR;
}
break;
diff --git a/src/lib/WinText602Parser.cpp b/src/lib/WinText602Parser.cpp
index 488a5bc..b0a29fa 100644
--- a/src/lib/WinText602Parser.cpp
+++ b/src/lib/WinText602Parser.cpp
@@ -15,10 +15,13 @@
#include <utility>
#include <librevenge/librevenge.h>
-#include <librevenge-stream/librevenge-stream.h>
#include "SW602MemoryStream.h"
+using boost::shared_ptr;
+
+using librevenge::RVNGInputStream;
+
namespace libsw602
{
@@ -44,7 +47,7 @@ public:
bool isPresent(WinText602Section section) const;
- RVNGInputStreamPtr getSectionStream(librevenge::RVNGInputStream &input, WinText602Section section) const;
+ shared_ptr<RVNGInputStream> getSectionStream(librevenge::RVNGInputStream &input, WinText602Section section) const;
private:
std::vector<Section_t> m_sections;
@@ -83,9 +86,9 @@ bool WinText602SectionMap::isPresent(const WinText602Section section) const
return false;
}
-RVNGInputStreamPtr WinText602SectionMap::getSectionStream(librevenge::RVNGInputStream &input, const WinText602Section section) const
+shared_ptr<RVNGInputStream> WinText602SectionMap::getSectionStream(librevenge::RVNGInputStream &input, const WinText602Section section) const
{
- RVNGInputStreamPtr strm;
+ shared_ptr<RVNGInputStream> strm;
if (isPresent(section))
{
@@ -106,7 +109,7 @@ RVNGInputStreamPtr WinText602SectionMap::getSectionStream(librevenge::RVNGInputS
namespace libsw602
{
-WinText602Parser::WinText602Parser(librevenge::RVNGInputStream *const input, librevenge::RVNGTextInterface *const document)
+WinText602Parser::WinText602Parser(const boost::shared_ptr<librevenge::RVNGInputStream> input, librevenge::RVNGTextInterface *const document)
: m_header(*input)
, m_input(input)
, m_document(document)
@@ -131,8 +134,8 @@ bool WinText602Parser::parse()
void WinText602Parser::readText()
{
- const RVNGInputStreamPtr textInput(getSection(WinText602_SECTION_TEXT));
- const RVNGInputStreamPtr textInfoInput(getSection(WinText602_SECTION_TEXT_INFO));
+ const shared_ptr<RVNGInputStream> textInput(getSection(WinText602_SECTION_TEXT));
+ const shared_ptr<RVNGInputStream> textInfoInput(getSection(WinText602_SECTION_TEXT_INFO));
const unsigned textLength = readU32(*textInput);
const unsigned spanCount = readU32(*textInfoInput);
@@ -181,7 +184,7 @@ void WinText602Parser::readText()
}
}
-RVNGInputStreamPtr WinText602Parser::getSection(const WinText602Section section) const
+shared_ptr<RVNGInputStream> WinText602Parser::getSection(const WinText602Section section) const
{
return m_sectionMap->getSectionStream(*m_input, section);
}
diff --git a/src/lib/WinText602Parser.h b/src/lib/WinText602Parser.h
index ef77702..dee476c 100644
--- a/src/lib/WinText602Parser.h
+++ b/src/lib/WinText602Parser.h
@@ -70,18 +70,18 @@ class WinText602Parser
WinText602Parser &operator=(const WinText602Parser &other);
public:
- WinText602Parser(librevenge::RVNGInputStream *input, librevenge::RVNGTextInterface *document);
+ WinText602Parser(boost::shared_ptr<librevenge::RVNGInputStream> input, librevenge::RVNGTextInterface *document);
bool parse();
private:
void readText();
- RVNGInputStreamPtr getSection(WinText602Section section) const;
+ boost::shared_ptr<librevenge::RVNGInputStream> getSection(WinText602Section section) const;
private:
WinText602Header m_header;
- librevenge::RVNGInputStream *m_input;
+ const boost::shared_ptr<librevenge::RVNGInputStream> m_input;
librevenge::RVNGTextInterface *m_document;
boost::shared_ptr<WinText602SectionMap> m_sectionMap;
diff --git a/src/lib/libsw602_utils.h b/src/lib/libsw602_utils.h
index 1decfac..ea1e83b 100644
--- a/src/lib/libsw602_utils.h
+++ b/src/lib/libsw602_utils.h
@@ -51,8 +51,6 @@ typedef __int64 int64_t;
#endif
-#include <boost/shared_ptr.hpp>
-
/** an noop deleter used to transform a librevenge pointer in a false shared_ptr */
template <class T>
struct SW602_shared_ptr_noop_deleter
@@ -60,8 +58,6 @@ struct SW602_shared_ptr_noop_deleter
void operator()(T *) {}
};
-typedef boost::shared_ptr<librevenge::RVNGInputStream> RVNGInputStreamPtr;
-
// debug message includes source file and line number
//#define VERBOSE_DEBUG 1