<commit_before>// -*-c++-*-

/*
 *
 * VRML2 file converter for OpenSceneGraph.
 *
 * authors : <NAME> (<EMAIL>),
 *           <NAME> (<EMAIL>),
 *           <NAME> (<EMAIL>)
 *
 *           (c) VRlab EPFL, Switzerland, 2004-2006
 *
 *           <NAME>, DTECTA (<EMAIL>)
 *           <NAME> (<EMAIL>)
 *
 */

#include "ReaderWriterVRML2.h"

#include <iostream>
#include <fstream>

#include <boost/algorithm/string/predicate.hpp>
#include <boost/utility.hpp>

#if defined(_MSC_VER)
#   pragma warning(disable: 4250)
#   pragma warning(disable: 4290)
#   pragma warning(disable: 4800)
#endif

#include <openvrml/browser.h>
#include <openvrml/node.h>

#include <osg/TexEnv>
#include <osg/CullFace>

#include <osg/Geode>
#include <osg/Geometry>
#include <osg/Material>
#include <osg/Image>
#include <osg/Texture2D>
#include <osg/Group>
#include <osg/MatrixTransform>
#include <osg/Light>
#include <osg/LightSource>
#include <osg/Depth>

#include <osg/Notify>
#include <osgDB/Registry>
#include <osgDB/ReadFile>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>

#include <assert.h>
#include <map>

// -------------------------------------------------------------------------------------
// OpenVRML helper class
// -------------------------------------------------------------------------------------
class resource_fetcher: public openvrml::resource_fetcher
{
    private:
        virtual std::auto_ptr<openvrml::resource_istream> do_get_resource(const std::string & uri)
        {
            using std::auto_ptr;
            using std::invalid_argument;
            using std::string;
            using openvrml::resource_istream;

            class file_resource_istream: public resource_istream
            {
                    std::string url_;
                    std::filebuf buf_;

                public:
                    explicit file_resource_istream(const std::string & path) :
                        resource_istream(&this->buf_)
                    {
                        //
                        // Note that the failbit is set in the constructor if no data
                        // can be read from the stream.  This is important.  If the
                        // failbit is not set on such a stream, OpenVRML will attempt
                        // to read data from a stream that cannot provide it.
                        //
                        if (!this->buf_.open(path.c_str(), ios_base::in | ios_base::binary))
                        {
                            this->setstate(ios_base::badbit);
                        }
                    }

                    void url(const std::string & str) throw (std::bad_alloc)
                    {
                        this->url_ = str;
                    }

                private:
                    virtual const std::string do_url() const throw ()
                    {
                        return this->url_;
                    }

                    virtual const std::string do_type() const throw ()
                    {
                        //
                        // A real application should use OS facilities for this;
                        // however, that is beyond the scope of this example (which
                        // is intended to be portable and stupid).
                        //
                        using std::find;
                        using std::string;
                        using boost::algorithm::iequals;
                        using boost::next;
                        string media_type = "application/octet-stream";

                        const string::const_reverse_iterator dot_pos = find(this->url_.rbegin(), this->url_.rend(), '.');
                        if (dot_pos == this->url_.rend() || next(dot_pos.base()) == this->url_.end())
                        {
                            return media_type;
                        }

                        const string::const_iterator hash_pos = find(next(dot_pos.base()), this->url_.end(), '#');
                        const string ext(dot_pos.base(), hash_pos);

                        if (iequals(ext, "wrl") || iequals(ext, "vrml"))
                        {
                            media_type = "model/vrml";
                        }
                        else if (iequals(ext, "png"))
                        {
                            media_type = "image/png";
                        }
                        else if (iequals(ext, "jpg") || iequals(ext, "jpeg"))
                        {
                            media_type = "image/jpeg";
                        }
                        return media_type;
                    }
<commit_msg>From <NAME>, "Here is a minor fix for the vrml plugin when building with Visual Studio 2010.  2010 has updated STL/TR1 libraries that create a naming conflict with the current source.  The fix is to remove the 'using boost::next' line and use the fully-qualified boost::next to get rid of the ambiguity.  Here is the patch and attached changes."<commit_after>// -*-c++-*-

/*
 *
 * VRML2 file converter for OpenSceneGraph.
 *
 * authors : <NAME> (<EMAIL>),
 *           <NAME> (<EMAIL>),
 *           <NAME> (<EMAIL>)
 *
 *           (c) VRlab EPFL, Switzerland, 2004-2006
 *
 *           <NAME>, DTECTA (<EMAIL>)
 *           <NAME> (<EMAIL>)
 *
 */

#include "ReaderWriterVRML2.h"

#include <iostream>
#include <fstream>

#include <boost/algorithm/string/predicate.hpp>
#include <boost/utility.hpp>

#if defined(_MSC_VER)
#   pragma warning(disable: 4250)
#   pragma warning(disable: 4290)
#   pragma warning(disable: 4800)
#endif

#include <openvrml/browser.h>
#include <openvrml/node.h>

#include <osg/TexEnv>
#include <osg/CullFace>

#include <osg/Geode>
#include <osg/Geometry>
#include <osg/Material>
#include <osg/Image>
#include <osg/Texture2D>
#include <osg/Group>
#include <osg/MatrixTransform>
#include <osg/Light>
#include <osg/LightSource>
#include <osg/Depth>

#include <osg/Notify>
#include <osgDB/Registry>
#include <osgDB/ReadFile>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>

#include <assert.h>
#include <map>

// -------------------------------------------------------------------------------------
// OpenVRML helper class
// -------------------------------------------------------------------------------------
class resource_fetcher: public openvrml::resource_fetcher
{
    private:
        virtual std::auto_ptr<openvrml::resource_istream> do_get_resource(const std::string & uri)
        {
            using std::auto_ptr;
            using std::invalid_argument;
            using std::string;
            using openvrml::resource_istream;

            class file_resource_istream: public resource_istream
            {
                    std::string url_;
                    std::filebuf buf_;

                public:
                    explicit file_resource_istream(const std::string & path) :
                        resource_istream(&this->buf_)
                    {
                        //
                        // Note that the failbit is set in the constructor if no data
                        // can be read from the stream.  This is important.  If the
                        // failbit is not set on such a stream, OpenVRML will attempt
                        // to read data from a stream that cannot provide it.
                        //
                        if (!this->buf_.open(path.c_str(), ios_base::in | ios_base::binary))
                        {
                            this->setstate(ios_base::badbit);
                        }
                    }

                    void url(const std::string & str) throw (std::bad_alloc)
                    {
                        this->url_ = str;
                    }

                private:
                    virtual const std::string do_url() const throw ()
                    {
                        return this->url_;
                    }

                    virtual const std::string do_type() const throw ()
                    {
                        //
                        // A real application should use OS facilities for this;
                        // however, that is beyond the scope of this example (which
                        // is intended to be portable and stupid).
                        //
                        using std::find;
                        using std::string;
                        using boost::algorithm::iequals;
                        string media_type = "application/octet-stream";

                        const string::const_reverse_iterator dot_pos = find(this->url_.rbegin(), this->url_.rend(), '.');
                        if (dot_pos == this->url_.rend() || boost::next(dot_pos.base()) == this->url_.end())
                        {
                            return media_type;
                        }

                        const string::const_iterator hash_pos = find(boost::next(dot_pos.base()), this->url_.end(), '#');
                        const string ext(dot_pos.base(), hash_pos);

                        if (iequals(ext, "wrl") || iequals(ext, "vrml"))
                        {
                            media_type = "model/vrml";
                        }
                        else if (iequals(ext, "png"))
                        {
                            media_type = "image/png";
                        }
                        else if (iequals(ext, "jpg") || iequals(ext, "jpeg"))
                        {
                            media_type = "image/jpeg";
                        }
                        return media_type;
                    }

{'fraction_non_alphanumeric': 0.13894345084255144, 'fraction_numerical': 0.005685929907991316, 'mean_word_length': 1.2132235186456188, 'pattern_counts': {'":': 0, '<': 76, '<?xml version=': 0, '>': 96, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1071860', 'n_tokens_mistral': 2577, 'n_tokens_neox': 2402, 'n_words': 609}