- Fixed some more compilation issues
- Added some more information to the licensing section of README.md
This commit is contained in:
@@ -21,11 +21,40 @@
|
||||
|
||||
#include <fennec/fproc/strings/string.h>
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
string getcwd();
|
||||
inline string getcwd() {
|
||||
char cstr[MAX_PATH];
|
||||
if (GetCurrentDirectory(sizeof(str), str) == 0) {
|
||||
return string("");
|
||||
}
|
||||
return string(cstr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <unistd.h>
|
||||
#include <linux/limits.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
inline string getcwd() {
|
||||
char cstr[PATH_MAX];
|
||||
if (::getcwd(cstr, sizeof(cstr)) == NULL) {
|
||||
return string("");
|
||||
}
|
||||
return string(cstr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // FENNEC_FPROC_IO_COMMON_H
|
||||
|
||||
@@ -136,13 +136,13 @@ public:
|
||||
/// \brief Dereference Operator
|
||||
/// \returns A const qualified pointer to the underlying allocation
|
||||
constexpr const char* operator*() const {
|
||||
return _str;
|
||||
return _str.data();
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Implicit Dereference Cast
|
||||
constexpr operator const char*() const {
|
||||
return _str;
|
||||
return _str.data();
|
||||
}
|
||||
|
||||
|
||||
@@ -163,9 +163,27 @@ public:
|
||||
if (i >= size()) { // bounds check
|
||||
return -1;
|
||||
}
|
||||
n = min(n, max(_str, str.size()) + 1);
|
||||
n = fennec::min(n, fennec::max(_str, str.size()) + 1);
|
||||
|
||||
return ::strncmp(_str + i, str, n);
|
||||
return ::strncmp(_str.data() + i, str, n);
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief String Comparison
|
||||
/// \param ostr the string to compare against
|
||||
/// \returns Zero if both strings are equal, otherwise a negative value if lhs appears before rhs according to the
|
||||
/// current locale, otherwise a positive value.
|
||||
constexpr int compare(const string& str, size_t i = 0, size_t n = npos) const {
|
||||
if (i >= size()) { // bounds check
|
||||
return -1;
|
||||
}
|
||||
n = min(n, max(size(), str.size()) + 1);
|
||||
|
||||
return ::strncmp(_str.data() + i, str, n);
|
||||
}
|
||||
|
||||
constexpr bool operator==(const _string& str) const {
|
||||
return compare(str) == 0;
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
@@ -548,6 +548,13 @@ public:
|
||||
return _data;
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Getter for the real pointer to the allocated block of memory
|
||||
/// \returns Pointer to the allocated memory.
|
||||
constexpr const value_t* data() const {
|
||||
return _data;
|
||||
}
|
||||
|
||||
private:
|
||||
alloc_t _alloc; // Allocator object
|
||||
value_t* _data; // Handle for the memory block
|
||||
|
||||
@@ -102,4 +102,37 @@ void operator delete (void* ptr, fennec::align_t, const fennec::nothrow_t&) noe
|
||||
void operator delete[](void* ptr, fennec::align_t, const fennec::nothrow_t&) noexcept;
|
||||
|
||||
|
||||
// Platform specific code
|
||||
#ifdef _WIN32
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
inline size_T pagesize() {
|
||||
SYSTEM_INFO sysInfo;
|
||||
GetSystemInfo(&sysInfo);
|
||||
return sysInfo.dwPageSize;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
inline size_t pagesize() {
|
||||
return sysconf(_SC_PAGESIZE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif // FENNEC_MEMORY_NEW_H
|
||||
|
||||
Reference in New Issue
Block a user