1#ifndef HALIDE_RUNTIME_STRING_STORAGE_H
2#define HALIDE_RUNTIME_STRING_STORAGE_H
4#include "../HalideRuntime.h"
33 const char *ptr = str;
48 char starts_with = *
s2;
49 for (
size_t length =
strlen(
s2); length <=
n;
n--,
s1++) {
50 if (*
s1 == starts_with) {
51 for (
size_t i = 1;
i <= length;
i++) {
65 const char *ptr = str;
95 void destroy(
void *user_context);
101 bool contains(
const char *str)
const;
105 void assign(
void *user_context,
char ch);
106 void assign(
void *user_context,
const char *str,
size_t length = 0);
107 void append(
void *user_context,
char ch);
108 void append(
void *user_context,
const char *str,
size_t length = 0);
109 void prepend(
void *user_context,
char ch);
110 void prepend(
void *user_context,
const char *str,
size_t length = 0);
111 void clear(
void *user_context);
115 const char *
data()
const;
125 : contents(user_context, {
sizeof(
char), 32, 32},
sma) {
127 contents.reserve(user_context, capacity);
140 if (result ==
nullptr) {
141 halide_error(user_context,
"StringStorage: Failed to create instance! Out of memory!\n");
152 instance->
destroy(user_context);
158 if (&
other !=
this) {
165 if (contents.
empty()) {
168 const char *
this_str =
static_cast<const char *
>(contents.
data());
173 if (contents.
empty()) {
176 if (
other.contents.empty()) {
179 const char *
this_str =
static_cast<const char *
>(contents.
data());
180 const char *
other_str =
static_cast<const char *
>(
other.contents.data());
185 if (contents.
size() !=
other.contents.size()) {
188 const char *
this_str =
static_cast<const char *
>(contents.
data());
189 const char *
other_str =
static_cast<const char *
>(
other.contents.data());
194 return !(*
this ==
other);
205 char *ptr =
static_cast<char *
>(contents[0]);
271 halide_error(user_context,
"StringStorage: Failed to terminate string! Out of bounds!\n");
276 contents.
clear(user_context);
282 reserve(user_context, capacity);
287 contents.
destroy(user_context);
295 return static_cast<const char *
>(contents.
data());
void halide_error(void *user_context, const char *)
Halide calls this function on runtime errors (for example bounds checking failures).
void destroy(void *user_context)
void clear(void *user_context)
void resize(void *user_context, size_t entry_count, bool realloc=true)
void replace(void *user_context, size_t index, const void *array, size_t array_size)
void prepend(void *user_context, const void *entry_ptr)
void insert(void *user_context, size_t index, const void *entry_ptr)
void initialize(void *user_context, const Config &cfg, const SystemMemoryAllocatorFns &sma=default_allocator())
static const SystemMemoryAllocatorFns & default_allocator()
const SystemMemoryAllocatorFns & current_allocator() const
bool is_valid(size_t index) const
void reserve(void *user_context, size_t capacity, bool free_existing=false)
const SystemMemoryAllocatorFns & current_allocator() const
void assign(void *user_context, char ch)
void prepend(void *user_context, char ch)
StringStorage(void *user_context=nullptr, uint32_t capacity=0, const SystemMemoryAllocatorFns &sma=default_allocator())
StringStorage & operator=(const StringStorage &other)
static const SystemMemoryAllocatorFns & default_allocator()
bool operator==(const StringStorage &other) const
const char * data() const
void reserve(void *user_context, size_t length)
bool operator!=(const StringStorage &other) const
StringStorage(const StringStorage &other)=default
void initialize(void *user_context, uint32_t capacity=0, const SystemMemoryAllocatorFns &sma=default_allocator())
static StringStorage * create(void *user_context, const SystemMemoryAllocatorFns &ma)
bool contains(const char *str) const
void clear(void *user_context)
void append(void *user_context, char ch)
void terminate(void *user_context, size_t length)
static void destroy(void *user_context, StringStorage *string_storage)
size_t strlen(const char *string)
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
@ Internal
Not visible externally, similar to 'static' linkage in C.
Internal::ConstantInterval cast(Type t, const Internal::ConstantInterval &a)
Cast operators for ConstantIntervals.
int strncmp(const char *s, const char *t, size_t n)
void * memcpy(void *s1, const void *s2, size_t n)
unsigned __INT32_TYPE__ uint32_t
#define halide_abort_if_false(user_context, cond)
const char * strstr(const char *, const char *)
static size_t count_tokens(const char *str, const char *delim)
static bool contains(const char *s1, const char *s2, size_t n)
static size_t count_length(const char *str, size_t max_chars)
static bool is_empty(const char *str)
static size_t copy_up_to(char *dst, const char *src, size_t max_chars)