Skip to content

Commit

Permalink
Update CorradeString.hpp to latest.
Browse files Browse the repository at this point in the history
  • Loading branch information
mosra committed Feb 12, 2025
1 parent 4128770 commit 5a41684
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
34 changes: 20 additions & 14 deletions CorradeString.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1BasicString.html
https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1BasicStringView.html
Depends on CorradeEnumSet.h, the implementation depends on CorradePair.h
and CorradeCpu.hpp.
Depends on CorradeEnumSet.h, the implementation depends on CorradeCpu.hpp.
This is a single-header library generated from the Corrade project. With
the goal being easy integration, it's deliberately free of all comments
Expand Down Expand Up @@ -37,6 +36,8 @@
`#define CORRADE_STRING_STL_VIEW_COMPATIBILITY` before including the file.
Including it multiple times with different macros defined works too.
v2020.06-1864-g8b00 (2025-02-12)
- Removed dependency on Containers::Pair
v2020.06-1846-gc4cdf (2025-01-07)
- Fixed embarrassing bugs in the NEON and WASM SIMD code paths for find()
- SFINAE is now done in template args as that's simpler for the compiler
Expand All @@ -52,7 +53,7 @@
v2020.06-1502-g147e (2023-09-11)
- Initial release
Generated from Corrade v2020.06-1846-gc4cdf (2025-01-07), 2517 / 2176 LoC
Generated from Corrade v2020.06-1864-g8b00 (2025-02-12), 2523 / 2179 LoC
*/

/*
Expand Down Expand Up @@ -135,7 +136,6 @@ namespace Corrade { namespace Containers {
class String;
template<class> class BasicStringView;
typedef BasicStringView<const char> StringView;
template<class, class> class Pair;

}}
#endif
Expand Down Expand Up @@ -842,7 +842,11 @@ class CORRADE_UTILITY_EXPORT String {
CORRADE_UTILITY_LOCAL void construct(const char* data, std::size_t size);
CORRADE_UTILITY_LOCAL void copyConstruct(const String& other);
CORRADE_UTILITY_LOCAL void destruct();
CORRADE_UTILITY_LOCAL Pair<const char*, std::size_t> dataInternal() const;
struct Data {
const char* data;
std::size_t size;
};
CORRADE_UTILITY_LOCAL Data dataInternal() const;

MutableStringView sliceSizePointerInternal(char* begin, std::size_t size);
StringView sliceSizePointerInternal(const char* begin, std::size_t size) const;
Expand Down Expand Up @@ -885,17 +889,20 @@ class CORRADE_UTILITY_EXPORT String {

namespace Corrade { namespace Containers { namespace Implementation {

template<> struct CORRADE_UTILITY_EXPORT StringConverter<std::string> {
template<> struct
StringConverter<std::string> {
static String from(const std::string& other);
static std::string to(const String& other);
};

template<> struct CORRADE_UTILITY_EXPORT StringViewConverter<const char, std::string> {
template<> struct
StringViewConverter<const char, std::string> {
static StringView from(const std::string& other);
static std::string to(StringView other);
};

template<> struct CORRADE_UTILITY_EXPORT StringViewConverter<char, std::string> {
template<> struct
StringViewConverter<char, std::string> {
static MutableStringView from(std::string& other);
static std::string to(MutableStringView other);
};
Expand Down Expand Up @@ -1016,7 +1023,6 @@ template<> struct StringViewConverter<char, std::string_view> {
CORRADE_INTERNAL_ASSERT_UNREACHABLE()
#endif

#include "CorradePair.h"
#include "CorradeCpu.hpp"

#if ((defined(CORRADE_ENABLE_SSE2) || defined(CORRADE_ENABLE_AVX)) && defined(CORRADE_ENABLE_BMI1)) || (defined(CORRADE_ENABLE_AVX) && defined(CORRADE_ENABLE_POPCNT))
Expand Down Expand Up @@ -1966,7 +1972,7 @@ inline void String::destruct() {
else delete[] _large.data;
}

inline Pair<const char*, std::size_t> String::dataInternal() const {
inline String::Data String::dataInternal() const {
if(_small.size & Implementation::SmallStringBit)
return {_small.data, _small.size & ~SmallSizeMask};
return {_large.data, _large.size & ~LargeSizeMask};
Expand Down Expand Up @@ -2035,11 +2041,11 @@ String::String(AllocatedInitT, String&& other) {
}

String::String(AllocatedInitT, const String& other) {
const Pair<const char*, std::size_t> data = other.dataInternal();
const std::size_t sizePlusOne = data.second() + 1;
_large.size = data.second();
const Data data = other.dataInternal();
const std::size_t sizePlusOne = data.size + 1;
_large.size = data.size;
_large.data = new char[sizePlusOne];
std::memcpy(_large.data, data.first(), sizePlusOne);
std::memcpy(_large.data, data.data, sizePlusOne);
_large.deleter = nullptr;
}

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Library | LoC | PpLoC<sup>[1]</sup> | Description
**[CorradePointer.h](CorradePointer.h)** | 381 | 1769 | [Containers::Pointer](https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1Pointer.html), a lightweight alternative to [`std::unique_ptr`](https://en.cppreference.com/w/cpp/memory/unique_ptr)
**[CorradeReference.h](CorradeReference.h)** | 131 | 1613 | [Containers::Reference](https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1Reference.html), a lightweight alternative to [`std::reference_wrapper`](https://en.cppreference.com/w/cpp/utility/functional/reference_wrapper)
**[CorradeScopeGuard.h](CorradeScopeGuard.h)** | 263 | 1689 | [Containers::ScopeGuard](https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1ScopeGuard.html), a lightweight alternative to [`std::unique_ptr`](https://en.cppreference.com/w/cpp/memory/unique_ptr) with a custom deleter
**[CorradeString.hpp](CorradeString.hpp)** | 2517<sup>[2]</sup> | 2176 | [Containers::String](https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1String.html) and [Containers::StringView](https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1BasicStringView.html), lightweight and optimized string (view) classes. Depends on `CorradeEnumSet.h`, the implementation depends on `CorradePair.h` and `CorradeCpu.hpp`.
**[CorradeString.hpp](CorradeString.hpp)** | 2521<sup>[2]</sup> | 2179 | [Containers::String](https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1String.html) and [Containers::StringView](https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1BasicStringView.html), lightweight and optimized string (view) classes. Depends on `CorradeEnumSet.h`, the implementation depends on `CorradeCpu.hpp`.
**[CorradeTriple.h](CorradeTriple.h)** | 476 | 1746 | [Containers::Triple](https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1Triple.html), a lightweight alternative to a three-component [`std::tuple`](https://en.cppreference.com/w/cpp/utility/tuple)
**[CorradeCpu.hpp](CorradeCpu.hpp)** | 1730 | 1978 | [Cpu](https://doc.magnum.graphics/corrade/namespaceCorrade_1_1Cpu.html) library, compile-time and runtime CPU feature detection and dispatch
**[CorradeStlForwardArray.h](CorradeStlForwardArray.h)** | 88 | 99<sup>[3]</sup> | [Corrade's forward declaration for `std::array`](https://doc.magnum.graphics/corrade/StlForwardArray_8h.html), a lightweight alternative to the full [`<array>`](https://en.cppreference.com/w/cpp/header/array) (15k PpLOC<sup>[1]</sup>) where supported
Expand Down

0 comments on commit 5a41684

Please sign in to comment.