Initial work on iterators, rework of variable handling by including actual string
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2019-06-23 15:58:14 +02:00
parent 1a84661c79
commit 76b8ba3ebc
25 changed files with 185 additions and 78 deletions

View File

@@ -7,16 +7,28 @@
namespace Porygon::Utilities{
class HashedString{
const uint32_t _hash;
const std::u16string _string;
public:
explicit HashedString(const std::u16string& s) : _hash(ConstHash(s.c_str())){
explicit HashedString(const std::u16string& s)
: _hash(ConstHash(s.c_str())),
_string(s)
{
}
explicit HashedString(char16_t const *input) : _hash(ConstHash(input)){
explicit HashedString(char16_t const *input)
: _hash(ConstHash(input)),
_string(std::u16string(input))
{
}
explicit HashedString(char const *input) : _hash(ConstHash(input)){
}
HashedString(const HashedString& b) = default;
explicit HashedString(uint32_t hash) : _hash(hash){
}
HashedString(const HashedString& b) :_hash(b._hash), _string(b._string){
};
static uint32_t constexpr ConstHash(char16_t const *input) {
return *input ?
@@ -34,12 +46,24 @@ namespace Porygon::Utilities{
return _hash;
}
const std::u16string* GetString() const{
return &_string;
}
bool operator==(const HashedString& b) const{
return _hash == b._hash;
}
bool operator!=(const HashedString& b) const{
return _hash != b._hash;
}
bool operator<(const HashedString& b) const{
return _hash < b._hash;
}
bool operator>(const HashedString& b) const{
return _hash > b._hash;
}
};
}

View File

@@ -0,0 +1,21 @@
#ifndef PORYGONLANG_STRINGUTILS_HPP
#define PORYGONLANG_STRINGUTILS_HPP
#include <iostream>
#include <string>
#include <locale>
#include <codecvt>
#include <sstream>
namespace Porygon::Utilities{
class StringUtils{
public:
static std::u16string IntToString(long const &i) {
std::wstring_convert<std::codecvt_utf8_utf16<char16_t, 0x10ffff, std::little_endian>, char16_t> conv;
return conv.from_bytes(std::to_string(i));
}
};
}
#endif //PORYGONLANG_STRINGUTILS_HPP