<commit_before>/**
 * Created by <NAME>
 * @since  2015.11.27
 * @author <NAME> <<EMAIL>>
 * @link   http://www.chensoft.com
 */
#pragma once

#include "dns_define.h"
#include <string>
#include <vector>
#include <array>

namespace chen
{
    namespace dns
    {
        // ---------------------------------------------------------------------
        // Resource Record(rfc1035, section 3.2.1)
        struct RR
        {
        public:
            virtual ~RR() = 0;

        public:
            /**
             * Data
             */
            virtual std::vector<std::uint8_t> data() const = 0;
            virtual std::size_t setData(const std::uint8_t *data, std::size_t size) = 0;

        public:
            std::string name;
            chen::dns::RRType rrtype   = chen::dns::RRType::None;
            chen::dns::RRClass rrclass = chen::dns::RRClass::IN;
            std::int32_t ttl = 0;

            // rdlength will be set when call setData method
            std::uint16_t rdlength = 0;
        };


        // ---------------------------------------------------------------------
        // Custom RR
        // ---------------------------------------------------------------------
        // ---------------------------------------------------------------------
        // Raw(raw resource record, with rdata)
        struct Raw : public RR
        {
        public:
            /**
             * Data
             */
            virtual std::vector<std::uint8_t> data() const override;
            virtual std::size_t setData(const std::uint8_t *data, std::size_t size) override;

        public:
            std::vector<std::uint8_t> rdata;
        };


        // ---------------------------------------------------------------------
        // Unknown(unknown record)
        struct Unknown : public Raw
        {
        };
<commit_msg>rr: only allow rdlength be accessed in derived class<commit_after>/**
 * Created by <NAME>
 * @since  2015.11.27
 * @author <NAME> <<EMAIL>>
 * @link   http://www.chensoft.com
 */
#pragma once

#include "dns_define.h"
#include <string>
#include <vector>
#include <array>

namespace chen
{
    namespace dns
    {
        // ---------------------------------------------------------------------
        // Resource Record(rfc1035, section 3.2.1)
        struct RR
        {
        public:
            virtual ~RR() = 0;

        public:
            /**
             * Data
             */
            virtual std::vector<std::uint8_t> data() const = 0;
            virtual std::size_t setData(const std::uint8_t *data, std::size_t size) = 0;

        public:
            std::string name;
            chen::dns::RRType rrtype   = chen::dns::RRType::None;
            chen::dns::RRClass rrclass = chen::dns::RRClass::IN;
            std::int32_t ttl = 0;

        protected:
            // internal use only, will be set when call setData method
            std::uint16_t rdlength = 0;
        };


        // ---------------------------------------------------------------------
        // Custom RR
        // ---------------------------------------------------------------------
        // ---------------------------------------------------------------------
        // Raw(raw resource record, with rdata)
        struct Raw : public RR
        {
        public:
            /**
             * Data
             */
            virtual std::vector<std::uint8_t> data() const override;
            virtual std::size_t setData(const std::uint8_t *data, std::size_t size) override;

        public:
            std::vector<std::uint8_t> rdata;
        };


        // ---------------------------------------------------------------------
        // Unknown(unknown record)
        struct Unknown : public Raw
        {
        };

{'fraction_non_alphanumeric': 0.2845464135021097, 'fraction_numerical': 0.01529535864978903, 'mean_word_length': 0.9491264131551901, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4088312', 'n_tokens_mistral': 1005, 'n_tokens_neox': 940, 'n_words': 227}