diff --git a/ext/crlib/cr-array.h b/ext/crlib/cr-array.h index fae8971..fe613e6 100644 --- a/ext/crlib/cr-array.h +++ b/ext/crlib/cr-array.h @@ -1,6 +1,6 @@ // // CRLib - Simple library for STL replacement in private projects. -// Copyright © 2020 YaPB Development Team . +// Copyright © 2020 YaPB Development Team . // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -33,9 +33,9 @@ CR_NAMESPACE_BEGIN // simple array class like std::vector template class Array : public DenyCopying { private: - T *m_data {}; - size_t m_capacity {}; - size_t m_length {}; + T *contents_ {}; + size_t capacity_ {}; + size_t length_ {}; public: explicit Array () { @@ -49,9 +49,9 @@ public: } Array (Array &&rhs) noexcept { - m_data = rhs.m_data; - m_length = rhs.m_length; - m_capacity = rhs.m_capacity; + contents_ = rhs.contents_; + length_ = rhs.length_; + capacity_ = rhs.capacity_; rhs.reset (); } @@ -68,8 +68,8 @@ public: private: void destructElements () noexcept { - for (size_t i = 0; i < m_length; ++i) { - alloc.destruct (&m_data[i]); + for (size_t i = 0; i < length_; ++i) { + alloc.destruct (&contents_[i]); } } @@ -82,55 +82,55 @@ private: void destroy () { destructElements (); - alloc.deallocate (m_data); + alloc.deallocate (contents_); } void reset () { - m_data = nullptr; - m_capacity = 0; - m_length = 0; + contents_ = nullptr; + capacity_ = 0; + length_ = 0; } public: bool reserve (const size_t amount) { - if (m_length + amount < m_capacity) { + if (length_ + amount < capacity_) { return true; } - auto capacity = m_capacity ? m_capacity : 12; + auto capacity = capacity_ ? capacity_ : 12; if (cr::fix (R == ReservePolicy::Multiple)) { - while (m_length + amount > capacity) { + while (length_ + amount > capacity) { capacity *= 2; } } else { - capacity = amount + m_capacity + 1; + capacity = amount + capacity_ + 1; } auto data = alloc.allocate (capacity); - if (m_data) { - transferElements (data, m_data, m_length); - alloc.deallocate (m_data); + if (contents_) { + transferElements (data, contents_, length_); + alloc.deallocate (contents_); } - m_data = data; - m_capacity = capacity; + contents_ = data; + capacity_ = capacity; return true; } bool resize (const size_t amount) { - if (amount < m_length) { - while (amount < m_length) { + if (amount < length_) { + while (amount < length_) { discard (); } } - else if (amount > m_length) { + else if (amount > length_) { if (!ensure (amount)) { return false; } - size_t resizeLength = amount - m_length; + size_t resizeLength = amount - length_; while (resizeLength--) { emplace (); @@ -140,30 +140,30 @@ public: } bool ensure (const size_t amount) { - if (amount <= m_length) { + if (amount <= length_) { return true; } - return reserve (amount - m_length); + return reserve (amount - length_); } template U length () const { - return static_cast (m_length); + return static_cast (length_); } size_t capacity () const { - return m_capacity; + return capacity_; } template bool set (size_t index, U &&object) { - if (index >= m_capacity) { + if (index >= capacity_) { if (!reserve (index + 1)) { return false; } } - alloc.construct (&m_data[index], cr::forward (object)); + alloc.construct (&contents_[index], cr::forward (object)); - if (index >= m_length) { - m_length = index + 1; + if (index >= length_) { + length_ = index + 1; } return true; } @@ -176,28 +176,28 @@ public: if (!objects || !count) { return false; } - const size_t capacity = (m_length > index ? m_length : index) + count; + const size_t capacity = (length_ > index ? length_ : index) + count; - if (capacity >= m_capacity && !reserve (capacity)) { + if (capacity >= capacity_ && !reserve (capacity)) { return false; } - if (index >= m_length) { + if (index >= length_) { for (size_t i = 0; i < count; ++i) { - alloc.construct (&m_data[i + index], cr::forward (objects[i])); + alloc.construct (&contents_[i + index], cr::forward (objects[i])); } - m_length = capacity; + length_ = capacity; } else { size_t i = 0; - for (i = m_length; i > index; --i) { - m_data[i + count - 1] = cr::move (m_data[i - 1]); + for (i = length_; i > index; --i) { + contents_[i + count - 1] = cr::move (contents_[i - 1]); } for (i = 0; i < count; ++i) { - alloc.construct (&m_data[i + index], cr::forward (objects[i])); + alloc.construct (&contents_[i + index], cr::forward (objects[i])); } - m_length += count; + length_ += count; } return true; } @@ -206,20 +206,20 @@ public: if (&rhs == this) { return false; } - return insert (at, &rhs.m_data[0], rhs.m_length); + return insert (at, &rhs.contents_[0], rhs.length_); } bool erase (const size_t index, const size_t count) { - if (index + count > m_capacity) { + if (index + count > capacity_) { return false; } for (size_t i = index; i < index + count; ++i) { - alloc.destruct (&m_data[i]); + alloc.destruct (&contents_[i]); } - m_length -= count; + length_ -= count; - for (size_t i = index; i < m_length; ++i) { - m_data[i] = cr::move (m_data[i + count]); + for (size_t i = index; i < length_; ++i) { + contents_[i] = cr::move (contents_[i + count]); } return true; } @@ -240,8 +240,8 @@ public: if (!reserve (1)) { return false; } - alloc.construct (&m_data[m_length], cr::forward (object)); - ++m_length; + alloc.construct (&contents_[length_], cr::forward (object)); + ++length_; return true; } @@ -250,41 +250,41 @@ public: if (!reserve (1)) { return false; } - alloc.construct (&m_data[m_length], cr::forward (args)...); - ++m_length; + alloc.construct (&contents_[length_], cr::forward (args)...); + ++length_; return true; } T pop () { - auto object = cr::move (m_data[m_length - 1]); + auto object = cr::move (contents_[length_ - 1]); discard (); return object; } void discard () { - erase (m_length - 1, 1); + erase (length_ - 1, 1); } size_t index (const T &object) const { - return &object - &m_data[0]; + return &object - &contents_[0]; } void shuffle () { - for (size_t i = m_length; i >= 1; --i) { - cr::swap (m_data[i - 1], m_data[rg.int_ (i, m_length - 2)]); + for (size_t i = length_; i >= 1; --i) { + cr::swap (contents_[i - 1], contents_[rg.int_ (i, length_ - 2)]); } } void reverse () { - for (size_t i = 0; i < m_length / 2; ++i) { - cr::swap (m_data[i], m_data[m_length - 1 - i]); + for (size_t i = 0; i < length_ / 2; ++i) { + cr::swap (contents_[i], contents_[length_ - 1 - i]); } } template bool extend (U &&rhs) { - if (m_length == 0) { + if (length_ == 0) { *this = cr::move (rhs); } else { @@ -304,67 +304,67 @@ public: void clear () { destructElements (); - m_length = 0; + length_ = 0; } bool empty () const { - return m_length == 0; + return length_ == 0; } bool shrink () { - if (m_length == m_capacity || !m_length) { + if (length_ == capacity_ || !length_) { return false; } - auto data = alloc.allocate (m_length); - transferElements (data, m_data, m_length); + auto data = alloc.allocate (length_); + transferElements (data, contents_, length_); - alloc.deallocate (m_data); + alloc.deallocate (contents_); - m_data = data; - m_capacity = m_length; + contents_ = data; + capacity_ = length_; return true; } const T &at (size_t index) const { - return m_data[index]; + return contents_[index]; } T &at (size_t index) { - return m_data[index]; + return contents_[index]; } const T &first () const { - return m_data[0]; + return contents_[0]; } T &first () { - return m_data[0]; + return contents_[0]; } T &last () { - return m_data[m_length - 1]; + return contents_[length_ - 1]; } const T &last () const { - return m_data[m_length - 1]; + return contents_[length_ - 1]; } const T &random () const { - return m_data[rg.int_ (0, m_length - 1)]; + return contents_[rg.int_ (0, length_ - 1)]; } T &random () { - return m_data[rg.int_ (0u, m_length - 1u)]; + return contents_[rg.int_ (0u, length_ - 1u)]; } T *data () { - return m_data; + return contents_; } T *data () const { - return m_data; + return contents_; } public: @@ -372,9 +372,9 @@ public: if (this != &rhs) { destroy (); - m_data = rhs.m_data; - m_length = rhs.m_length; - m_capacity = rhs.m_capacity; + contents_ = rhs.contents_; + length_ = rhs.length_; + capacity_ = rhs.capacity_; rhs.reset (); } @@ -393,19 +393,19 @@ public: // for range-based loops public: T *begin () { - return m_data; + return contents_; } T *begin () const { - return m_data; + return contents_; } T *end () { - return m_data + m_length; + return contents_ + length_; } T *end () const { - return m_data + m_length; + return contents_ + length_; } }; diff --git a/ext/crlib/cr-dict.h b/ext/crlib/cr-dict.h index ae0dd42..6a18d98 100644 --- a/ext/crlib/cr-dict.h +++ b/ext/crlib/cr-dict.h @@ -1,6 +1,6 @@ // // CRLib - Simple library for STL replacement in private projects. -// Copyright © 2020 YaPB Development Team . +// Copyright © 2020 YaPB Development Team . // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -96,38 +96,38 @@ public: }; private: - Array m_table; - Array m_buckets{}; - H m_hasher; + Array contents_; + Array buckets_; + H hashFunction_; private: uint32 hash (const K &key) const { - return m_hasher (key); + return hashFunction_ (key); } size_t find (const K &key, bool allocate) { auto hashed = hash (key); - auto pos = hashed % m_table.length (); + auto pos = hashed % contents_.length (); - for (auto bucket = m_table[pos]; bucket != nullptr; bucket = bucket->next) { - if (m_buckets[bucket->index].hash == hashed) { + for (auto bucket = contents_[pos]; bucket != nullptr; bucket = bucket->next) { + if (buckets_[bucket->index].hash == hashed) { return bucket->index; } } if (allocate) { - size_t created = m_buckets.length (); - m_buckets.resize (created + 1); + size_t created = buckets_.length (); + buckets_.resize (created + 1); auto allocated = alloc.allocate (); allocated->index = static_cast (created); - allocated->next = m_table[pos]; + allocated->next = contents_[pos]; - m_table[pos] = allocated; + contents_[pos] = allocated; - m_buckets[created].key = key; - m_buckets[created].hash = hashed; + buckets_[created].key = key; + buckets_[created].hash = hashed; return created; } @@ -143,7 +143,7 @@ public: reset (); } - Dictionary (Dictionary &&rhs) noexcept : m_table (cr::move (rhs.m_table)), m_buckets (cr::move (rhs.m_buckets)), m_hasher (cr::move (rhs.m_hasher)) + Dictionary (Dictionary &&rhs) noexcept : contents_ (cr::move (rhs.contents_)), buckets_ (cr::move (rhs.buckets_)), hashFunction_ (cr::move (rhs.hashFunction_)) { } ~Dictionary () { @@ -156,11 +156,11 @@ public: } bool empty () const { - return m_buckets.empty (); + return buckets_.empty (); } size_t length () const { - return m_buckets.length (); + return buckets_.length (); } bool find (const K &key, V &value) const { @@ -169,7 +169,7 @@ public: if (index == InvalidIndex) { return false; } - value = m_buckets[index].value; + value = buckets_[index].value; return true; } @@ -181,20 +181,20 @@ public: bool remove (const K &key) { auto hashed = hash (key); - auto pos = hashed % m_table.length (); - auto *bucket = m_table[pos]; + auto pos = hashed % contents_.length (); + auto *bucket = contents_[pos]; DictList *next = nullptr; while (bucket != nullptr) { - if (m_buckets[bucket->index].hash == hashed) { + if (buckets_[bucket->index].hash == hashed) { if (!next) { - m_table[pos] = bucket->next; + contents_[pos] = bucket->next; } else { next->next = bucket->next; } - m_buckets.erase (bucket->index, 1); + buckets_.erase (bucket->index, 1); alloc.deallocate (bucket); bucket = nullptr; @@ -208,7 +208,7 @@ public: } void clear () { - for (auto object : m_table) { + for (auto object : contents_) { while (object != nullptr) { auto next = object->next; @@ -216,34 +216,34 @@ public: object = next; } } - m_table.clear (); - m_buckets.clear (); + contents_.clear (); + buckets_.clear (); reset (); } void reset () { - m_table.resize (HashSize); + contents_.resize (HashSize); for (size_t i = 0; i < HashSize; ++i) { - m_table[i] = nullptr; + contents_[i] = nullptr; } } public: V &operator [] (const K &key) { - return m_buckets[find (key, true)].value; + return buckets_[find (key, true)].value; } const V &operator [] (const K &key) const { - return m_buckets[findIndex (key)].value; + return buckets_[findIndex (key)].value; } Dictionary &operator = (Dictionary &&rhs) noexcept { if (this != &rhs) { - m_table = cr::move (rhs.m_table); - m_buckets = cr::move (rhs.m_buckets); - m_hasher = cr::move (rhs.m_hasher); + contents_ = cr::move (rhs.contents_); + buckets_ = cr::move (rhs.buckets_); + hashFunction_ = cr::move (rhs.hashFunction_); } return *this; } @@ -251,19 +251,19 @@ public: // for range-based loops public: DictBucket *begin () { - return m_buckets.begin (); + return buckets_.begin (); } DictBucket *begin () const { - return m_buckets.begin (); + return buckets_.begin (); } DictBucket *end () { - return m_buckets.end (); + return buckets_.end (); } DictBucket *end () const { - return m_buckets.end (); + return buckets_.end (); } }; diff --git a/ext/crlib/cr-string.h b/ext/crlib/cr-string.h index 7b55f3d..34292f7 100644 --- a/ext/crlib/cr-string.h +++ b/ext/crlib/cr-string.h @@ -1,6 +1,6 @@ // // CRLib - Simple library for STL replacement in private projects. -// Copyright © 2020 YaPB Development Team . +// Copyright © 2020 YaPB Development Team . // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -504,7 +503,7 @@ public: } StringRef str () const { - return StringRef (chars_.get (), length_); + return { chars_.get (), length_ }; } public: @@ -824,8 +823,8 @@ public: }; private: - char m_data[RotationCount + 1][StaticBufferSize] {}; - size_t m_rotate = 0; + char data_[RotationCount + 1][StaticBufferSize] {}; + size_t rotate_ = 0; public: StringBuffer () = default; @@ -833,24 +832,24 @@ public: public: char *chars () noexcept { - if (++m_rotate >= RotationCount) { - m_rotate = 0; + if (++rotate_ >= RotationCount) { + rotate_ = 0; } - auto result = m_data[cr::clamp (m_rotate, 0, RotationCount)]; + auto result = data_[cr::clamp (rotate_, 0, RotationCount)]; result[0] = kNullChar; return result; } template U *format (const U *fmt, Args &&...args) noexcept { - auto buffer = Singleton ::instance ().chars (); + auto buffer = Singleton ::instance ()->chars (); fmtwrap.exec (buffer, StaticBufferSize, fmt, args...); return buffer; } template U *format (const U *fmt) noexcept { - auto buffer = Singleton ::instance ().chars (); + auto buffer = Singleton ::instance ()->chars (); copy (buffer, fmt, StaticBufferSize); return buffer; @@ -918,7 +917,7 @@ private: }; private: - Utf8CaseTable m_toUpperTable[Utf8MaxChars] = { + Utf8CaseTable upperTable_[Utf8MaxChars] = { { 0x0061, 0x0041 }, { 0x0062, 0x0042 }, { 0x0063, 0x0043 }, { 0x0064, 0x0044 }, { 0x0065, 0x0045 }, { 0x0066, 0x0046 }, { 0x0067, 0x0047 }, { 0x0068, 0x0048 }, { 0x0069, 0x0049 }, { 0x006a, 0x004a }, { 0x006b, 0x004b }, { 0x006c, 0x004c }, { 0x006d, 0x004d }, { 0x006e, 0x004e }, { 0x006f, 0x004f }, { 0x0070, 0x0050 }, { 0x0071, 0x0051 }, { 0x0072, 0x0052 }, { 0x0073, 0x0053 }, { 0x0074, 0x0054 }, { 0x0075, 0x0055 }, { 0x0076, 0x0056 }, { 0x0077, 0x0057 }, { 0x0078, 0x0058 }, @@ -1011,16 +1010,16 @@ private: }; private: - SmallArray m_utfTable; + SmallArray utfTable_; private: void buildTable () { - m_utfTable.emplace (0x80, 0x00, 0 * 6, 0x7f, 0); // 1 byte sequence - m_utfTable.emplace (0xe0, 0xc0, 1 * 6, 0x7ff, 0x80); // 2 byte sequence - m_utfTable.emplace (0xf0, 0xe0, 2 * 6, 0xffff, 0x800); // 3 byte sequence - m_utfTable.emplace (0xf8, 0xf0, 3 * 6, 0x1fffff, 0x10000); // 4 byte sequence - m_utfTable.emplace (0xfc, 0xf8, 4 * 6, 0x3ffffff, 0x200000); // 5 byte sequence - m_utfTable.emplace (0xfe, 0xfc, 5 * 6, 0x7fffffff, 0x4000000); // 6 byte sequence + utfTable_.emplace (0x80, 0x00, 0 * 6, 0x7f, 0); // 1 byte sequence + utfTable_.emplace (0xe0, 0xc0, 1 * 6, 0x7ff, 0x80); // 2 byte sequence + utfTable_.emplace (0xf0, 0xe0, 2 * 6, 0xffff, 0x800); // 3 byte sequence + utfTable_.emplace (0xf8, 0xf0, 3 * 6, 0x1fffff, 0x10000); // 4 byte sequence + utfTable_.emplace (0xfc, 0xf8, 4 * 6, 0x3ffffff, 0x200000); // 5 byte sequence + utfTable_.emplace (0xfe, 0xfc, 5 * 6, 0x7fffffff, 0x4000000); // 6 byte sequence } int32 multiByteToWideChar (wchar_t *wide, const char *mbs) { @@ -1029,7 +1028,7 @@ private: auto ch = *mbs; auto lval = static_cast (ch); - for (const auto &table : m_utfTable) { + for (const auto &table : utfTable_) { len++; if ((ch & table.cmask) == table.cval) { @@ -1059,7 +1058,7 @@ private: long lmask = wide; int32 len = 0; - for (const auto &table : m_utfTable) { + for (const auto &table : utfTable_) { len++; if (lmask <= table.lmask) { @@ -1092,10 +1091,10 @@ public: while (bottom <= top) { const auto mid = (bottom + top) / 2; - wchar_t cur = static_cast (m_toUpperTable[mid].from); + auto cur = static_cast (upperTable_[mid].from); if (ch == cur) { - return static_cast (m_toUpperTable[mid].to); + return static_cast (upperTable_[mid].to); } if (ch > cur) { bottom = mid + 1; diff --git a/vc/yapb.vcxproj b/vc/yapb.vcxproj index cd0c88f..2aed5ad 100644 --- a/vc/yapb.vcxproj +++ b/vc/yapb.vcxproj @@ -11,36 +11,36 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vc/yapb.vcxproj.filters b/vc/yapb.vcxproj.filters index 9271b40..1edea0e 100644 --- a/vc/yapb.vcxproj.filters +++ b/vc/yapb.vcxproj.filters @@ -13,12 +13,12 @@ {bec0fb46-08b4-4bfa-900c-d279a933ff77} - - {f6a0fc04-bdf5-479b-8e5a-85eae698541e} - {5e73b918-f42b-4df9-bbe9-918289e44ad2} + + {f6a0fc04-bdf5-479b-8e5a-85eae698541e} + @@ -42,96 +42,6 @@ inc - - inc\ext\crlib - - - inc\ext\crlib - - - inc\ext\crlib - - - inc\ext\crlib - - - inc\ext\crlib - - - inc\ext\crlib - - - inc\ext\crlib - - - inc\ext\crlib - - - inc\ext\crlib - - - inc\ext\crlib - - - inc\ext\crlib - - - inc\ext\crlib - - - inc\ext\crlib - - - inc\ext\crlib - - - inc\ext\crlib - - - inc\ext\crlib - - - inc\ext\crlib - - - inc\ext\crlib - - - inc\ext\crlib - - - inc\ext\crlib - - - inc\ext\crlib - - - inc\ext\crlib - - - inc\ext\sdk - - - inc\ext\sdk - - - inc\ext\sdk - - - inc\ext\sdk - - - inc\ext\sdk - - - inc\ext\sdk - - - inc\ext\sdk - - - inc\ext\sdk - inc @@ -141,6 +51,96 @@ inc + + inc\ext\hlsdk + + + inc\ext\hlsdk + + + inc\ext\hlsdk + + + inc\ext\hlsdk + + + inc\ext\hlsdk + + + inc\ext\hlsdk + + + inc\ext\hlsdk + + + inc\ext\hlsdk + + + inc\ext\crlib + + + inc\ext\crlib + + + inc\ext\crlib + + + inc\ext\crlib + + + inc\ext\crlib + + + inc\ext\crlib + + + inc\ext\crlib + + + inc\ext\crlib + + + inc\ext\crlib + + + inc\ext\crlib + + + inc\ext\crlib + + + inc\ext\crlib + + + inc\ext\crlib + + + inc\ext\crlib + + + inc\ext\crlib + + + inc\ext\crlib + + + inc\ext\crlib + + + inc\ext\crlib + + + inc\ext\crlib + + + inc\ext\crlib + + + inc\ext\crlib + + + inc\ext\crlib +