Skip to content

Commit

Permalink
Replace some use of Boost smart pointers by std equivalents
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldk authored and Daniël de Kok committed May 4, 2020
1 parent 7f32f9c commit 3a0cbbc
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 26 deletions.
3 changes: 2 additions & 1 deletion util/common/EqualsPrevious.hh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define ALPINOCORPUS_EQUALSPREVIOUS_HH

#include <functional>
#include <memory>

#include <boost/shared_ptr.hpp>

Expand All @@ -23,7 +24,7 @@ public:
}

// operator() is often expected to be const.
mutable boost::shared_ptr<T> d_previous;
mutable std::unique_ptr<T> d_previous;
};

template <typename T>
Expand Down
4 changes: 1 addition & 3 deletions util/create/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <string>
#include <unordered_set>

#include <boost/scoped_ptr.hpp>
#include <boost/filesystem.hpp>

#include <AlpinoCorpus/CorpusReader.hh>
Expand All @@ -28,7 +27,6 @@
#include <iostream>
#include <stdexcept>

#include <EqualsPrevious.hh>
#include <ProgramOptions.hh>
#include <util.hh>

Expand Down Expand Up @@ -89,7 +87,7 @@ void writeCorpus(std::shared_ptr<CorpusReader> reader,

int main(int argc, char *argv[])
{
boost::scoped_ptr<ProgramOptions> opts;
std::unique_ptr<ProgramOptions> opts;
try {
opts.reset(new ProgramOptions(argc, const_cast<char const **>(argv),
"c:d:m:nq:r"));
Expand Down
3 changes: 1 addition & 2 deletions util/extract/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <string>

#include <boost/filesystem/path.hpp>
#include <boost/scoped_ptr.hpp>

#include <AlpinoCorpus/CorpusReader.hh>
#include <AlpinoCorpus/macros.hh>
Expand All @@ -26,7 +25,7 @@ void usage(std::string const &programName) {
}

int main(int argc, char *argv[]) {
boost::scoped_ptr<ProgramOptions> opts;
std::unique_ptr<ProgramOptions> opts;
try {
opts.reset(new ProgramOptions(argc, const_cast<char const **>(argv),
"q"));
Expand Down
4 changes: 1 addition & 3 deletions util/get/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#include <stdexcept>
#include <string>

#include <boost/scoped_ptr.hpp>

#include <AlpinoCorpus/CorpusReader.hh>
#include <AlpinoCorpus/macros.hh>

Expand All @@ -29,7 +27,7 @@ void usage(std::string const &programName) {
}

int main(int argc, char *argv[]) {
boost::scoped_ptr<ProgramOptions> opts;
std::unique_ptr<ProgramOptions> opts;
try {
opts.reset(new ProgramOptions(argc, const_cast<char const **>(argv),
"a:m:q:v:"));
Expand Down
4 changes: 1 addition & 3 deletions util/stats/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#include <string>
#include <unordered_map>

#include <boost/scoped_ptr.hpp>

#include <AlpinoCorpus/CorpusReader.hh>
#include <AlpinoCorpus/macros.hh>

Expand Down Expand Up @@ -64,7 +62,7 @@ void usage(std::string const &programName)

int main(int argc, char *argv[])
{
boost::scoped_ptr<ProgramOptions> opts;
std::unique_ptr<ProgramOptions> opts;
try {
opts.reset(new ProgramOptions(argc, const_cast<char const **>(argv),
"m:p"));
Expand Down
8 changes: 1 addition & 7 deletions util/xpath/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <string>
#include <unordered_set>

#include <boost/scoped_ptr.hpp>
#include <boost/filesystem.hpp>

#include <AlpinoCorpus/CorpusInfo.hh>
Expand Down Expand Up @@ -138,11 +137,6 @@ void listCorpus(std::shared_ptr<CorpusReader> reader,
}
}

void readEntry(boost::shared_ptr<CorpusReader> reader, std::string const &entry)
{
std::cout << reader->read(entry);
}

void usage(std::string const &programName)
{
std::cerr << "Usage: " << programName << " [OPTION] treebank(s)" <<
Expand All @@ -156,7 +150,7 @@ void usage(std::string const &programName)

int main(int argc, char *argv[])
{
boost::scoped_ptr<ProgramOptions> opts;
std::unique_ptr<ProgramOptions> opts;
try {
opts.reset(new ProgramOptions(argc, const_cast<char const **>(argv),
"a:cm:q:s"));
Expand Down
4 changes: 1 addition & 3 deletions util/xquery/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#include <memory>
#include <string>

#include <boost/scoped_ptr.hpp>

#include <AlpinoCorpus/CorpusReader.hh>
#include <AlpinoCorpus/Entry.hh>
#include <AlpinoCorpus/Error.hh>
Expand Down Expand Up @@ -51,7 +49,7 @@ void usage(std::string const &programName)

int main(int argc, char *argv[])
{
boost::scoped_ptr<ProgramOptions> opts;
std::unique_ptr<ProgramOptions> opts;
try {
opts.reset(new ProgramOptions(argc, const_cast<char const **>(argv),
"f:m:q:"));
Expand Down
5 changes: 1 addition & 4 deletions util/xslt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#include <string>
#include <unordered_set>

#include <boost/scoped_ptr.hpp>

extern "C" {
#include <libxslt/xslt.h>
#include <libxml/parser.h>
Expand All @@ -20,7 +18,6 @@ extern "C" {

#include "../src/util/textfile.hh" // XXX - hmpf

#include <EqualsPrevious.hh>
#include <ProgramOptions.hh>
#include <Stylesheet.hh>
#include <util.hh>
Expand Down Expand Up @@ -95,7 +92,7 @@ int main (int argc, char *argv[])
// XPath
xmlXPathInit();

boost::scoped_ptr<ProgramOptions> opts;
std::unique_ptr<ProgramOptions> opts;
try {
opts.reset(new ProgramOptions(argc, const_cast<char const **>(argv),
"g:m:q:"));
Expand Down

0 comments on commit 3a0cbbc

Please sign in to comment.