Skip to content

Commit

Permalink
Remove ptree from options.
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed Jan 20, 2016
1 parent ba51042 commit ff98b4a
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 84 deletions.
8 changes: 0 additions & 8 deletions include/pdal/Options.hpp
Expand Up @@ -38,7 +38,6 @@
#include <pdal/Metadata.hpp>
#include <pdal/util/Utils.hpp>

#include <boost/property_tree/ptree.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/optional.hpp>

Expand Down Expand Up @@ -118,9 +117,6 @@ class PDAL_DLL Option
}
}

/// Construct from an existing boost::property_tree
Option(const boost::property_tree::ptree& tree);

/// Equality operator
bool operator==(const Option& rhs) const
{
Expand Down Expand Up @@ -332,8 +328,6 @@ class PDAL_DLL Options

Options(const Option&);

Options(const boost::property_tree::ptree& tree);

// add an option
void add(const Option& option);

Expand Down Expand Up @@ -439,8 +433,6 @@ class PDAL_DLL Options
// returns true iff the option name is valid
bool hasOption(std::string const& name) const;

void dump() const;

std::vector<Option> getOptions(std::string const& name="") const;


Expand Down
38 changes: 0 additions & 38 deletions src/Options.cpp
Expand Up @@ -42,16 +42,6 @@
namespace pdal
{

Option::Option(const boost::property_tree::ptree& tree)
{
using namespace boost::property_tree;

m_name = tree.get<std::string>("Name");
m_value = tree.get<std::string>("Value");
m_description =
tree.count("Description") ? tree.get<std::string>("Description") : "";
}

#if !defined(PDAL_COMPILER_MSVC)

// explicit specialization:
Expand Down Expand Up @@ -104,17 +94,6 @@ bool Option::nameValid(const std::string& name, bool reportError)
}


Options::Options(const boost::property_tree::ptree& tree)
{
for (auto iter = tree.begin(); iter != tree.end(); ++iter)
{
assert(iter->first == "Option");
Option opt(iter->second);
add(opt);
}
}


void Options::add(const Option& option)
{
assert(Option::nameValid(option.getName(), true));
Expand Down Expand Up @@ -192,21 +171,4 @@ bool Options::hasOption(std::string const& name) const
return false;
}


void Options::dump() const
{
std::cout << *this;
}


std::ostream& operator<<(std::ostream& ostr, const Options& options)
{
const boost::property_tree::ptree tree = pdal::Utils::toPTree(options);

boost::property_tree::write_json(ostr, tree);

return ostr;
}


} // namespace pdal
40 changes: 2 additions & 38 deletions test/unit/OptionsTest.cpp
Expand Up @@ -102,6 +102,7 @@ TEST(OptionsTest, test_option_writing)
EXPECT_TRUE(str_s == ref_s);
}

/**
TEST(OptionsTest, test_option_reading)
{
// from an xml stream
Expand All @@ -124,6 +125,7 @@ TEST(OptionsTest, test_option_reading)
EXPECT_TRUE(opt_from_ptree.getValue<std::string>() == "17");
EXPECT_TRUE(opt_from_ptree.getValue<int>() == 17);
}
**/

TEST(OptionsTest, test_options_copy_ctor)
{
Expand Down Expand Up @@ -167,21 +169,6 @@ TEST(OptionsTest, test_options_writing)
EXPECT_TRUE(desc_s == "This is my stringy option.");
}

TEST(OptionsTest, test_options_reading)
{
const std::string ref = xml_header + "<Option>" + xml_int_ref + "</Option><Option>" + xml_str_ref + "</Option>";
std::istringstream istr(ref);

boost::property_tree::ptree tree;
boost::property_tree::read_xml(istr,tree);
Options opts_from_istr(tree);

const Option& opt = opts_from_istr.getOption("my_int");

EXPECT_TRUE(opt.getValue<std::string>() == "17");
EXPECT_TRUE(opt.getValue<int>() == 17);
}

TEST(OptionsTest, test_valid_options)
{
Options opts;
Expand Down Expand Up @@ -283,29 +270,6 @@ TEST(OptionsTest, implicitdefault)
EXPECT_EQ(slist.size(), (size_t)4);
}

TEST(OptionsTest, metadata)
{
Options ops;
ops.add("testa", "This is a test");
ops.add("testb", 56);
ops.add("testc", 27.5, "Testing testc");

Option op35("testd", 3.5);

ops.add("teste", "Testing option test e");

MetadataNode node;
ops.toMetadata(node);

std::string goodfile(Support::datapath("misc/opts2json_meta.txt"));
std::string testfile(Support::temppath("opts2json.txt"));
{
std::ofstream out(testfile);
Utils::toJSON(node, out);
}
EXPECT_TRUE(Support::compare_files(goodfile, testfile));
}

TEST(OptionsTest, conditional)
{
CropFilter s;
Expand Down

0 comments on commit ff98b4a

Please sign in to comment.