- Fixed some circular includes
- Documentation - File Declaration, TODO: Implementation
This commit is contained in:
@@ -24,17 +24,23 @@
|
||||
|
||||
#include <fennec/lang/assert.h>
|
||||
#include <fennec/memory/allocator.h>
|
||||
#include <fennec/memory/memory.h>
|
||||
#include <fennec/memory/common.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
// Forward def
|
||||
template<typename AllocT = allocator<char>> struct _string;
|
||||
|
||||
// Alias for default allocator
|
||||
using string = _string<>;
|
||||
|
||||
///
|
||||
/// \brief Struct for wrapping c-style strings
|
||||
///
|
||||
/// \details behaviour guarantees that the underlying string is null-terminated
|
||||
template<typename AllocT = allocator<char>>
|
||||
struct string
|
||||
struct _string
|
||||
{
|
||||
public:
|
||||
using alloc_t = allocation<char, AllocT>;
|
||||
@@ -44,7 +50,7 @@ public:
|
||||
|
||||
///
|
||||
/// \brief Default Constructor, initializes empty string
|
||||
constexpr string()
|
||||
constexpr _string()
|
||||
: _str()
|
||||
{ }
|
||||
|
||||
@@ -53,8 +59,8 @@ public:
|
||||
/// \param n the number of characters
|
||||
///
|
||||
/// \details adds additional character for null termination.
|
||||
constexpr string(size_t n)
|
||||
: string('\0', n)
|
||||
constexpr _string(size_t n)
|
||||
: _string('\0', n)
|
||||
{ }
|
||||
|
||||
///
|
||||
@@ -63,7 +69,7 @@ public:
|
||||
/// \param n the number of characters
|
||||
///
|
||||
/// \details adds additional character for null termination.
|
||||
constexpr string(char c, size_t n)
|
||||
constexpr _string(char c, size_t n)
|
||||
: _str(n + 1)
|
||||
{ fennec::memset(_str, c, n); _str[n] = '\0'; }
|
||||
|
||||
@@ -74,24 +80,24 @@ public:
|
||||
///
|
||||
/// \details adds additional character for null termination. Ignores whether str is null-terminated.
|
||||
/// This constructor makes the assumption that `len` is the intended number of characters.
|
||||
constexpr string(const cstring& str)
|
||||
constexpr _string(const cstring& str)
|
||||
: _str(str, str.size() + 1)
|
||||
{ _str[str.size()] = '\0'; }
|
||||
|
||||
///
|
||||
/// \brief String Copy Constructor
|
||||
/// \param str the string to copy
|
||||
constexpr string(const string& str)
|
||||
: string(str, str.size() - 1)
|
||||
constexpr _string(const string& str)
|
||||
: _string(str, str.size() - 1)
|
||||
{ }
|
||||
|
||||
constexpr string(string&& str) noexcept
|
||||
constexpr _string(_string&& str) noexcept
|
||||
: _str(fennec::move(str._str))
|
||||
{ }
|
||||
|
||||
///
|
||||
/// \brief String Destructor, cleans up the underlying allocation
|
||||
constexpr ~string() = default; // allocation cleans up itself
|
||||
constexpr ~_string() = default; // allocation cleans up itself
|
||||
|
||||
// Properties ==========================================================================================================
|
||||
|
||||
|
||||
Reference in New Issue
Block a user