Skip to content

Commit

Permalink
Boost removal.
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed Dec 28, 2015
1 parent 3a92163 commit f4581cc
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 138 deletions.
1 change: 0 additions & 1 deletion include/pdal/Stage.hpp
Expand Up @@ -114,7 +114,6 @@ class PDAL_DLL Stage
virtual std::string getName() const = 0;
const std::vector<Stage*>& getInputs() const
{ return m_inputs; }
std::vector<Stage *> findStage(std::string name);
virtual Options getDefaultOptions()
{ return Options(); }
static Dimension::IdList getDefaultDimensions()
Expand Down
54 changes: 23 additions & 31 deletions include/pdal/util/FileUtils.hpp
Expand Up @@ -57,71 +57,63 @@
namespace pdal
{

// this is a static class -- do not instantiate]
class PDAL_DLL FileUtils
namespace FileUtils
{
public:
// open existing file for reading
static std::istream* openFile(std::string const& filename,
bool asBinary=true);
std::istream* openFile(std::string const& filename, bool asBinary=true);

// open new file for writing
static std::ostream* createFile(std::string const& filename,
bool asBinary=true);
std::ostream* createFile(std::string const& filename, bool asBinary=true);

static bool directoryExists(std::string const& dirname);
static bool createDirectory(std::string const& dirname);
static void deleteDirectory(std::string const& dirname);
bool directoryExists(std::string const& dirname);
bool createDirectory(std::string const& dirname);
void deleteDirectory(std::string const& dirname);

static void closeFile(std::ostream* ofs);
static void closeFile(std::istream* ifs);
void closeFile(std::ostream* ofs);
void closeFile(std::istream* ifs);

static bool deleteFile(const std::string& filename);
static void renameFile(const std::string& dest, const std::string& src);
static bool fileExists(const std::string& filename);
static uintmax_t fileSize(const std::string& filename);
bool deleteFile(const std::string& filename);
void renameFile(const std::string& dest, const std::string& src);
bool fileExists(const std::string& filename);
uintmax_t fileSize(const std::string& filename);

// reads a file into a text string for you
static std::string readFileIntoString(const std::string& filename);
std::string readFileIntoString(const std::string& filename);

// return current working dir
// the result will always have a trailing '/'
static std::string getcwd();
std::string getcwd();

// return the file component of the given path,
// e.g. "d:/foo/bar/a.c" -> "a.c"
static std::string getFilename(const std::string& path);
std::string getFilename(const std::string& path);

// return the directory component of the given path,
// e.g. "d:/foo/bar/a.c" -> "d:/foo/bar"
// the result will always have a trailing '/'
static std::string getDirectory(const std::string& path);
std::string getDirectory(const std::string& path);

// returns true iff the path is not relative
static bool isAbsolutePath(const std::string& path);
bool isAbsolutePath(const std::string& path);

// if the filename is an absolute path, just return it
// otherwise, make it absolute (relative to current working dir)
// and return that
static std::string toAbsolutePath(const std::string& filename);
std::string toAbsolutePath(const std::string& filename);

// if the filename is an absolute path, just return it
// otherwise, make it absolute (relative to base dir) and return that
//
// note: if base dir is not absolute, first make it absolute via
// toAbsolutePath(base)
static std::string toAbsolutePath(const std::string& filename,
std::string toAbsolutePath(const std::string& filename,
const std::string base);

static std::string readFileAsString(std::string const& filename);
static void fileTimes(const std::string& filename, struct tm *createTime,
std::string readFileAsString(std::string const& filename);
void fileTimes(const std::string& filename, struct tm *createTime,
struct tm *modTime);

private:
static std::string addTrailingSlash(std::string path);

FileUtils& operator=(const FileUtils&); // not implemented
FileUtils(const FileUtils&); // not implemented;
};
std::string extension(const std::string& filename);
}

} // namespace pdal
23 changes: 9 additions & 14 deletions src/KernelSupport.cpp
Expand Up @@ -34,9 +34,6 @@

#include <pdal/KernelSupport.hpp>

#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>

#include <pdal/util/FileUtils.hpp>
#include <pdal/PipelineReader.hpp>
#include <pdal/util/Utils.hpp>
Expand All @@ -56,7 +53,7 @@ PipelineManagerPtr KernelSupport::makePipeline(const std::string& inputFile)
PipelineReader pipeReader(*output);
pipeReader.readPipeline(std::cin);
}
else if (boost::filesystem::extension(inputFile) == ".xml")
else if (FileUtils::extension(inputFile) == ".xml")
{
PipelineReader pipeReader(*output);
pipeReader.readPipeline(inputFile);
Expand Down Expand Up @@ -116,13 +113,10 @@ ShellScriptCallback::ShellScriptCallback(
if (command.size())
{
m_command = command[0];
if (command.size() == 3)
{
major_tick = boost::lexical_cast<double>(command[1]);
minor_tick = boost::lexical_cast<double>(command[2]);
}
else if (command.size() == 2)
major_tick = boost::lexical_cast<double>(command[1]);
if (command.size() > 1)
Utils::fromString(command[1], major_tick);
if (command.size() > 2)
Utils::fromString(command[2], minor_tick);
}
PercentageCallback(major_tick, minor_tick);
}
Expand All @@ -138,10 +132,11 @@ void ShellScriptCallback::callback()
m_done = true;
else if (currPerc >= m_lastMajorPerc + 10.0)
{
std::ostringstream cmd;
std::string output;
Utils::run_shell_command(m_command + " " +
boost::lexical_cast<std::string>(static_cast<int>(currPerc)),
output);

cmd << m_command << " " << (int)currPerc;
Utils::run_shell_command(cmd.str(), output);
m_lastMajorPerc = currPerc;
m_lastMinorPerc = currPerc;
}
Expand Down
6 changes: 2 additions & 4 deletions src/PipelineReader.cpp
Expand Up @@ -41,8 +41,6 @@

#include <boost/property_tree/xml_parser.hpp>
#include <boost/optional.hpp>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string/trim.hpp>

#ifndef _WIN32
#include <wordexp.h>
Expand Down Expand Up @@ -161,7 +159,7 @@ Option PipelineReader::parseElement_Option(const ptree& tree)

std::string name = attrs["name"];
std::string value = tree.get_value<std::string>();
boost::algorithm::trim(value);
Utils::trim(value);
Option option(name, value);

// filenames in the XML are fixed up as follows:
Expand Down Expand Up @@ -352,7 +350,7 @@ void PipelineReader::parse_attributes(map_t& attrs, const ptree& tree)
{
std::string name = iter->first;
std::string value = tree.get<std::string>(name);
boost::algorithm::trim(value);
Utils::trim(value);

attrs[name] = value;
}
Expand Down
4 changes: 1 addition & 3 deletions src/PipelineWriter.cpp
Expand Up @@ -42,8 +42,6 @@

#include <boost/property_tree/xml_parser.hpp>
#include <boost/optional.hpp>
#include <boost/foreach.hpp>
#include <boost/algorithm/string.hpp>

#include <boost/property_tree/xml_parser.hpp>
#include <boost/property_tree/json_parser.hpp>
Expand Down Expand Up @@ -142,7 +140,7 @@ void PipelineWriter::writePipeline(const std::string& filename) const
const xml_parser::xml_writer_settings<char> settings(' ', 4);
#endif

if (boost::iequals(filename, "STDOUT"))
if (Utils::iequals(filename, "STDOUT"))
xml_parser::write_xml(std::cout, tree);
else
xml_parser::write_xml(filename, tree, std::locale(), settings);
Expand Down
2 changes: 0 additions & 2 deletions src/PointView.cpp
Expand Up @@ -37,8 +37,6 @@
#include <pdal/PointView.hpp>
#include <pdal/PointViewIter.hpp>

#include <boost/lexical_cast.hpp>

namespace pdal
{

Expand Down
21 changes: 0 additions & 21 deletions src/Stage.cpp
Expand Up @@ -362,27 +362,6 @@ void Stage::setSpatialReference(MetadataNode& m,
}
}

std::vector<Stage *> Stage::findStage(std::string name)
{
std::vector<Stage *> output;

if (boost::iequals(getName(), name))
output.push_back(this);

for (auto const& stage : m_inputs)
{
if (boost::iequals(stage->getName(), name))
output.push_back(stage);
if (stage->getInputs().size())
{
auto hits = stage->findStage(name);
if (hits.size())
output.insert(output.end(), hits.begin(), hits.end());
}
}

return output;
}

std::ostream& operator<<(std::ostream& ostr, const Stage& stage)
{
Expand Down
9 changes: 4 additions & 5 deletions src/StageFactory.cpp
Expand Up @@ -34,6 +34,7 @@

#include <pdal/StageFactory.hpp>
#include <pdal/PluginManager.hpp>
#include <pdal/util/FileUtils.hpp>

// filters
#include <chipper/ChipperFilter.hpp>
Expand Down Expand Up @@ -74,8 +75,6 @@
#include <text/TextWriter.hpp>
#include <null/NullWriter.hpp>

#include <boost/filesystem.hpp>

#include <sstream>
#include <string>
#include <stdio.h> // for funcptr
Expand All @@ -90,7 +89,7 @@ std::string StageFactory::inferReaderDriver(const std::string& filename)
if (Utils::iequals(http, "http"))
return "readers.greyhound";

std::string ext = boost::filesystem::extension(filename);
std::string ext = FileUtils::extension(filename);
std::map<std::string, std::string> drivers;
drivers["bin"] = "readers.terrasolid";
drivers["bpf"] = "readers.bpf";
Expand Down Expand Up @@ -125,7 +124,7 @@ std::string StageFactory::inferReaderDriver(const std::string& filename)

std::string StageFactory::inferWriterDriver(const std::string& filename)
{
std::string ext = Utils::tolower(boost::filesystem::extension(filename));
std::string ext = Utils::tolower(FileUtils::extension(filename));

std::map<std::string, std::string> drivers;
drivers["bpf"] = "writers.bpf";
Expand Down Expand Up @@ -162,7 +161,7 @@ std::string StageFactory::inferWriterDriver(const std::string& filename)
pdal::Options StageFactory::inferWriterOptionsChanges(
const std::string& filename)
{
std::string ext = boost::filesystem::extension(filename);
std::string ext = FileUtils::extension(filename);
ext = Utils::tolower(ext);
Options options;

Expand Down

0 comments on commit f4581cc

Please sign in to comment.