initial commit, 4.5 stable
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
This commit is contained in:
55
thirdparty/icu4c/common/charstrmap.h
vendored
Normal file
55
thirdparty/icu4c/common/charstrmap.h
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
// © 2020 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
|
||||
// charstrmap.h
|
||||
// created: 2020sep01 Frank Yung-Fong Tang
|
||||
|
||||
#ifndef __CHARSTRMAP_H__
|
||||
#define __CHARSTRMAP_H__
|
||||
|
||||
#include <utility>
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/uobject.h"
|
||||
#include "uhash.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* Map of const char * keys & values.
|
||||
* Stores pointers as is: Does not own/copy/adopt/release strings.
|
||||
*/
|
||||
class CharStringMap final : public UMemory {
|
||||
public:
|
||||
/** Constructs an unusable non-map. */
|
||||
CharStringMap() : map(nullptr) {}
|
||||
CharStringMap(int32_t size, UErrorCode &errorCode) {
|
||||
map = uhash_openSize(uhash_hashChars, uhash_compareChars, uhash_compareChars,
|
||||
size, &errorCode);
|
||||
}
|
||||
CharStringMap(CharStringMap &&other) noexcept : map(other.map) {
|
||||
other.map = nullptr;
|
||||
}
|
||||
CharStringMap(const CharStringMap &other) = delete;
|
||||
~CharStringMap() {
|
||||
uhash_close(map);
|
||||
}
|
||||
|
||||
CharStringMap &operator=(CharStringMap &&other) noexcept {
|
||||
map = other.map;
|
||||
other.map = nullptr;
|
||||
return *this;
|
||||
}
|
||||
CharStringMap &operator=(const CharStringMap &other) = delete;
|
||||
|
||||
const char *get(const char *key) const { return static_cast<const char *>(uhash_get(map, key)); }
|
||||
void put(const char *key, const char *value, UErrorCode &errorCode) {
|
||||
uhash_put(map, const_cast<char *>(key), const_cast<char *>(value), &errorCode);
|
||||
}
|
||||
|
||||
private:
|
||||
UHashtable *map;
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif // __CHARSTRMAP_H__
|
Reference in New Issue
Block a user