| \emph{read | write | trunc}
/// | Opens file as read-write, destroying contents
///
enum fmode_ : uint8_t
@@ -147,7 +147,7 @@ public:
file();
///
- /// \details Initializes a stream pointing to \f$path\f$ opened with \f$mode\f$
+ /// \details Initializes a stream pointing to \emph{path} opened with \emph{mode}
/// \param path the path of the file
/// \param mode the mode to open with
file(const cstring& path, uint8_t mode)
@@ -156,7 +156,7 @@ public:
}
///
- /// \details Initializes a stream pointing to \f$path\f$ opened with \f$mode\f$
+ /// \details Initializes a stream pointing to \emph{path} opened with \emph{mode}
/// \param path the path of the file
/// \param mode the mode to open with
file(const string& path, uint8_t mode)
@@ -166,7 +166,7 @@ public:
///
/// \brief Path constructor
- /// \details Initializes a stream pointing to \f$path\f$ opened with \f$mode\f$
+ /// \details Initializes a stream pointing to \emph{path} opened with \emph{mode}
/// \param path the path of the file
/// \param mode the mode to open with
file(const path& path, uint8_t mode)
@@ -179,23 +179,39 @@ public:
/// \param file the stream to take ownership of
file(file&& file) noexcept;
+ ///
+ /// \brief Copy Constructor
+ /// \details Deleted, no semantics for copying a stream. Holding multiple copies of a stream will cause conflicts.
+ file(const file&) = delete;
+
///
/// \brief Destructor
/// \details Flushes and closes an open stream
~file();
+ ///@}
+
+
+// Assignment ==========================================================================================================
+public:
+
+ /// \name Assignment
+ /// @{
+
+
///
/// \brief Move assignment
/// \param file the stream to take ownership of
file& operator=(file&& file) noexcept;
- ///@}
-
-private:
- // don't allow copying streams
- file(const file&) = delete;
+ ///
+ /// \brief Copy Assignment
+ /// \details Deleted, no semantics for copying a stream. Holding multiple copies of a stream will cause conflicts.
+ /// \returns Deleted
file& operator=(const file&) = delete;
+ /// @}
+
// Properties ==========================================================================================================
public:
@@ -216,7 +232,7 @@ public:
}
///
- /// \returns \f$true\f$ if there is a valid, open stream.
+ /// \returns \emph{true} if there is a valid, open stream.
bool is_open() const {
return _handle != nullptr;
}
@@ -233,30 +249,30 @@ public:
///
/// \param path the path to the file
/// \param mode the mode flags to open the file with
- /// \returns \f$false\f$ on success, \f$true\f$ on error
+ /// \returns \emph{false} on success, \emph{true} on error
bool open(const cstring& path, uint8_t mode);
///
/// \param path the path to the file
/// \param mode the mode flags to open the file with
- /// \returns \f$false\f$ on success, \f$true\f$ on error
+ /// \returns \emph{false} on success, \emph{true} on error
bool open(const string& path, uint8_t mode);
///
/// \brief Open a file
/// \param path the path to the file
/// \param mode the mode flags to open the file with
- /// \returns \f$false\f$ on success, \f$true\f$ on error
+ /// \returns \emph{false} on success, \emph{true} on error
bool open(const path& path, uint8_t mode);
///
/// \brief Close a stream
- /// \returns \f$false\f$ on success, \f$true\f$ on error
+ /// \returns \emph{false} on success, \emph{true} on error
bool close();
///
/// \brief Commit the streams buffer to the file
- /// \returns \f$false\f$ on success, \f$true\f$ on error
+ /// \returns \emph{false} on success, \emph{true} on error
bool commit();
/// @}
@@ -270,12 +286,12 @@ public:
///
/// \brief closes the stream and erases the file
- /// \returns \f$false\f$ on success, \f$true\f$ on error
+ /// \returns \emph{false} on success, \emph{true} on error
bool erase();
///
/// \param path the new path
- /// \returns \f$false\f$ on success, \f$true\f$ on error
+ /// \returns \emph{false} on success, \emph{true} on error
///
/// \details
/// Copies contents to the new path, and erases the old file.
@@ -288,7 +304,7 @@ public:
///
/// \param path the new path
- /// \returns \f$false\f$ on success, \f$true\f$ on error
+ /// \returns \emph{false} on success, \emph{true} on error
///
/// \details
/// Copies contents to the new path, and erases the old file.
@@ -302,7 +318,7 @@ public:
///
/// \brief Rebind the stream.
/// \param path the new path
- /// \returns \f$false\f$ on success, \f$true\f$ on error
+ /// \returns \emph{false} on success, \emph{true} on error
///
/// \details
/// Copies contents to the new path, and erases the old file.
@@ -366,16 +382,16 @@ public:
///
/// \param i the new index to move to
- /// \returns \f$false\f$ on success, \f$true\f$ otherwise
+ /// \returns \emph{false} on success, \emph{true} otherwise
bool set_pos(size_t i);
///
/// \brief return to the start of the stream
- /// \returns \f$false\f$ on success, \f$true\f$ otherwise
+ /// \returns \emph{false} on success, \emph{true} otherwise
bool rewind();
///
- /// \returns \f$true\f$ if the stream has reached the end of the file, \f$false\f$ otherwise
+ /// \returns \emph{true} if the stream has reached the end of the file, \emph{false} otherwise
bool eof() const;
/// @}
@@ -429,13 +445,13 @@ public:
///
/// \brief put a character at the current position in the stream
/// \param c the character to put
- /// \returns \f$false\f$ on success, \f$true\f$ otherwise
+ /// \returns \emph{false} on success, \emph{true} otherwise
bool putc(char c);
///
/// \brief put a wide character at the current position in the stream
/// \param c the character to put
- /// \returns \f$false\f$ on success, \f$true\f$ otherwise
+ /// \returns \emph{false} on success, \emph{true} otherwise
bool putwc(wchar_t c);
///
@@ -551,7 +567,7 @@ public:
/// \param args the argument values
template
void printf(const cstring& str, ArgsT&&...args) {
- string fmt = fennec::format(str, fennec::forward(args)...);
+ const string fmt = fennec::format(str, fennec::forward(args)...);
this->print(cstring(fmt.cstr(), fmt.length()));
}
diff --git a/include/fennec/filesystem/path.h b/include/fennec/filesystem/path.h
index 5d7fffc..c027e8d 100644
--- a/include/fennec/filesystem/path.h
+++ b/include/fennec/filesystem/path.h
@@ -115,7 +115,7 @@ public:
///
/// \brief C-String Assignment Operator
/// \param str the cstring to assign
- /// \returns a reference to \f$this\f$ after assigning \f$p\f$
+ /// \returns a reference to \emph{this} after assigning \emph{p}
template
path& operator=(const char (&str)[n]) {
_str = str;
@@ -125,7 +125,7 @@ public:
///
/// \brief C-String Assignment Operator
/// \param p the cstring to assign
- /// \returns a reference to \f$this\f$ after assigning \f$p\f$
+ /// \returns a reference to \emph{this} after assigning \emph{p}
path& operator=(const cstring& p) {
_str = p;
return *this;
@@ -134,7 +134,7 @@ public:
///
/// \brief String Assignment Operator
/// \param p the cstring to assign
- /// \returns a reference to \f$this\f$ after assigning \f$p\f$
+ /// \returns a reference to \emph{this} after assigning \emph{p}
path& operator=(const string& p) {
_str = p;
return *this;
@@ -143,7 +143,7 @@ public:
///
/// \brief Path Copy Assignment Operator
/// \param p the path to copy
- /// \returns a reference to \f$this\f$ after copying \f$p\f$
+ /// \returns a reference to \emph{this} after copying \emph{p}
path& operator=(const path& p) {
_str = p._str;
return *this;
@@ -152,7 +152,7 @@ public:
///
/// \brief Path Move Assignment Operator
/// \param p the path to take ownership of
- /// \returns a reference to \f$this\f$ after taking ownership of \f$p\f$
+ /// \returns a reference to \emph{this} after taking ownership of \emph{p}
path& operator=(path&& p) noexcept {
_str = move(p._str);
return *this;
@@ -170,7 +170,7 @@ public:
///
/// \brief path equality operator
/// \param p the path to compare against
- /// \returns \f$true\f$ if the paths are identical, \f$false\f$ otherwise. relative paths are not resolved
+ /// \returns \emph{true} if the paths are identical, \emph{false} otherwise. relative paths are not resolved
bool operator==(const path& p) const {
return _str == p._str;
}
@@ -187,7 +187,7 @@ public:
///
/// \brief path append operator
/// \param str the filename to append
- /// \returns a path containing the current path followed by \f$str\f$
+ /// \returns a path containing the current path followed by \emph{str}
path operator/(const cstring& str) const {
return path(_str + '/' + str);
}
@@ -195,7 +195,7 @@ public:
///
/// \brief path append operator
/// \param str the filename to append
- /// \returns a path containing the current path followed by \f$str\f$
+ /// \returns a path containing the current path followed by \emph{str}
path operator/(const string& str) const {
return path(_str + '/' + str);
}
@@ -203,7 +203,7 @@ public:
///
/// \brief path append operator
/// \param p the path to append
- /// \returns a path containing the current path followed by \f$p\f$
+ /// \returns a path containing the current path followed by \emph{p}
path operator/(const path& p) const {
return path(_str + '/' + p._str);
}
@@ -214,7 +214,7 @@ public:
/// \brief the filename of the current path
/// \returns a string containing a copy of the filename
string filename() const {
- size_t i = _str.rfind('/');
+ const size_t i = _str.rfind('/');
return _str.substring(i + 1);
}
@@ -227,9 +227,9 @@ public:
const char* cstr() const { return _str.cstr(); }
///
- /// \returns \f$true\f$ if the path is empty or points to root
+ /// \returns \emph{true} if the path is empty or points to root
bool is_empty() {
- size_t size = _str.size();
+ const size_t size = _str.size();
if (size == 0) return true;
#if FENNEC_PLATFORM_WINDOWS
return (_str[1] == ':' && size == 3);
@@ -322,21 +322,21 @@ public:
/// @{
///
- /// \brief C++ Iterator Specification \f$begin()\f$
+ /// \brief C++ Iterator Specification \emph{begin()}
/// \returns an iterator at the first filename in the path
iterator begin() const {
return iterator(this, 0);
}
///
- /// \brief C++ Iterator Specification \f$end()\f$
+ /// \brief C++ Iterator Specification \emph{end()}
/// \returns an iterator to the end of the path
iterator end() const {
return iterator(this, _str.size());
}
///
- /// \brief C++ Iterator Specification \f$iterator\f$
+ /// \brief C++ Iterator Specification \emph{iterator}
class iterator {
public:
///
@@ -363,7 +363,7 @@ public:
///
/// \brief prefix increment operator
- /// \returns \f$self\f$ after having moved to the next element in the list
+ /// \returns \emph{self} after having moved to the next element in the list
constexpr iterator& operator++() {
_pos = min(_str->find('/', _pos) + 1, _str->size());
return *this;
@@ -371,9 +371,9 @@ public:
///
/// \brief postfix increment operator
- /// \returns \f$self\f$ before having moved to the next element in the list
+ /// \returns \emph{self} before having moved to the next element in the list
constexpr iterator operator++(int) {
- iterator it = *this;
+ const iterator it = *this;
this->operator++();
return it;
}
@@ -381,7 +381,7 @@ public:
///
/// \brief iterator equality operator
/// \param rhs the iterator to compare with
- /// \returns \f$true\f$ if the iterators are identical, \f$false\f$ otherwise
+ /// \returns \emph{true} if the iterators are identical, \emph{false} otherwise
constexpr bool operator==(const iterator& rhs) const {
return _str == rhs._str and _pos == rhs._pos;
}
@@ -389,7 +389,7 @@ public:
///
/// \brief iterator inequality operator
/// \param rhs the iterator to compare with
- /// \returns \f$true\f$ if the iterators are different, \f$false\f$ otherwise
+ /// \returns \emph{true} if the iterators are different, \emph{false} otherwise
constexpr bool operator!=(const iterator& rhs) const {
return _str != rhs._str or _pos != rhs._pos;
}
diff --git a/include/fennec/format/format.h b/include/fennec/format/format.h
index b328317..79f5099 100644
--- a/include/fennec/format/format.h
+++ b/include/fennec/format/format.h
@@ -60,6 +60,8 @@ string format(const cstring& str, ArgsT&&...args) {
.type = '\0',
};
+ static_assert(argc > 0, "fennec::format may not accept 0 arguments");
+
// empty case
if constexpr(argc == 0) {
return str;
diff --git a/include/fennec/format/formatter.h b/include/fennec/format/formatter.h
index e9f25cb..e61c187 100644
--- a/include/fennec/format/formatter.h
+++ b/include/fennec/format/formatter.h
@@ -48,9 +48,9 @@ struct formatter {
///
/// \brief default format function
///
- /// \details throws a static assertion
+ /// \details Fails an assertion, the formatter is not implemented for the provided type
/// \returns empty string
- string operator()(const format_arg&, const T&) {
+ string operator()(const format_arg&, const T&) const {
static_assert(false, "Formatter not implemented for the provided type.");
return string("");
}
@@ -59,6 +59,8 @@ struct formatter {
// strings =============================================================================================================
+// TODO: String formatting
+
///
/// \brief formatter of a character array
/// \tparam N the number of characters
@@ -67,8 +69,8 @@ struct formatter {
///
/// \brief format function
/// \param str the string argument
- /// \returns the formatted version of \f$str\f$
- string operator()(const format_arg&, const char (&str)[N]) {
+ /// \returns the formatted version of \emph{str}
+ string operator()(const format_arg&, const char (&str)[N]) const {
return string(str);
}
};
@@ -81,8 +83,8 @@ struct formatter {
///
/// \brief format function
/// \param str the string argument
- /// \returns the formatted version of \f$str\f$
- string operator()(const format_arg&, const char (&str)[N]) {
+ /// \returns the formatted version of \emph{str}
+ string operator()(const format_arg&, const char (&str)[N]) const {
return string(str);
}
};
@@ -94,8 +96,8 @@ struct formatter {
///
/// \brief format function
/// \param str the string argument
- /// \returns the formatted version of \f$str\f$
- string operator()(const format_arg&, const cstring& str) {
+ /// \returns the formatted version of \emph{str}
+ string operator()(const format_arg&, const cstring& str) const {
return str;
}
};
@@ -107,8 +109,8 @@ struct formatter {
///
/// \brief format function
/// \param str the string argument
- /// \returns the formatted version of \f$str\f$
- string operator()(const format_arg&, const string& str) {
+ /// \returns the formatted version of \emph{str}
+ string operator()(const format_arg&, const string& str) const {
return str;
}
};
@@ -124,12 +126,12 @@ struct formatter {
/// \brief format function
/// \param fmt the format specification
/// \param x the integral argument
- /// \returns the formatted version of \f$x\f$
- string operator()(const format_arg& fmt, IntT x) {
+ /// \returns the formatted version of \emph{x}
+ string operator()(const format_arg& fmt, IntT x) const {
char digits[128] = {};
auto chk = fennec::to_chars(digits, digits + sizeof(digits), fennec::abs(x), fmt.base);
assertf(chk != nullptr, "fennec::format error, to_chars error");
- size_t len = chk - digits;
+ const size_t len = chk - digits;
// handle uppercase
if (fmt.upper) {
@@ -163,8 +165,8 @@ struct formatter {
memset(res.data(), fmt.fill, explen - len);
break;
case '^':
- size_t bef = fill / 2 + has_sign + prefix;
- size_t aft = explen - bef;
+ const size_t bef = fill / 2 + has_sign + prefix;
+ const size_t aft = explen - bef;
memcpy(res.data() + bef, digits, len);
sign = fmt.fill == '0' ? 0 : bef - 1 - prefix;
memset(res.data(), fmt.fill, bef);
@@ -200,8 +202,8 @@ struct formatter {
/// \brief format function
/// \param fmt the format specification
/// \param x the boolean argument
- /// \returns the formatted version of \f$x\f$
- string operator()(const format_arg& fmt, BoolT x) {
+ /// \returns the formatted version of \emph{x}
+ string operator()(const format_arg& fmt, BoolT x) const {
if (fmt.type == 's' or fmt.type == '\0') {
return x ? string("true") : string("false");
}
@@ -218,8 +220,8 @@ struct formatter {
/// \brief format function
/// \param fmt the format specification
/// \param x the float argument
- /// \returns the formatted version of \f$x\f$
- string operator()(const format_arg& fmt, FloatT x) {
+ /// \returns the formatted version of \emph{x}
+ string operator()(const format_arg& fmt, FloatT x) const {
// nan & inf cases
if (fennec::isnan(x)) {
@@ -267,8 +269,8 @@ struct formatter {
memset(res.data(), fmt.fill, explen - len);
break;
case '^':
- size_t bef = fill / 2 + has_sign + prefix;
- size_t aft = explen - bef;
+ const size_t bef = fill / 2 + has_sign + prefix;
+ const size_t aft = explen - bef;
memcpy(res.data() + bef, digits, len);
sign = fmt.fill == '0' ? 0 : bef - 1 - prefix;
memset(res.data(), fmt.fill, bef);
diff --git a/include/fennec/interpret/tokenizer.h b/include/fennec/interpret/tokenizer.h
index b980315..7fd4517 100644
--- a/include/fennec/interpret/tokenizer.h
+++ b/include/fennec/interpret/tokenizer.h
@@ -94,8 +94,8 @@ private:
list res;
priority_queue> idx;
- for (char c : delimiter) {
- size_t i = 0;
+ for (const char c : delimiter) {
+ const size_t i = 0;
while (i != line.size()) {
size_t n = line.find(c, i);
// TODO
diff --git a/include/fennec/lang/assert.h b/include/fennec/lang/assert.h
index 9f4bf88..ecedfbc 100644
--- a/include/fennec/lang/assert.h
+++ b/include/fennec/lang/assert.h
@@ -48,18 +48,18 @@
///
/// assert(expr, desc)
/// |
-/// Make an assertion with expression \f$expr\f$ and provide a description \f$desc\f$. Only halts in debug mode.
+/// Make an assertion with expression \emph{expr} and provide a description \emph{desc}. Only halts in debug mode.
///
/// |
/// assertf(expr, desc)
/// |
-/// Make an assertion with expression \f$expr\f$ and provide a description \f$desc\f$. Always halts.
+/// Make an assertion with expression \emph{expr} and provide a description \emph{desc}. Always halts.
///
/// |
/// assertd(expr, desc)
/// |
-/// Make an assertion, ***only in debug mode***, with expression \f$expr\f$ and provide a description \f$desc\f$.
-/// This should be used when the branching caused by \f$assert\f$ would hinder performance in release mode.
+/// Make an assertion, ***only in debug mode***, with expression \emph{expr} and provide a description \emph{desc}.
+/// This should be used when the branching caused by \emph{assert} would hinder performance in release mode.
///
///
///
@@ -92,7 +92,7 @@ void _assert(const char (&expr)[ExprL],
/// \param description the description of the assertion
#define assert(expression, description) \
if(not(expression)) [[unlikely]] { \
- _assert(#expression, __FILE__, __LINE__, __PRETTY_FUNCTION__, description, not FENNEC_RELEASE); \
+ _assert(#expression, __FILE__, __LINE__, __PRETTY_FUNCTION__, description, FENNEC_DEBUG); \
}
///
diff --git a/include/fennec/lang/bits.h b/include/fennec/lang/bits.h
index fe5b871..3217a03 100644
--- a/include/fennec/lang/bits.h
+++ b/include/fennec/lang/bits.h
@@ -116,7 +116,7 @@ constexpr ToT bit_cast(const FromT& from) {
/// \param arr the array of bytes to modify
/// \param mask the mask to and against arr
/// \param n the number of bytes
-/// \returns the pointer \f$arr\f$
+/// \returns the pointer \emph{arr}
constexpr void* bit_and(void* arr, const void* mask, size_t n) {
if (arr == mask) {
return arr;
diff --git a/include/fennec/lang/compare.h b/include/fennec/lang/compare.h
index bfa5cca..4757789 100644
--- a/include/fennec/lang/compare.h
+++ b/include/fennec/lang/compare.h
@@ -33,23 +33,23 @@ namespace fennec
template struct equality;
///
-/// \brief Implementations for two types that have a common equality operator \f$==\f$
+/// \brief Implementations for two types that have a common equality operator \math{=}
/// \tparam T0 The first type
/// \tparam T1 The second type
template requires has_equals_v
struct equality {
///
/// \brief operator to test the two values
- /// \param x the value of type \f$T0\f$
- /// \param y the value of type \f$T1\f$
- /// \returns \f$true\f$ if equal, \f$false\f$ otherwise
+ /// \param x the value of type \emph{T0}
+ /// \param y the value of type \emph{T1}
+ /// \returns \emph{true} if equal, \emph{false} otherwise
constexpr bool operator()(const T0& x, const T1& y) const {
return x == y;
}
};
///
-/// \brief Implementations for two types that have a common less operator \f$<\f$
+/// \brief Implementations for two types that have a common less operator \math{<}
/// \tparam T0 The first type
/// \tparam T1 The second type
template requires(not has_equals_v
@@ -57,16 +57,16 @@ template requires(not has_equals_v
struct equality {
///
/// \brief operator to test the two values
- /// \param x the value of type \f$T0\f$
- /// \param y the value of type \f$T1\f$
- /// \returns \f$true\f$ if equal, \f$false\f$ otherwise
+ /// \param x the value of type \emph{T0}
+ /// \param y the value of type \emph{T1}
+ /// \returns \emph{true} if equal, \emph{false} otherwise
constexpr bool operator()(const T0& x, const T1& y) const {
return not(x < y) and not(y < x);
}
};
///
-/// \brief Implementations for two types that have a common greater operator \f$>\f$
+/// \brief Implementations for two types that have a common greater operator \math{>}
/// \tparam T0 The first type
/// \tparam T1 The second type
template requires(not(has_equals_v)
@@ -75,9 +75,9 @@ template | |