#ifndef CPU_FEATURES_INCLUDE_INTERNAL_STRING_VIEW_H_
#define CPU_FEATURES_INCLUDE_INTERNAL_STRING_VIEW_H_
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
#include "cpu_features_macros.h"
CPU_FEATURES_START_CPP_NAMESPACE
typedef struct {
const char* ptr;
size_t size;
} StringView;
#ifdef __cplusplus
static const StringView kEmptyStringView = {NULL, 0};
#else
static const StringView kEmptyStringView;
#endif
static inline StringView view(const char* str, const size_t size) {
StringView view;
view.ptr = str;
view.size = size;
return view;
}
static inline StringView str(const char* str) { return view(str, strlen(str)); }
int CpuFeatures_StringView_IndexOfChar(const StringView view, char c);
int CpuFeatures_StringView_IndexOf(const StringView view,
const StringView sub_view);
bool CpuFeatures_StringView_IsEquals(const StringView a, const StringView b);
bool CpuFeatures_StringView_StartsWith(const StringView a, const StringView b);
StringView CpuFeatures_StringView_PopFront(const StringView str_view,
size_t count);
StringView CpuFeatures_StringView_PopBack(const StringView str_view,
size_t count);
StringView CpuFeatures_StringView_KeepFront(const StringView str_view,
size_t count);
char CpuFeatures_StringView_Front(const StringView view);
char CpuFeatures_StringView_Back(const StringView view);
StringView CpuFeatures_StringView_TrimWhitespace(StringView view);
int CpuFeatures_StringView_ParsePositiveNumber(const StringView view);
void CpuFeatures_StringView_CopyString(const StringView src, char* dst,
size_t dst_size);
bool CpuFeatures_StringView_HasWord(const StringView line,
const char* const word,
const char separator);
bool CpuFeatures_StringView_GetAttributeKeyValue(const StringView line,
StringView* key,
StringView* value);
CPU_FEATURES_END_CPP_NAMESPACE
#endif