35 using namespace cacao;
54 bool is_empty()
const {
return string == ((utf*) 0); }
66 return equal(t.hash(), t.size(), t.begin(), t.tag());
69 template<
typename Iterator>
71 return hash() == _hash
73 && std::equal(it, it + _size, begin());
76 template<
typename Iterator>
78 return hash() == _hash
79 && utf16_size() == _size
80 && std::equal(it, it + _size, utf16_begin());
87 size_t hash()
const {
return string.hash(); }
88 size_t size()
const {
return string.size(); }
90 size_t utf16_size()
const {
return string.utf16_size(); }
108 #define HASHTABLE_UTF_SIZE 16384
114 assert(!is_initialized());
122 #define UTF8(NAME, STR) utf8::NAME = Utf8String::from_utf8(STR);
183 hash += (hash << 10);
192 hash ^= (hash >> 11);
193 hash += (hash << 15);
207 template<
typename Iterator>
210 : _hash(0), _utf8_size(utf8_size), _utf16_size(0), _text(text) {}
236 size_t hash()
const {
return _hash; }
242 Iterator
begin()
const {
return _text; }
244 size_t size()
const {
return _utf8_size; }
250 cs = std::copy(_text, _text + _utf8_size, cs);
265 template<
typename Iterator>
268 : _hash(0), _utf8_size(0), _utf16_size(utf16_size), _text(text) {}
291 size_t hash()
const {
return _hash; }
297 Iterator
begin()
const {
return _text; }
299 size_t size()
const {
return _utf16_size; }
306 cs[_utf8_size] =
'\0';
318 template<
typename Iterator>
321 Iterator end = cs +
size;
326 template<
typename Iterator>
329 Iterator end = cs +
size;
336 return string_from_utf8<const char*>(cs, sz);
340 return string_from_utf8<utf8::DotToSlash>(cs, sz);
344 return string_from_utf8<utf8::SlashToDot>(cs, sz);
348 return string_from_utf8<utf8::SlashToDot>(u.
begin(), u.
size());
352 return string_from_utf16<const uint16_t*>(cs, sz);
356 return string_from_utf16<utf16::DotToSlash>(cs, sz);
380 return substring(from,
size());
397 for (; it != end; it++) {
398 unsigned char c = *it;
402 if (c == 0xc0 && ((
unsigned char) it[1]) == 0x80)
456 void utf8(uint8_t) { count++; }
496 #define UTF8( NAME, STR ) Utf8String utf8::NAME;
524 fputc((c >= 32 && c <= 127) ? c :
'?', _dst);
577 void utf16(uint16_t c) { *_dst++ = c; }
587 strcpy(buffer,
"NULL");
607 strcpy(buffer,
"NULL");
678 return os << (u ? u.
begin() :
"(nil)");
void utf_strcat_convert_to_latin1_classname(char *buffer, Utf8String u)
utf_utils::Range< SlashToDot > slash_to_dot(T t)
uint16_t decode_char(const char *&)
Utf8String substring(size_t from) const
#define STATISTICS(x)
Wrapper for statistics only code.
static const size_t sizeof_utf
FromUtf8Builder(Iterator text, size_t utf8_size)
utf8_tag tag() const
used by operator==
static Utf8String from_utf8_dot_to_slash(const char *, size_t)
Fn::ReturnType transform(Iterator begin, Iterator end, Fn)
static Data * alloc(size_t hash, size_t utf8_size, size_t utf16_size)
allocate a Utf8String with given hash and size You still have to fill in the strings text! ...
static Utf8String from_utf8_slash_to_dot(const char *, size_t)
size_t compute_hash(const uint16_t *cs, size_t)
byte_iterator end() const
void utf_display_printable_ascii_classname(Utf8String u)
Utf8String::utf16_iterator utf16_begin() const
void set_occupied(const T &t)
void encode(Utf16Iterator begin, Utf16Iterator end, char *dst)
void utf_fprint_printable_ascii_classname(FILE *file, Utf8String u)
static Utf8String from_utf16_dot_to_slash(const uint16_t *, size_t)
Utf8String::utf16_iterator utf16_end() const
Utf8String::byte_iterator begin() const
utf16_tag tag() const
interface to InternTableEntry
JNIEnv jthread jobject jclass jlong size
#define TRACESUBSYSTEMINITIALIZATION(text)
void utf_strcat_convert_to_latin1(char *buffer, utf *u)
void utf_sprint_convert_to_latin1_classname(char *buffer, Utf8String u)
bool operator==(const T &t) const
const char * byte_iterator
size_t hash() const
interface to HashTable
size_t hash() const
interface to HashTable
FromUtf16Builder(Iterator text, size_t utf16_size)
utf8_tag tag() const
interface to InternTableEntry
#define HASHTABLE_UTF_SIZE
This file contains the statistics framework.
static bool is_initialized()
const char * utf8_text(utf *u)
static Utf8String string_from_utf16(const uint16_t *cs, size_t size)
Simple stream class for formatted output.
bool is_valid_name() const
Utf8String ReturnType
interface to utf8::transform
static Utf8String from_utf8(const char *, size_t)
void utf_sprint_convert_to_latin1(char *buffer, Utf8String u)
static InternTable< InternedUtf8String > intern_table
Utf8String get_string() const
used by set_occupied
Utf8String get_string() const
Utf8String ReturnType
interface to utf8::transform
Utf8String get_string() const
SprintConvertToLatin1(char *dst)
bool equal(size_t _hash, size_t _size, Iterator it, utf8_tag) const
DisplayPrintableAscii(FILE *dst)
OStream & operator<<(OStream &OS, const std::string &t)
#define EXPENSIVE_ASSERT(EXPR)
An assertion that performs computations too expensive even for a normal debug build.
void utf_fprint_printable_ascii(FILE *file, Utf8String u)
void utf_display_printable_ascii(Utf8String u)
static Utf8String from_utf16(const uint16_t *, size_t)
long num_codepoints(const char *, size_t)
byte_iterator begin() const
static size_t finish_hash(size_t hash)
Additional assertion macros.
Fn::ReturnType transform(Iterator begin, Iterator end, Fn)
InternedUtf8String(Utf8String u)
static size_t update_hash(size_t hash, uint8_t byte)
bool equal(size_t _hash, size_t _size, Iterator it, utf16_tag) const
static java_object_t * next
size_t utf16_size() const
#define STAT_REGISTER_VAR(type, var, init, name, description)
Register an external statistics variable.
#define STAT_DECLARE_VAR(type, var, init)
Declare an external statistics variable.
bool is_empty() const
Interface to HashTable.
void * mem_alloc(int32_t size)
char text[sizeof(void *)]
const char * utf8_end(utf *u)
Utf8String::byte_iterator end() const
size_t num_bytes(const uint16_t *, size_t)
static Utf8String string_from_utf8(const char *cs, size_t size)