Sha256: f28d47f687dd625666df29f130d9e949ef21b1c71ecafee77f3a3c983aa4f8e9
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
#ifndef MARISA_GRIMOIRE_TRIE_HEADER_H_ #define MARISA_GRIMOIRE_TRIE_HEADER_H_ #include "marisa/grimoire/io.h" namespace marisa { namespace grimoire { namespace trie { class Header { public: enum { HEADER_SIZE = 16 }; Header() {} void map(Mapper &mapper) { const char *ptr; mapper.map(&ptr, HEADER_SIZE); MARISA_THROW_IF(!test_header(ptr), MARISA_FORMAT_ERROR); } void read(Reader &reader) { char buf[HEADER_SIZE]; reader.read(buf, HEADER_SIZE); MARISA_THROW_IF(!test_header(buf), MARISA_FORMAT_ERROR); } void write(Writer &writer) const { writer.write(get_header(), HEADER_SIZE); } std::size_t io_size() const { return HEADER_SIZE; } private: static const char *get_header() { static const char buf[HEADER_SIZE] = "We love Marisa."; return buf; } static bool test_header(const char *ptr) { for (std::size_t i = 0; i < HEADER_SIZE; ++i) { if (ptr[i] != get_header()[i]) { return false; } } return true; } // Disallows copy and assignment. Header(const Header &); Header &operator=(const Header &); }; } // namespace trie } // namespace marisa } // namespace grimoire #endif // MARISA_GRIMOIRE_TRIE_HEADER_H_
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
melisa-0.1.0 | ext/marisa/lib/marisa/grimoire/trie/header.h |