<commit_before>#ifndef PHPCXX_HELPERS_H
#define PHPCXX_HELPERS_H

#include <Zend/zend.h>
#include <Zend/zend_string.h>
#include <cstring>
#include <string>
#include <type_traits>

namespace phpcxx {

// See http://loungecpp.wikidot.com/tips-and-tricks:indices
template <std::size_t... Is>
struct indices {};

template <std::size_t N, std::size_t... Is>
struct build_indices : build_indices<N-1, N-1, Is...> {};

template <std::size_t... Is>
struct build_indices<0, Is...> : indices<Is...> {};

template<typename ...T>
using IndicesFor = build_indices<sizeof...(T)>;

static inline void construct_zval(zval& z, std::nullptr_t) { ZVAL_NULL(&z); }

template<typename T, typename std::enable_if<std::is_integral<T>::value>::type* = nullptr>
static inline void construct_zval(zval& z, T v) { ZVAL_LONG(&z, v); }

template<typename T, typename std::enable_if<std::is_floating_point<T>::value>::type* = nullptr>
static inline void construct_zval(zval& z, T v) { ZVAL_DOUBLE(&z, v); }

static inline void construct_zval(zval& z, const char* s)
{
    zend_string* zs = zend_string_init(s, std::strlen(s), 0);
    ZVAL_STR(&z, zs);
}

static inline void construct_zval(zval& z, const std::string& s)
{
    zend_string* zs = zend_string_init(s.c_str(), s.size(), 0);
    ZVAL_STR(&z, zs);
}

}

#endif /* PHPCXX_HELPERS_H */
<commit_msg>construct_zval() from phpcxx::string, not std<commit_after>#ifndef PHPCXX_HELPERS_H
#define PHPCXX_HELPERS_H

#include <Zend/zend.h>
#include <Zend/zend_string.h>
#include <cstring>
#include <type_traits>
#include "string.h"

namespace phpcxx {

// See http://loungecpp.wikidot.com/tips-and-tricks:indices
template <std::size_t... Is>
struct indices {};

template <std::size_t N, std::size_t... Is>
struct build_indices : build_indices<N-1, N-1, Is...> {};

template <std::size_t... Is>
struct build_indices<0, Is...> : indices<Is...> {};

template<typename ...T>
using IndicesFor = build_indices<sizeof...(T)>;

static inline void construct_zval(zval& z, std::nullptr_t) { ZVAL_NULL(&z); }

template<typename T, typename std::enable_if<std::is_integral<T>::value>::type* = nullptr>
static inline void construct_zval(zval& z, T v) { ZVAL_LONG(&z, v); }

template<typename T, typename std::enable_if<std::is_floating_point<T>::value>::type* = nullptr>
static inline void construct_zval(zval& z, T v) { ZVAL_DOUBLE(&z, v); }

static inline void construct_zval(zval& z, const char* s)
{
    zend_string* zs = zend_string_init(s, std::strlen(s), 0);
    ZVAL_STR(&z, zs);
}

static inline void construct_zval(zval& z, const phpcxx::string& s)
{
    zend_string* zs = zend_string_init(s.c_str(), s.size(), 0);
    ZVAL_STR(&z, zs);
}

}

#endif /* PHPCXX_HELPERS_H */

{'fraction_non_alphanumeric': 0.17255485310524357, 'fraction_numerical': 0.003718854592785422, 'mean_word_length': 5.34433962264151, 'pattern_counts': {'":': 0, '<': 40, '<?xml version=': 0, '>': 40, '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': '4464448', 'n_tokens_mistral': 1072, 'n_tokens_neox': 1057, 'n_words': 228}