<commit_before>#pragma once
#include "postgresql/libpq-fe.h"
#include <sstream>
#include "string"

#include <boost/lexical_cast.hpp>

namespace sqlpp{
namespace postgresql {

using std::string;

class __attribute__((__visibility__("default"))) Result{
public:
    Result();
    Result( PGresult *res );

    ExecStatusType status();
    bool hasError();
    string errorStr();

    void operator = ( PGresult *res );
    operator bool () const {
        return m_result == nullptr ? false : true;
    }

    void clear(){
        if(m_result)
            PQclear(m_result);
        m_result = nullptr;
    }

    size_t affected_rows();

    size_t records_size();

    size_t field_count();

    bool isNull(size_t record, size_t field) const {
        return PQgetisnull(m_result, record, field);
    }

    template<typename T>
    inline T getValue(size_t record, size_t field) const {
        return boost::lexical_cast<T>(PQgetvalue(m_result, record, field));
    }

    size_t length(size_t record, size_t field) const {
        return PQgetlength(m_result, record, field);
    }

    ~Result();

    PGresult *get(){
        return m_result;
    }

private:
    PGresult *m_result;
};

template<>
inline const char * Result::getValue<const char *>(size_t record, size_t field) const {
    return const_cast<const char *>(PQgetvalue(m_result, record, field));
}

}
}<commit_msg>add extra specialization for casting postgres bool data<commit_after>#pragma once
#include "postgresql/libpq-fe.h"
#include <sstream>
#include "string"

#include <boost/lexical_cast.hpp>

namespace sqlpp{
namespace postgresql {

using std::string;

class __attribute__((__visibility__("default"))) Result{
public:
    Result();
    Result( PGresult *res );

    ExecStatusType status();
    bool hasError();
    string errorStr();

    void operator = ( PGresult *res );
    operator bool () const {
        return m_result == nullptr ? false : true;
    }

    void clear(){
        if(m_result)
            PQclear(m_result);
        m_result = nullptr;
    }

    size_t affected_rows();

    size_t records_size();

    size_t field_count();

    bool isNull(size_t record, size_t field) const {
        return PQgetisnull(m_result, record, field);
    }

    template<typename T>
    inline T getValue(size_t record, size_t field) const {
        return boost::lexical_cast<T>(PQgetvalue(m_result, record, field));
    }

    size_t length(size_t record, size_t field) const {
        return PQgetlength(m_result, record, field);
    }

    ~Result();

    PGresult *get(){
        return m_result;
    }

private:
    PGresult *m_result;
};

template<>
inline const char * Result::getValue<const char *>(size_t record, size_t field) const {
    return const_cast<const char *>(PQgetvalue(m_result, record, field));
}
template<>
inline bool Result::getValue<bool>(size_t record, size_t field) const {
    auto val = PQgetvalue(m_result, record, field);
    if( *val == 't' )
        return true;
    else if( *val == 'f' )
        return false;
    return const_cast<const char *>(val);
}

}
}
{'fraction_non_alphanumeric': 0.11903989620499514, 'fraction_numerical': 0.0, 'mean_word_length': 3.218878248974008, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, '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': '6326481', 'n_tokens_mistral': 1018, 'n_tokens_neox': 981, 'n_words': 259}