mirror of
https://github.com/EnderIce2/Fennix.git
synced 2025-08-24 20:44:59 +00:00
.devcontainer
.github
.vscode
Bootloader
Drivers
Kernel
.vscode
arch
core
drivers
exec
files
include
include_std
sys
algorithm
assert.h
atomic
bitset
cassert
cctype
cfloat
climits
cmath
concepts
coroutine
cstddef
cstring
ctype.h
dlfcn.h
errno.h
exception
float.h
functional
initializer_list
inttypes.h
ios
iostream
istream
iterator
limits
limits.h
list
locale
math.h
memory
memory.h
mutex
new
optional
ostream
pthread.h
ranges
sched.h
signal.h
stdarg.h
stdatomic.h
stdbool.h
stddef.h
stdexcept
stdint.h
stdio.h
stdlib.h
streambuf
string
string.h
string_view
strings.h
stropts.h
system_error
termios.h
thread
time.h
tuple
type_traits
typeinfo
unistd.h
unordered_map
utility
utsname.h
vector
wchar.h
kshell
library
network
profiling
storage
subsystem
syscalls
tasking
tests
tty
virtualization
.editorconfig
.gdbinit
.gitignore
ISSUES.md
Makefile
README.md
TODO.md
dump.sh
kernel.cpp
kernel.h
kernel_config.cpp
kernel_thread.cpp
kernel_vfs.cpp
Userspace
initrd
tools
.editorconfig
.gitignore
.gitlab-ci.yml
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
CREDITS.md
Doxyfile
Fennix Bootloader.code-workspace
Fennix Drivers.code-workspace
Fennix Kernel.code-workspace
Fennix Userspace.code-workspace
Fennix Website.code-workspace
Fennix.code-workspace
INSTALL.md
LICENSE.md
LICENSES.md
Makefile
README.md
SECURITY.md
STYLE_GUIDE.md
cliff.toml
config.mk
120 lines
2.4 KiB
Plaintext
120 lines
2.4 KiB
Plaintext
/*
|
|
This file is part of Fennix Kernel.
|
|
|
|
Fennix Kernel is free software: you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public License as
|
|
published by the Free Software Foundation, either version 3 of
|
|
the License, or (at your option) any later version.
|
|
|
|
Fennix Kernel is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <convert.h>
|
|
#include <cassert>
|
|
#include <new>
|
|
|
|
namespace std
|
|
{
|
|
class __simple_string
|
|
{
|
|
private:
|
|
char *data;
|
|
size_t size;
|
|
|
|
public:
|
|
__simple_string()
|
|
: data(nullptr),
|
|
size(0)
|
|
{
|
|
}
|
|
|
|
__simple_string(const char *str)
|
|
: data(nullptr),
|
|
size(0)
|
|
{
|
|
size = strlen(str);
|
|
data = new char[size + 1];
|
|
assert(data != nullptr);
|
|
memcpy(data, str, size);
|
|
data[size] = '\0';
|
|
}
|
|
|
|
__simple_string(const __simple_string &other)
|
|
: data(nullptr),
|
|
size(0)
|
|
{
|
|
size = other.size;
|
|
data = new char[size + 1];
|
|
assert(data != nullptr);
|
|
memcpy(data, other.data, size);
|
|
data[size] = '\0';
|
|
}
|
|
|
|
~__simple_string()
|
|
{
|
|
if (data)
|
|
delete[] data;
|
|
}
|
|
|
|
const char *c_str() const { return data; }
|
|
|
|
__simple_string &operator=(const __simple_string &other)
|
|
{
|
|
if (data)
|
|
delete[] data;
|
|
|
|
size = other.size;
|
|
data = new char[size + 1];
|
|
assert(data != nullptr);
|
|
memcpy(data, other.data, size);
|
|
data[size] = '\0';
|
|
|
|
return *this;
|
|
}
|
|
};
|
|
|
|
class runtime_error : public exception
|
|
{
|
|
};
|
|
|
|
class logic_error : public exception
|
|
{
|
|
private:
|
|
__simple_string msg;
|
|
|
|
public:
|
|
logic_error(const char *what_arg) : msg(what_arg) {}
|
|
logic_error(const logic_error &other) : msg(other.msg) {}
|
|
|
|
logic_error &operator=(const logic_error &other) noexcept
|
|
{
|
|
msg = other.msg;
|
|
return *this;
|
|
}
|
|
|
|
virtual const char *what() const noexcept
|
|
{
|
|
return msg.c_str();
|
|
}
|
|
};
|
|
|
|
class out_of_range : public logic_error
|
|
{
|
|
public:
|
|
out_of_range(const char *what_arg) : logic_error(what_arg) {}
|
|
out_of_range(const out_of_range &other) = default;
|
|
out_of_range &operator=(const out_of_range &) = default;
|
|
out_of_range(out_of_range &&) = default;
|
|
out_of_range &operator=(out_of_range &&) = default;
|
|
virtual ~out_of_range() = default;
|
|
};
|
|
}
|