<commit_before>#ifndef DAS_STRING_H
#define DAS_STRING_H
// @author <NAME> (Spector)
// This library is going to be my personal impleneation of a string type in cpp
// Testing for now

//TODO: look at doing custom allocations but this is probally already ready
#include <malloc.h>

inline unsigned int
getStringLength(char* input)
{
    unsigned int length = 0;
    while(*input++ != 0) { ++length; }
    return length;
}

struct String
{
    char* string;
    unsigned int length; // not including termininating null

    // OPERATOR_OVERLOAD SECTION
    inline char & operator[](unsigned int index)
    { return string[index]; }

    inline void operator=(char* input)
    {
        length = getStringLength(input);
        string = input;
    }
};
//We are actually getting each character, not just setting the address
inline void
copyString(String input, String output)
{
    if(input.length != 0)
    {
        output.length = input.length;
        for(unsigned int i = 0; i < input.length; i++)
        {
            output.string[i] = input.string[i];
        }
        output.string[output.length] = '\0';
    }
}

inline String
copyString(String input)
{
    String result = {(char*)calloc((input.length +1), sizeof(char)) \
                    , input.length};
    if(input.length != 0)
    {
        for(unsigned int i = 0; i < input.length; i++)
        {
            result.string[i] = input.string[i];
        }
        result.string[input.length] = '\0';
    }
    else { result = {}; }
    return result;
}

inline String
copyString(char* input)
{
    unsigned int length = getStringLength(input);
    String result = {(char*)calloc((length +1), sizeof(char)) \
                    , length};
    if(length != 0)
    {
        result.length = length;
        for(unsigned int i = 0; i < length; i++)
        {
            result.string[i] = input[i];
        }
        result.string[length] = '\0';
    }
    else { result = {}; }
    return result;
}

inline bool
compareString(String A, String B)
{
    if(A.length != B.length) return false;
    for(unsigned int i = 0; i < A.length; i++)
    {
        if(A.string[i] != B.string[i]) return false;
    }
    return true;
}

inline bool
compareString(String A, char* B)
{
    String C = copyString(B);
    if(A.length != C.length) return false;
    for(unsigned int i = 0; i < A.length; i++)
    {
        if(A.string[i] != C.string[i]) return false;
    }
    return true;
}

inline bool
compareString(char* A, String B)
{
    String C = copyString(A);
    if(B.length != C.length) return false;
    for(unsigned int i = 0; i < B.length; i++)
    {
        if(B.string[i] != C.string[i]) return false;
    }
    return true;
}

inline String
splitString(String input, char delim)
{
    unsigned int length = 0;
    for(unsigned int i = 0; i < input.length; i++)
    {
        if(input[i] == delim)
        {
            String result = {(char*)calloc((length +1), sizeof(char)) \
                            , (length)};
            for(unsigned int i = 0; i < length; i++)<commit_msg>added a char[] to char[] comparestring, No test was added for this<commit_after>#ifndef DAS_STRING_H
#define DAS_STRING_H
// @author <NAME> (Spector)
// This library is going to be my personal impleneation of a string type in cpp
// Testing for now

//TODO: look at doing custom allocations but this is probally already ready
#include <malloc.h>

inline unsigned int
getStringLength(char* input)
{
    unsigned int length = 0;
    while(*input++ != 0) { ++length; }
    return length;
}

struct String
{
    char* string;
    unsigned int length; // not including termininating null

    // OPERATOR_OVERLOAD SECTION
    inline char & operator[](unsigned int index)
    { return string[index]; }

    inline void operator=(char* input)
    {
        length = getStringLength(input);
        string = input;
    }
};
//We are actually getting each character, not just setting the address
inline void
copyString(String input, String output)
{
    if(input.length != 0)
    {
        output.length = input.length;
        for(unsigned int i = 0; i < input.length; i++)
        {
            output.string[i] = input.string[i];
        }
        output.string[output.length] = '\0';
    }
}

inline String
copyString(String input)
{
    String result = {(char*)calloc((input.length +1), sizeof(char)) \
                    , input.length};
    if(input.length != 0)
    {
        for(unsigned int i = 0; i < input.length; i++)
        {
            result.string[i] = input.string[i];
        }
        result.string[input.length] = '\0';
    }
    else { result = {}; }
    return result;
}

inline String
copyString(char* input)
{
    unsigned int length = getStringLength(input);
    String result = {(char*)calloc((length +1), sizeof(char)) \
                    , length};
    if(length != 0)
    {
        result.length = length;
        for(unsigned int i = 0; i < length; i++)
        {
            result.string[i] = input[i];
        }
        result.string[length] = '\0';
    }
    else { result = {}; }
    return result;
}

inline bool
compareString(String A, String B)
{
    if(A.length != B.length) return false;
    for(unsigned int i = 0; i < A.length; i++)
    {
        if(A.string[i] != B.string[i]) return false;
    }
    return true;
}

inline bool
compareString(String A, char* B)
{
    String C = copyString(B);
    if(A.length != C.length) return false;
    for(unsigned int i = 0; i < A.length; i++)
    {
        if(A.string[i] != C.string[i]) return false;
    }
    return true;
}

inline bool
compareString(char* A, String B)
{
    String C = copyString(A);
    if(B.length != C.length) return false;
    for(unsigned int i = 0; i < B.length; i++)
    {
        if(B.string[i] != C.string[i]) return false;
    }
    return true;
}

inline bool
compareString(char* A, char* B)
{ return compareString(copyString(A), copyString(B)); }

inline String
splitString(String input, char delim)
{
    unsigned int length = 0;
    for(unsigned int i = 0; i < input.length; i++)
    {
        if(input[i] == delim)
        {
            String result = {(char*)calloc((length +1), sizeof(char)) \
                            , (length)};
            for(unsigned int i = 0; i < length; i++)
{'fraction_non_alphanumeric': 0.13706070287539937, 'fraction_numerical': 0.006389776357827476, 'mean_word_length': 2.2952631578947367, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 7, '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': '7022300', 'n_tokens_mistral': 2029, 'n_tokens_neox': 1976, 'n_words': 579}