<commit_before>
#include <iostream>
#include <sstream>
#include <array>
#include <string>
#include <type_traits>

#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h>

#include <glbinding/Meta.h>
#include <glbinding/ContextInfo.h>
#include <glbinding/Version.h>
#include <glbinding/Binding.h>

#include <glbinding/gl/types.h>
#include <glbinding/gl/enum.h>
#include <glbinding/gl/functions.h>
#include <glbinding/gl/boolean.h>


using namespace gl;
using namespace glbinding;

namespace
{

    void error(int errnum, const char * errmsg)
    {
        std::cerr << errnum << ": " << errmsg << std::endl;
    }

    static const std::array<GLfloat, 9> identity3{ { 1.f, 0.f, 0.f,  0.f, 1.f, 0.f,  0.f, 0.f, 1.f } };
    static const std::array<GLfloat, 16> identity4{ { 1.f, 0.f, 0.f, 0.f,  0.f, 1.f, 0.f, 0.f,  0.f, 0.f, 1.f, 0.f,  0.f, 0.f, 0.f, 1.f } };

    template <typename T>
    void glrequest(const GLenum pname, T * data);

    template <>
    void glrequest<GLboolean>(const GLenum pname, GLboolean * data)
    {
        glGetBooleanv(pname, data);
    }

    template <>
    void glrequest<GLenum>(const GLenum pname, GLenum * data)
    {
        glGetIntegerv(pname, reinterpret_cast<GLint *>(data));
    }

    template <>
    void glrequest<GLint>(const GLenum pname, GLint * data)
    {
        glGetIntegerv(pname, data);
    }

    template <>
    void glrequest<GLfloat>(const GLenum pname, GLfloat * data)
    {
        glGetFloatv(pname, data);
    }

	template <>
	void glrequest<GLdouble>(const GLenum pname, GLdouble * data)
	{
		glGetDoublev(pname, data);
	}

    template <typename T, int count>
    struct identity
    {
        static bool valid(const std::array<T, count> &)
        {
            return false;
        }
        static std::string str()
        {
            return "";
        }
    };

    template <>
    struct identity<GLfloat, 9>
    {
        static bool valid(const std::array<GLfloat, 9> & data)
        {
            return identity3 == data;
        }
        static std::string str()
        {
            return "identity3";
        }
    };

    template <>
    struct identity<GLfloat, 16>
    {
        static bool valid(const std::array<GLfloat, 16> & data)
        {
            return identity4 == data;
        }
        static std::string str()
        {
            return "identity4";
        }
    };

    template <typename T, int count>
    std::string string(const std::array<T, count> & data)
    {
        std::stringstream stream;

        if (identity<T, count>::valid(data))
            stream << identity<T, count>::str();
        else
        {
            if (data.size() > 1)
                stream << "(";

            for (int i = 0; i < count; ++i)
            {
                stream << data[i];
                if (i + 1 < count)
                    stream << ", ";
            }

            if (data.size() > 1)
                stream << ")";
        }

        return stream.str();
    }

    template <typename T, int count>
    void request(const GLenum pname, std::array<T, count> & data)
    {
        glrequest<T>(pname, data.data());

        static const size_t MAX_PSTRING_LENGTH { 37 };    // actually, it's 44 / average is 23,
                                                          // but 37 works for 452 of 462 glGet enums (98%)

        const std::string pstring{ glbinding::Meta::getString(pname) };
        const std::string spaces{ std::string(MAX_PSTRING_LENGTH - pstring.length(), ' ') };

        if (glGetError() != gl::GL_NO_ERROR)
        {
            std::cout << "\t" << pstring << spaces << " = NOT AVAILABLE" << std::endl;
            return;
        }
        std::cout << "\t" << glbinding::Meta::getString(pname) << spaces << " = " << string<T, count>(data);
    }

    template <typename T, int count>
    void requestState(const GLenum pname)<commit_msg>Add guard clause for GLenum names longer than 37 characters.<commit_after>
#include <iostream>
#include <sstream>
#include <array>
#include <string>
#include <type_traits>

#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h>

#include <glbinding/Meta.h>
#include <glbinding/ContextInfo.h>
#include <glbinding/Version.h>
#include <glbinding/Binding.h>

#include <glbinding/gl/types.h>
#include <glbinding/gl/enum.h>
#include <glbinding/gl/functions.h>
#include <glbinding/gl/boolean.h>


using namespace gl;
using namespace glbinding;

namespace
{

    void error(int errnum, const char * errmsg)
    {
        std::cerr << errnum << ": " << errmsg << std::endl;
    }

    static const std::array<GLfloat, 9> identity3{ { 1.f, 0.f, 0.f,  0.f, 1.f, 0.f,  0.f, 0.f, 1.f } };
    static const std::array<GLfloat, 16> identity4{ { 1.f, 0.f, 0.f, 0.f,  0.f, 1.f, 0.f, 0.f,  0.f, 0.f, 1.f, 0.f,  0.f, 0.f, 0.f, 1.f } };

    template <typename T>
    void glrequest(const GLenum pname, T * data);

    template <>
    void glrequest<GLboolean>(const GLenum pname, GLboolean * data)
    {
        glGetBooleanv(pname, data);
    }

    template <>
    void glrequest<GLenum>(const GLenum pname, GLenum * data)
    {
        glGetIntegerv(pname, reinterpret_cast<GLint *>(data));
    }

    template <>
    void glrequest<GLint>(const GLenum pname, GLint * data)
    {
        glGetIntegerv(pname, data);
    }

    template <>
    void glrequest<GLfloat>(const GLenum pname, GLfloat * data)
    {
        glGetFloatv(pname, data);
    }

	template <>
	void glrequest<GLdouble>(const GLenum pname, GLdouble * data)
	{
		glGetDoublev(pname, data);
	}

    template <typename T, int count>
    struct identity
    {
        static bool valid(const std::array<T, count> &)
        {
            return false;
        }
        static std::string str()
        {
            return "";
        }
    };

    template <>
    struct identity<GLfloat, 9>
    {
        static bool valid(const std::array<GLfloat, 9> & data)
        {
            return identity3 == data;
        }
        static std::string str()
        {
            return "identity3";
        }
    };

    template <>
    struct identity<GLfloat, 16>
    {
        static bool valid(const std::array<GLfloat, 16> & data)
        {
            return identity4 == data;
        }
        static std::string str()
        {
            return "identity4";
        }
    };

    template <typename T, int count>
    std::string string(const std::array<T, count> & data)
    {
        std::stringstream stream;

        if (identity<T, count>::valid(data))
            stream << identity<T, count>::str();
        else
        {
            if (data.size() > 1)
                stream << "(";

            for (int i = 0; i < count; ++i)
            {
                stream << data[i];
                if (i + 1 < count)
                    stream << ", ";
            }

            if (data.size() > 1)
                stream << ")";
        }

        return stream.str();
    }

    template <typename T, int count>
    void request(const GLenum pname, std::array<T, count> & data)
    {
        glrequest<T>(pname, data.data());

        static const size_t MAX_PSTRING_LENGTH { 37 };    // actually, it's 44 / average is 23,
                                                          // but 37 works for 452 of 462 glGet enums (98%)

        const std::string pstring{ glbinding::Meta::getString(pname) };
		const std::string spaces{ std::string((glbinding::Meta::getString(pname).length() > 37) ? 1 : (MAX_PSTRING_LENGTH - pstring.length()), ' ') };

        if (glGetError() != gl::GL_NO_ERROR)
        {
            std::cout << "\t" << pstring << spaces << " = NOT AVAILABLE" << std::endl;
            return;
        }
        std::cout << "\t" << glbinding::Meta::getString(pname) << spaces << " = " << string<T, count>(data);
    }

    template <typename T, int count>
    void requestState(const GLenum pname)
{'fraction_non_alphanumeric': 0.14274799439704572, 'fraction_numerical': 0.016172163504393225, 'mean_word_length': 1.9908606245239908, 'pattern_counts': {'":': 2, '<': 173, '<?xml version=': 0, '>': 98, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5423731', 'n_tokens_mistral': 2696, 'n_tokens_neox': 2510, 'n_words': 621}