made PLY parser C++11-compatible

metadata
Wenzel Jakob 2017-07-28 22:07:24 +02:00
parent f995a91d4d
commit c510050e0b
3 changed files with 125 additions and 209 deletions

View File

@ -22,24 +22,7 @@
#include <mitsuba/core/fstream.h>
#include <mitsuba/core/timer.h>
#include <ply/ply_parser.hpp>
#if MTS_USE_BOOST_TR1
#include <boost/tr1/functional.hpp>
#else
#if defined(_MSC_VER) && (_MSC_VER >= 1600)
#include <functional>
#else
#include <tr1/functional>
#endif
#endif
#if !MTS_USE_BOOST_TR1 && defined(_MSC_VER) && (_MSC_VER >= 1600)
# define PLY_USE_NULLPTR 1
#else
# define PLY_USE_NULLPTR 0
#endif
using namespace std::tr1::placeholders;
MTS_NAMESPACE_BEGIN
@ -160,43 +143,37 @@ public:
message.c_str());
}
template<typename ValueType> std::tr1::function <void (ValueType)>
template<typename ValueType> std::function <void (ValueType)>
scalar_property_definition_callback(const std::string& element_name,
const std::string& property_name);
template<typename SizeType, typename IndexType> std::tr1::tuple<std::tr1::function<void (SizeType)>,
std::tr1::function<void (IndexType)>, std::tr1::function<void ()> >
template<typename SizeType, typename IndexType> std::tuple<std::function<void (SizeType)>,
std::function<void (IndexType)>, std::function<void ()> >
list_property_definition_callback(const std::string& element_name,
const std::string& property_name);
std::tr1::tuple<std::tr1::function<void()>, std::tr1::function<void()> >
std::tuple<std::function<void()>, std::function<void()> >
element_definition_callback(const std::string& element_name, std::size_t count) {
if (element_name == "vertex") {
m_vertexCount = count;
m_positions = new Point[m_vertexCount];
return std::tr1::tuple<std::tr1::function<void()>,
std::tr1::function<void()> >(
std::tr1::bind(&PLYLoader::vertex_begin_callback, this),
std::tr1::bind(&PLYLoader::vertex_end_callback, this)
return std::tuple<std::function<void()>,
std::function<void()> >(
std::bind(&PLYLoader::vertex_begin_callback, this),
std::bind(&PLYLoader::vertex_end_callback, this)
);
} else if (element_name == "face") {
m_faceCount = count;
m_triangles = new Triangle[m_faceCount*2];
return std::tr1::tuple<std::tr1::function<void()>,
std::tr1::function<void()> >(
std::tr1::bind(&PLYLoader::face_begin_callback, this),
std::tr1::bind(&PLYLoader::face_end_callback, this)
return std::tuple<std::function<void()>,
std::function<void()> >(
std::bind(&PLYLoader::face_begin_callback, this),
std::bind(&PLYLoader::face_end_callback, this)
);
} else {
#if PLY_USE_NULLPTR
return
std::tr1::tuple<std::tr1::function<void()>,
std::tr1::function<void()> >(nullptr, nullptr);
#else
return
std::tr1::tuple<std::tr1::function<void()>,
std::tr1::function<void()> >(0, 0);
#endif
std::tuple<std::function<void()>,
std::function<void()> >(nullptr, nullptr);
}
}
@ -325,206 +302,174 @@ private:
bool m_sRGB;
};
template<> std::tr1::function <void (ply::float32)>
template<> std::function <void (ply::float32)>
PLYLoader::scalar_property_definition_callback(const std::string& element_name,
const std::string& property_name) {
if (element_name == "vertex") {
if (property_name == "x") {
return std::tr1::bind(&PLYLoader::vertex_x_callback, this, _1);
return std::bind(&PLYLoader::vertex_x_callback, this, _1);
} else if (property_name == "y") {
return std::tr1::bind(&PLYLoader::vertex_y_callback, this, _1);
return std::bind(&PLYLoader::vertex_y_callback, this, _1);
} else if (property_name == "z") {
return std::tr1::bind(&PLYLoader::vertex_z_callback, this, _1);
return std::bind(&PLYLoader::vertex_z_callback, this, _1);
} else if (property_name == "nx") {
m_hasNormals = true;
return std::tr1::bind(&PLYLoader::normal_x_callback, this, _1);
return std::bind(&PLYLoader::normal_x_callback, this, _1);
} else if (property_name == "ny") {
return std::tr1::bind(&PLYLoader::normal_y_callback, this, _1);
return std::bind(&PLYLoader::normal_y_callback, this, _1);
} else if (property_name == "nz") {
return std::tr1::bind(&PLYLoader::normal_z_callback, this, _1);
return std::bind(&PLYLoader::normal_z_callback, this, _1);
} else if (property_name == "u" || property_name == "texture_u" || property_name == "s") {
m_hasTexCoords = true;
return std::tr1::bind(&PLYLoader::texcoord_u_callback, this, _1);
return std::bind(&PLYLoader::texcoord_u_callback, this, _1);
} else if (property_name == "v" || property_name == "texture_v" || property_name == "t") {
return std::tr1::bind(&PLYLoader::texcoord_v_callback, this, _1);
return std::bind(&PLYLoader::texcoord_v_callback, this, _1);
} else if (property_name == "diffuse_red" || property_name == "red") {
return std::tr1::bind(&PLYLoader::red_callback, this, _1);
return std::bind(&PLYLoader::red_callback, this, _1);
} else if (property_name == "diffuse_green" || property_name == "green") {
return std::tr1::bind(&PLYLoader::green_callback, this, _1);
return std::bind(&PLYLoader::green_callback, this, _1);
} else if (property_name == "diffuse_blue" || property_name == "blue") {
return std::tr1::bind(&PLYLoader::blue_callback, this, _1);
return std::bind(&PLYLoader::blue_callback, this, _1);
}
} else if (element_name == "face") {
if (property_name == "diffuse_red" || property_name == "red") {
return std::tr1::bind(&PLYLoader::face_red_callback, this, _1);
return std::bind(&PLYLoader::face_red_callback, this, _1);
} else if (property_name == "diffuse_green" || property_name == "green") {
return std::tr1::bind(&PLYLoader::face_green_callback, this, _1);
return std::bind(&PLYLoader::face_green_callback, this, _1);
} else if (property_name == "diffuse_blue" || property_name == "blue") {
return std::tr1::bind(&PLYLoader::face_blue_callback, this, _1);
return std::bind(&PLYLoader::face_blue_callback, this, _1);
}
}
#if PLY_USE_NULLPTR
return nullptr;
#else
return 0;
#endif
}
template<> std::tr1::function <void (ply::uint8)>
template<> std::function <void (ply::uint8)>
PLYLoader::scalar_property_definition_callback(const std::string& element_name,
const std::string& property_name) {
if (element_name == "vertex") {
if (property_name == "diffuse_red" || property_name == "red") {
return std::tr1::bind(&PLYLoader::red_callback_uint8, this, _1);
return std::bind(&PLYLoader::red_callback_uint8, this, _1);
} else if (property_name == "diffuse_green" || property_name == "green") {
return std::tr1::bind(&PLYLoader::green_callback_uint8, this, _1);
return std::bind(&PLYLoader::green_callback_uint8, this, _1);
} else if (property_name == "diffuse_blue" || property_name == "blue") {
return std::tr1::bind(&PLYLoader::blue_callback_uint8, this, _1);
return std::bind(&PLYLoader::blue_callback_uint8, this, _1);
}
} else if (element_name == "face") {
if (property_name == "diffuse_red" || property_name == "red") {
return std::tr1::bind(&PLYLoader::face_red_callback_uint8, this, _1);
return std::bind(&PLYLoader::face_red_callback_uint8, this, _1);
} else if (property_name == "diffuse_green" || property_name == "green") {
return std::tr1::bind(&PLYLoader::face_green_callback_uint8, this, _1);
return std::bind(&PLYLoader::face_green_callback_uint8, this, _1);
} else if (property_name == "diffuse_blue" || property_name == "blue") {
return std::tr1::bind(&PLYLoader::face_blue_callback_uint8, this, _1);
return std::bind(&PLYLoader::face_blue_callback_uint8, this, _1);
}
}
#if PLY_USE_NULLPTR
return nullptr;
#else
return 0;
#endif
}
template<> std::tr1::tuple<std::tr1::function<void (ply::uint8)>,
std::tr1::function<void (ply::int32)>, std::tr1::function<void ()> >
template<> std::tuple<std::function<void (ply::uint8)>,
std::function<void (ply::int32)>, std::function<void ()> >
PLYLoader::list_property_definition_callback(const std::string& element_name,
const std::string& property_name) {
if ((element_name == "face") && (property_name == "vertex_indices" || property_name == "vertex_index")) {
return std::tr1::tuple<std::tr1::function<void (ply::uint8)>,
std::tr1::function<void (ply::int32)>, std::tr1::function<void ()> >(
std::tr1::bind(&PLYLoader::face_vertex_indices_begin_uint8, this, _1),
std::tr1::bind(&PLYLoader::face_vertex_indices_element_int32, this, _1),
std::tr1::bind(&PLYLoader::face_vertex_indices_end, this)
return std::tuple<std::function<void (ply::uint8)>,
std::function<void (ply::int32)>, std::function<void ()> >(
std::bind(&PLYLoader::face_vertex_indices_begin_uint8, this, _1),
std::bind(&PLYLoader::face_vertex_indices_element_int32, this, _1),
std::bind(&PLYLoader::face_vertex_indices_end, this)
);
} else {
#if PLY_USE_NULLPTR
return std::tr1::tuple<std::tr1::function<void (ply::uint8)>,
std::tr1::function<void (ply::int32)>,
std::tr1::function<void ()> >(nullptr, nullptr, nullptr);
#else
return std::tr1::tuple<std::tr1::function<void (ply::uint8)>,
std::tr1::function<void (ply::int32)>,
std::tr1::function<void ()> >(0, 0, 0);
#endif
return std::tuple<std::function<void (ply::uint8)>,
std::function<void (ply::int32)>,
std::function<void ()> >(nullptr, nullptr, nullptr);
}
}
template<> std::tr1::tuple<std::tr1::function<void (ply::uint32)>,
std::tr1::function<void (ply::int32)>, std::tr1::function<void ()> >
template<> std::tuple<std::function<void (ply::uint32)>,
std::function<void (ply::int32)>, std::function<void ()> >
PLYLoader::list_property_definition_callback(const std::string& element_name,
const std::string& property_name) {
if ((element_name == "face") && (property_name == "vertex_indices" || property_name == "vertex_index")) {
return std::tr1::tuple<std::tr1::function<void (ply::uint32)>,
std::tr1::function<void (ply::int32)>, std::tr1::function<void ()> >(
std::tr1::bind(&PLYLoader::face_vertex_indices_begin_uint32, this, _1),
std::tr1::bind(&PLYLoader::face_vertex_indices_element_int32, this, _1),
std::tr1::bind(&PLYLoader::face_vertex_indices_end, this)
return std::tuple<std::function<void (ply::uint32)>,
std::function<void (ply::int32)>, std::function<void ()> >(
std::bind(&PLYLoader::face_vertex_indices_begin_uint32, this, _1),
std::bind(&PLYLoader::face_vertex_indices_element_int32, this, _1),
std::bind(&PLYLoader::face_vertex_indices_end, this)
);
} else {
#if PLY_USE_NULLPTR
return std::tr1::tuple<std::tr1::function<void (ply::uint32)>,
std::tr1::function<void (ply::int32)>,
std::tr1::function<void ()> >(nullptr, nullptr, nullptr);
#else
return std::tr1::tuple<std::tr1::function<void (ply::uint32)>,
std::tr1::function<void (ply::int32)>,
std::tr1::function<void ()> >(0, 0, 0);
#endif
return std::tuple<std::function<void (ply::uint32)>,
std::function<void (ply::int32)>,
std::function<void ()> >(0, 0, 0);
}
}
template<> std::tr1::tuple<std::tr1::function<void (ply::uint8)>,
std::tr1::function<void (ply::uint32)>, std::tr1::function<void ()> >
template<> std::tuple<std::function<void (ply::uint8)>,
std::function<void (ply::uint32)>, std::function<void ()> >
PLYLoader::list_property_definition_callback(const std::string& element_name,
const std::string& property_name) {
if ((element_name == "face") && (property_name == "vertex_indices" || property_name == "vertex_index")) {
return std::tr1::tuple<std::tr1::function<void (ply::uint8)>,
std::tr1::function<void (ply::uint32)>, std::tr1::function<void ()> >(
std::tr1::bind(&PLYLoader::face_vertex_indices_begin_uint8, this, _1),
std::tr1::bind(&PLYLoader::face_vertex_indices_element_uint32, this, _1),
std::tr1::bind(&PLYLoader::face_vertex_indices_end, this)
return std::tuple<std::function<void (ply::uint8)>,
std::function<void (ply::uint32)>, std::function<void ()> >(
std::bind(&PLYLoader::face_vertex_indices_begin_uint8, this, _1),
std::bind(&PLYLoader::face_vertex_indices_element_uint32, this, _1),
std::bind(&PLYLoader::face_vertex_indices_end, this)
);
} else {
#if PLY_USE_NULLPTR
return std::tr1::tuple<std::tr1::function<void (ply::uint8)>,
std::tr1::function<void (ply::uint32)>,
std::tr1::function<void ()> >(nullptr, nullptr, nullptr);
#else
return std::tr1::tuple<std::tr1::function<void (ply::uint8)>,
std::tr1::function<void (ply::uint32)>,
std::tr1::function<void ()> >(0, 0, 0);
#endif
return std::tuple<std::function<void (ply::uint8)>,
std::function<void (ply::uint32)>,
std::function<void ()> >(0, 0, 0);
}
}
template<> std::tr1::tuple<std::tr1::function<void (ply::uint32)>,
std::tr1::function<void (ply::uint32)>, std::tr1::function<void ()> >
template<> std::tuple<std::function<void (ply::uint32)>,
std::function<void (ply::uint32)>, std::function<void ()> >
PLYLoader::list_property_definition_callback(const std::string& element_name,
const std::string& property_name) {
if ((element_name == "face") && (property_name == "vertex_indices" || property_name == "vertex_index")) {
return std::tr1::tuple<std::tr1::function<void (ply::uint32)>,
std::tr1::function<void (ply::uint32)>, std::tr1::function<void ()> >(
std::tr1::bind(&PLYLoader::face_vertex_indices_begin_uint32, this, _1),
std::tr1::bind(&PLYLoader::face_vertex_indices_element_uint32, this, _1),
std::tr1::bind(&PLYLoader::face_vertex_indices_end, this)
return std::tuple<std::function<void (ply::uint32)>,
std::function<void (ply::uint32)>, std::function<void ()> >(
std::bind(&PLYLoader::face_vertex_indices_begin_uint32, this, _1),
std::bind(&PLYLoader::face_vertex_indices_element_uint32, this, _1),
std::bind(&PLYLoader::face_vertex_indices_end, this)
);
} else {
#if PLY_USE_NULLPTR
return std::tr1::tuple<std::tr1::function<void (ply::uint32)>,
std::tr1::function<void (ply::uint32)>,
std::tr1::function<void ()> >(nullptr, nullptr, nullptr);
#else
return std::tr1::tuple<std::tr1::function<void (ply::uint32)>,
std::tr1::function<void (ply::uint32)>,
std::tr1::function<void ()> >(0, 0, 0);
#endif
return std::tuple<std::function<void (ply::uint32)>,
std::function<void (ply::uint32)>,
std::function<void ()> >(0, 0, 0);
}
}
void PLYLoader::loadPLY(const fs::path &path) {
ply::ply_parser ply_parser;
ply_parser.info_callback(std::tr1::bind(&PLYLoader::info_callback,
this, std::tr1::ref(m_name), _1, _2));
ply_parser.warning_callback(std::tr1::bind(&PLYLoader::warning_callback,
this, std::tr1::ref(m_name), _1, _2));
ply_parser.error_callback(std::tr1::bind(&PLYLoader::error_callback,
this, std::tr1::ref(m_name), _1, _2));
ply_parser.info_callback(std::bind(&PLYLoader::info_callback,
this, std::ref(m_name), _1, _2));
ply_parser.warning_callback(std::bind(&PLYLoader::warning_callback,
this, std::ref(m_name), _1, _2));
ply_parser.error_callback(std::bind(&PLYLoader::error_callback,
this, std::ref(m_name), _1, _2));
ply_parser.element_definition_callback(std::tr1::bind(&PLYLoader::element_definition_callback,
ply_parser.element_definition_callback(std::bind(&PLYLoader::element_definition_callback,
this, _1, _2));
ply::ply_parser::scalar_property_definition_callbacks_type scalar_property_definition_callbacks;
ply::ply_parser::list_property_definition_callbacks_type list_property_definition_callbacks;
ply::at<ply::float32>(scalar_property_definition_callbacks) = std::tr1::bind(
ply::at<ply::float32>(scalar_property_definition_callbacks) = std::bind(
&PLYLoader::scalar_property_definition_callback<ply::float32>, this, _1, _2);
ply::at<ply::uint8>(scalar_property_definition_callbacks) = std::tr1::bind(
ply::at<ply::uint8>(scalar_property_definition_callbacks) = std::bind(
&PLYLoader::scalar_property_definition_callback<ply::uint8>, this, _1, _2);
ply::at<ply::uint8, ply::int32>(list_property_definition_callbacks) = std::tr1::bind(
ply::at<ply::uint8, ply::int32>(list_property_definition_callbacks) = std::bind(
&PLYLoader::list_property_definition_callback<ply::uint8, ply::int32>, this, _1, _2);
ply::at<ply::uint32, ply::int32>(list_property_definition_callbacks) = std::tr1::bind(
ply::at<ply::uint32, ply::int32>(list_property_definition_callbacks) = std::bind(
&PLYLoader::list_property_definition_callback<ply::uint32, ply::int32>, this, _1, _2);
ply::at<ply::uint8, ply::uint32>(list_property_definition_callbacks) = std::tr1::bind(
ply::at<ply::uint8, ply::uint32>(list_property_definition_callbacks) = std::bind(
&PLYLoader::list_property_definition_callback<ply::uint8, ply::uint32>, this, _1, _2);
ply::at<ply::uint32, ply::uint32>(list_property_definition_callbacks) = std::tr1::bind(
ply::at<ply::uint32, ply::uint32>(list_property_definition_callbacks) = std::bind(
&PLYLoader::list_property_definition_callback<ply::uint32, ply::uint32>, this, _1, _2);
ply_parser.scalar_property_definition_callbacks(scalar_property_definition_callbacks);

View File

@ -9,7 +9,7 @@ bool ply::ply_parser::parse(std::istream& istream)
std::size_t number_of_format_statements = 0, number_of_element_statements = 0, number_of_property_statements = 0, number_of_obj_info_statements = 0, number_of_comment_statements = 0;
format_type format = ascii_format;
std::vector< std::tr1::shared_ptr<element> > elements;
std::vector< std::shared_ptr<element> > elements;
// magic
char magic[3];
@ -103,7 +103,7 @@ bool ply::ply_parser::parse(std::istream& istream)
}
return false;
}
std::vector< std::tr1::shared_ptr<element> >::const_iterator iterator;
std::vector< std::shared_ptr<element> >::const_iterator iterator;
for (iterator = elements.begin(); iterator != elements.end(); ++iterator) {
const struct element& element = *(iterator->get());
if (element.name == name) {
@ -121,8 +121,8 @@ bool ply::ply_parser::parse(std::istream& istream)
if (element_definition_callbacks_) {
element_callbacks = element_definition_callbacks_(name, count);
}
std::tr1::shared_ptr<element> element_ptr(new element(name, count, std::tr1::get<0>(element_callbacks), std::tr1::get<1>(element_callbacks)));
elements.push_back(std::tr1::shared_ptr<element>(element_ptr));
std::shared_ptr<element> element_ptr(new element(name, count, std::get<0>(element_callbacks), std::get<1>(element_callbacks)));
elements.push_back(std::shared_ptr<element>(element_ptr));
current_element_ = element_ptr.get();
}
@ -154,7 +154,7 @@ bool ply::ply_parser::parse(std::istream& istream)
}
return false;
}
std::vector< std::tr1::shared_ptr<property> >::const_iterator iterator;
std::vector< std::shared_ptr<property> >::const_iterator iterator;
for (iterator = current_element_->properties.begin(); iterator != current_element_->properties.end(); ++iterator) {
const struct property& property = *(iterator->get());
if (property.name == name) {
@ -216,7 +216,7 @@ bool ply::ply_parser::parse(std::istream& istream)
}
return false;
}
std::vector< std::tr1::shared_ptr<property> >::const_iterator iterator;
std::vector< std::shared_ptr<property> >::const_iterator iterator;
for (iterator = current_element_->properties.begin(); iterator != current_element_->properties.end(); ++iterator) {
const struct property& property = *(iterator->get());
if (property.name == name) {
@ -392,7 +392,7 @@ bool ply::ply_parser::parse(std::istream& istream)
// ascii
if (format == ascii_format) {
for (std::vector< std::tr1::shared_ptr<element> >::const_iterator element_iterator = elements.begin(); element_iterator != elements.end(); ++element_iterator) {
for (std::vector< std::shared_ptr<element> >::const_iterator element_iterator = elements.begin(); element_iterator != elements.end(); ++element_iterator) {
struct element& element = *(element_iterator->get());
for (std::size_t element_index = 0; element_index < element.count; ++element_index) {
if (element.begin_element_callback) {
@ -408,7 +408,7 @@ bool ply::ply_parser::parse(std::istream& istream)
std::istringstream stringstream(line);
stringstream.unsetf(std::ios_base::skipws);
stringstream >> std::ws;
for (std::vector< std::tr1::shared_ptr<property> >::const_iterator property_iterator = element.properties.begin(); property_iterator != element.properties.end(); ++property_iterator) {
for (std::vector< std::shared_ptr<property> >::const_iterator property_iterator = element.properties.begin(); property_iterator != element.properties.end(); ++property_iterator) {
struct property& property = *(property_iterator->get());
if (property.parse(*this, format, stringstream) == false) {
return false;
@ -437,13 +437,13 @@ bool ply::ply_parser::parse(std::istream& istream)
// binary
else {
for (std::vector< std::tr1::shared_ptr<element> >::const_iterator element_iterator = elements.begin(); element_iterator != elements.end(); ++element_iterator) {
for (std::vector< std::shared_ptr<element> >::const_iterator element_iterator = elements.begin(); element_iterator != elements.end(); ++element_iterator) {
struct element& element = *(element_iterator->get());
for (std::size_t element_index = 0; element_index < element.count; ++element_index) {
if (element.begin_element_callback) {
element.begin_element_callback();
}
for (std::vector< std::tr1::shared_ptr<property> >::const_iterator property_iterator = element.properties.begin(); property_iterator != element.properties.end(); ++property_iterator) {
for (std::vector< std::shared_ptr<property> >::const_iterator property_iterator = element.properties.begin(); property_iterator != element.properties.end(); ++property_iterator) {
struct property& property = *(property_iterator->get());
if (property.parse(*this, format, istream) == false) {
return false;

View File

@ -9,42 +9,11 @@
#include <vector>
#include <cctype>
#if defined(__clang__)
# define MTS_USE_BOOST_TR1 (!__has_feature(cxx_variadic_templates))
# define ADT_WORKAROUND 1
#else
# if defined(_MSC_VER)
# if _MSC_VER < 1600
# define MTS_USE_BOOST_TR1 1
# else
# define MTS_USE_BOOST_TR1 0
# define ADT_WORKAROUND 1
# endif
# elif defined(__INTEL_COMPILER) && !defined(__OSX__)
# define MTS_USE_BOOST_TR1 1
# else
# define MTS_USE_BOOST_TR1 0
# endif
#endif
#if !defined(ADT_WORKAROUND) && (defined(__INTEL_COMPILER) || defined(__INTELLISENSE__))
#define ADT_WORKAROUND 1
#endif
#if MTS_USE_BOOST_TR1
#include <boost/tr1/functional.hpp>
#include <boost/tr1/memory.hpp>
#include <boost/tr1/tuple.hpp>
#else
#if defined(_MSC_VER) && (_MSC_VER >= 1600)
#include <functional>
#include <memory>
#include <tuple>
#else
#include <tr1/functional>
#include <tr1/memory>
#endif
#endif
#include <boost/mpl/fold.hpp>
#include <boost/mpl/inherit.hpp>
@ -57,38 +26,40 @@
#include <ply/byte_order.hpp>
#include <ply/io_operators.hpp>
using namespace std::placeholders;
namespace ply {
class ply_parser
{
public:
typedef std::tr1::function<void (std::size_t, const std::string&)> info_callback_type;
typedef std::tr1::function<void (std::size_t, const std::string&)> warning_callback_type;
typedef std::tr1::function<void (std::size_t, const std::string&)> error_callback_type;
typedef std::function<void (std::size_t, const std::string&)> info_callback_type;
typedef std::function<void (std::size_t, const std::string&)> warning_callback_type;
typedef std::function<void (std::size_t, const std::string&)> error_callback_type;
typedef std::tr1::function<void ()> magic_callback_type;
typedef std::tr1::function<void (format_type, const std::string&)> format_callback_type;
typedef std::tr1::function<void (const std::string&)> comment_callback_type;
typedef std::tr1::function<void (const std::string&)> obj_info_callback_type;
typedef std::tr1::function<bool ()> end_header_callback_type;
typedef std::function<void ()> magic_callback_type;
typedef std::function<void (format_type, const std::string&)> format_callback_type;
typedef std::function<void (const std::string&)> comment_callback_type;
typedef std::function<void (const std::string&)> obj_info_callback_type;
typedef std::function<bool ()> end_header_callback_type;
typedef std::tr1::function<void()> begin_element_callback_type;
typedef std::tr1::function<void()> end_element_callback_type;
typedef std::tr1::tuple<begin_element_callback_type, end_element_callback_type> element_callbacks_type;
typedef std::tr1::function<element_callbacks_type (const std::string&, std::size_t)> element_definition_callback_type;
typedef std::function<void()> begin_element_callback_type;
typedef std::function<void()> end_element_callback_type;
typedef std::tuple<begin_element_callback_type, end_element_callback_type> element_callbacks_type;
typedef std::function<element_callbacks_type (const std::string&, std::size_t)> element_definition_callback_type;
template <typename ScalarType>
struct scalar_property_callback_type
{
typedef std::tr1::function<void (ScalarType)> type;
typedef std::function<void (ScalarType)> type;
};
template <typename ScalarType>
struct scalar_property_definition_callback_type
{
typedef typename scalar_property_callback_type<ScalarType>::type scalar_property_callback_type;
typedef std::tr1::function<scalar_property_callback_type (const std::string&, const std::string&)> type;
typedef std::function<scalar_property_callback_type (const std::string&, const std::string&)> type;
};
typedef boost::mpl::vector<int8, int16, int32, uint8, uint16, uint32, float32, float64> scalar_types;
@ -138,19 +109,19 @@ public:
template <typename SizeType, typename ScalarType>
struct list_property_begin_callback_type
{
typedef std::tr1::function<void (SizeType)> type;
typedef std::function<void (SizeType)> type;
};
template <typename SizeType, typename ScalarType>
struct list_property_element_callback_type
{
typedef std::tr1::function<void (ScalarType)> type;
typedef std::function<void (ScalarType)> type;
};
template <typename SizeType, typename ScalarType>
struct list_property_end_callback_type
{
typedef std::tr1::function<void ()> type;
typedef std::function<void ()> type;
};
template <typename SizeType, typename ScalarType>
@ -159,8 +130,8 @@ public:
typedef typename list_property_begin_callback_type<SizeType, ScalarType>::type list_property_begin_callback_type;
typedef typename list_property_element_callback_type<SizeType, ScalarType>::type list_property_element_callback_type;
typedef typename list_property_end_callback_type<SizeType, ScalarType>::type list_property_end_callback_type;
typedef std::tr1::function<
std::tr1::tuple<
typedef std::function<
std::tuple<
list_property_begin_callback_type,
list_property_element_callback_type,
list_property_end_callback_type
@ -288,7 +259,7 @@ private:
std::size_t count;
begin_element_callback_type begin_element_callback;
end_element_callback_type end_element_callback;
std::vector<std::tr1::shared_ptr<property> > properties;
std::vector<std::shared_ptr<property> > properties;
};
flags_type flags_;
@ -398,7 +369,7 @@ inline void ply::ply_parser::parse_scalar_property_definition(const std::string&
warning_callback_(line_number_, "property '" + std::string(type_traits<scalar_type>::name()) + " " + property_name + "' of element '" + current_element_->name + "' is not handled");
}
}
current_element_->properties.push_back(std::tr1::shared_ptr<property>(new scalar_property<scalar_type>(property_name, scalar_property_callback)));
current_element_->properties.push_back(std::shared_ptr<property>(new scalar_property<scalar_type>(property_name, scalar_property_callback)));
}
template <typename SizeType, typename ScalarType>
@ -414,16 +385,16 @@ inline void ply::ply_parser::parse_list_property_definition(const std::string& p
typedef typename list_property_begin_callback_type<size_type, scalar_type>::type list_property_begin_callback_type;
typedef typename list_property_element_callback_type<size_type, scalar_type>::type list_property_element_callback_type;
typedef typename list_property_end_callback_type<size_type, scalar_type>::type list_property_end_callback_type;
std::tr1::tuple<list_property_begin_callback_type, list_property_element_callback_type, list_property_end_callback_type> list_property_callbacks;
std::tuple<list_property_begin_callback_type, list_property_element_callback_type, list_property_end_callback_type> list_property_callbacks;
if (list_property_definition_callback) {
list_property_callbacks = list_property_definition_callback(current_element_->name, property_name);
}
if (!std::tr1::get<0>(list_property_callbacks) || !std::tr1::get<1>(list_property_callbacks) || !std::tr1::get<2>(list_property_callbacks)) {
if (!std::get<0>(list_property_callbacks) || !std::get<1>(list_property_callbacks) || !std::get<2>(list_property_callbacks)) {
if (warning_callback_) {
warning_callback_(line_number_, "property 'list " + std::string(type_traits<size_type>::name()) + " " + std::string(type_traits<scalar_type>::name()) + " " + property_name + "' of element '" + current_element_->name + "' is not handled");
}
}
current_element_->properties.push_back(std::tr1::shared_ptr<property>(new list_property<size_type, scalar_type>(property_name, std::tr1::get<0>(list_property_callbacks), std::tr1::get<1>(list_property_callbacks), std::tr1::get<2>(list_property_callbacks))));
current_element_->properties.push_back(std::shared_ptr<property>(new list_property<size_type, scalar_type>(property_name, std::get<0>(list_property_callbacks), std::get<1>(list_property_callbacks), std::get<2>(list_property_callbacks))));
}
template <typename ScalarType>