6#ifndef LIMA_COMMON_STDBITSET
7#define LIMA_COMMON_STDBITSET
28 std::bitset<LC_WIDTH> base;
30 static std::hash<std::bitset<LC_WIDTH>> hash_fn;
34 inline std::string toString_()
const
37 char *p = chars + (
LC_WIDTH / N + 1);
39 LinguisticCode n = *
this;
44 unsigned char c = n.
lsb() & ((1 << N) - 1);
49 return std::string(p);
52 inline std::size_t hash()
const
58 : base((
unsigned long long)(val))
69 inline static LinguisticCode
fromUInt(uint64_t v)
76 const char *p = str.c_str();
77 const char *e = p + str.size();
93 inline static LinguisticCode
fromString(
const std::string& str)
98 static std::size_t
size() noexcept
113 inline LinguisticCode
operator<<(std::size_t pos)
const noexcept
115 LinguisticCode x = *
this;
126 inline LinguisticCode
operator>>(std::size_t pos)
const noexcept
128 LinguisticCode x = *
this;
141 return toString_<4>();
146 return toString_<3>();
151 return toString_<1>();
161 inline unsigned char lsb()
177 inline static std::ostream&
encodeToBinary(std::ostream& os,
const LinguisticCode& value)
179 std::deque<char> chars;
180 LinguisticCode n = value;
184 unsigned c = (n.
lsb() & 0x7F) << 1;
189 for (std::deque<char>::size_type i=chars.size()-1;i>0;i--)
204 LinguisticCode tmp(0);
206 while((c & 0x1) && is.good())
208 is.read((
char*)&c,
sizeof(
char));
219 LinguisticCode tmp(0);
233 LinguisticCode x = *
this;
238 inline LinguisticCode
operator&=(
const LinguisticCode& other)
noexcept
244 inline LinguisticCode
operator|=(
const LinguisticCode& other)
noexcept
250 inline LinguisticCode
operator^=(
const LinguisticCode& other)
noexcept
256 inline bool operator==(
const LinguisticCode& other)
const noexcept
258 return base == other.base;
261 inline bool operator!=(
const LinguisticCode& other)
const noexcept
263 return base != other.base;
275inline LinguisticCode
operator&(
const LinguisticCode& lhs,
const LinguisticCode& rhs)
noexcept
277 LinguisticCode x = lhs;
281inline LinguisticCode
operator|(
const LinguisticCode& lhs,
const LinguisticCode& rhs)
noexcept
283 LinguisticCode x = lhs;
287inline LinguisticCode
operator^(
const LinguisticCode& lhs,
const LinguisticCode& rhs)
noexcept
289 LinguisticCode x = lhs;
293inline bool operator<(
const LinguisticCode& lhs,
const LinguisticCode& rhs)
295 return lhs.hash() < rhs.hash();
298inline bool operator>(
const LinguisticCode& lhs,
const LinguisticCode& rhs)
300 return lhs.hash() > rhs.hash();
316 if (!std::isspace(c))
325 if (!std::isdigit(c))
342#define L_NONE Lima::LinguisticCode::ZERO
343#define NONE_1 Lima::LinguisticCode::ZERO
#define LIMA_COMMON_EXPORT
std::string toString() const
LinguisticCode operator>>=(std::size_t pos) noexcept
bool operator!=(const LinguisticCode &other) const noexcept
bool toBool() const noexcept
friend LinguisticCode operator^(const LinguisticCode &lhs, const LinguisticCode &rhs) noexcept
LinguisticCode operator<<=(std::size_t pos) noexcept
static LinguisticCode fromString(const std::string &str)
std::string toHexString() const
static LIMA_COMMON_EXPORT LinguisticCode fromDecString(const std::string &str)
static LIMA_COMMON_EXPORT const LinguisticCode ZERO
friend bool operator>(const LinguisticCode &lhs, const LinguisticCode &rhs)
LinguisticCode operator<<(std::size_t pos) const noexcept
LinguisticCode operator~() const noexcept
friend LinguisticCode operator&(const LinguisticCode &lhs, const LinguisticCode &rhs) noexcept
std::string toOctString() const
static std::size_t size() noexcept
static LinguisticCode fromUInt(uint64_t v)
static LinguisticCode fromOctString(const std::string &str)
static std::ostream & encodeToBinary(std::ostream &os, const LinguisticCode &value)
LIMA_COMMON_EXPORT std::string toDecString() const
friend LinguisticCode operator|(const LinguisticCode &lhs, const LinguisticCode &rhs) noexcept
LinguisticCode() noexcept
friend bool operator<(const LinguisticCode &lhs, const LinguisticCode &rhs)
static LinguisticCode decodeFromBinary(std::istream &is)
LinguisticCode operator^=(const LinguisticCode &other) noexcept
LinguisticCode operator&=(const LinguisticCode &other) noexcept
bool operator==(const LinguisticCode &other) const noexcept
LinguisticCode operator>>(std::size_t pos) const noexcept
LinguisticCode operator|=(const LinguisticCode &other) noexcept
std::string toBinString() const
bool operator!() const noexcept
static LinguisticCode decodeFromBinary(unsigned char *&p)
LinguisticCode operator|(const LinguisticCode &lhs, const LinguisticCode &rhs) noexcept
bool operator<(const LinguisticCode &lhs, const LinguisticCode &rhs)
std::ostream & operator<<(ostream &os, const Node &node)
bool operator>(const LinguisticCode &lhs, const LinguisticCode &rhs)
LinguisticCode operator&(const LinguisticCode &lhs, const LinguisticCode &rhs) noexcept
LIMA_COMMON_EXPORT std::istream & operator>>(std::istream &is, uint128_t &value)
LinguisticCode operator^(const LinguisticCode &lhs, const LinguisticCode &rhs) noexcept