<commit_before>// Author: <NAME>
// Copyright (c) 2015
#ifndef _NGX_BUF_HPP
#define _NGX_BUF_HPP

#include "NgxPool.hpp"

class NgxBuf final : public NgxWrapper<ngx_buf_t>
{
public:
    typedef NgxWrapper<ngx_buf_t> super_type;
    typedef NgxBuf this_type;
public:
    NgxBuf(const NgxPool& p, std::size_t n):
        super_type(p.buffer(n))
    {}

    NgxBuf(ngx_buf_t* buf):super_type(buf)
    {}

    ~NgxBuf() = default;
public:
    // readable range
    void range(u_char* a, u_char* b) const
    {
        get()->pos = a;
        get()->last = b;

        get()->memory = true;
    }

    // convenitable method
    void range(ngx_str_t* s) const
    {
        range(s->data, s->data + s->len);
        boundary(s->data, s->data + s->len);
    }

    void boundary(u_char* a, u_char* b) const
    {
        get()->start = a;
        get()->end = b;
    }

    ngx_str_t range() const
    {
        return ngx_str_t{
            static_cast<std::size_t>(get()->last - get()->pos), get()->pos};
    }

    ngx_str_t boundary() const
    {
        return ngx_str_t{
            static_cast<std::size_t>(get()->end - get()->start), get()->start};
    }
public:
    std::size_t size() const
    {
        return ngx_buf_size(get());
    }

    void clear() const
    {
        get()->pos = get()->last;
    }
//    ngx_uint_t capacity() const
//    {
//        return get()->end - get()->start;
//    }

public:
    void consume(std::size_t n) const
    {
        if(n > size())<commit_msg>NgxBuf.hpp<commit_after>// Author: <NAME>
// Copyright (c) 2015
#ifndef _NGX_BUF_HPP
#define _NGX_BUF_HPP

#include "NgxPool.hpp"

class NgxBuf final : public NgxWrapper<ngx_buf_t>
{
public:
    typedef NgxWrapper<ngx_buf_t> super_type;
    typedef NgxBuf this_type;
public:
    NgxBuf(const NgxPool& p, std::size_t n):
        super_type(p.buffer(n))
    {}

    NgxBuf(ngx_buf_t* buf):super_type(buf)
    {}

    ~NgxBuf() = default;
public:
    // readable range
    void range(u_char* a, u_char* b) const
    {
        get()->pos = a;
        get()->last = b;

        get()->memory = true;
    }

    // convenitable method
    void range(ngx_str_t* s) const
    {
        range(s->data, s->data + s->len);
        boundary(s->data, s->data + s->len);
    }

    void boundary(u_char* a, u_char* b) const
    {
        get()->start = a;
        get()->end = b;
    }

    ngx_str_t range() const
    {
        return ngx_str_t{
            static_cast<std::size_t>(get()->last - get()->pos), get()->pos};
    }

    ngx_str_t boundary() const
    {
        return ngx_str_t{
            static_cast<std::size_t>(get()->end - get()->start), get()->start};
    }
public:
    std::size_t size() const
    {
        return ngx_buf_size(get());
    }

    void clear() const
    {
        get()->pos = get()->last;
    }
//    ngx_uint_t capacity() const
//    {
//        return get()->end - get()->start;
//    }

public:
    bool empty() const
    {
        return get()->pos == get()->last;
    }

    bool full() const
    {
        return get()->pos == get()->end;
    }
public:
    void consume(std::size_t n) const
    {
        if(n > size())
{'fraction_non_alphanumeric': 0.16539440203562342, 'fraction_numerical': 0.002544529262086514, 'mean_word_length': 2.0833333333333335, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 61, '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': '5784271', 'n_tokens_mistral': 1184, 'n_tokens_neox': 1156, 'n_words': 236}