BarinkOS/CoreLib/String.cpp
Nigel dea8ab7d71 Improved build system
Added new entries to .gitignore
Moved away from source directory as central spot for all source code
2023-02-20 00:29:06 +01:00

40 lines
551 B
C++

#include "String.h"
#include <stdint.h>
#include <stddef.h>
String::String(char* characters)
: chars(characters)
{
}
char* String::str(){
return chars;
}
unsigned int String::length ()
{
int i = 0;
while ( chars[i] != '\0'){
i++;
}
return i;
}
// Returns a null character if size exceeds limits
char String::operator[] (size_t idx)
{
if( idx > this->length())
return '\0';
return chars[idx];
}
const char String::operator[](size_t idx) const {
return (const char) chars[idx];
}