#include <xapian/types.h>
#include <string>
Include dependency graph for quartz_utils.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Defines | |
#define | CASSERT(a) {char assert[(a) ? 1 : -1];(void)assert;} |
Compile time assert a condition. | |
#define | CASSERT_TYPE_UNSIGNED(T) CASSERT(static_cast<T>(-1) > 0) |
Compile time assert that type T is unsigned. | |
Typedefs | |
typedef unsigned char | om_byte |
typedef unsigned int | om_uint32 |
typedef int | om_int32 |
Functions | |
template<class T> | |
bool | unpack_uint (const char **src, const char *src_end, T *resultptr) |
Reads an unsigned integer from a string starting at a given position. | |
template<class T> | |
string | pack_uint (T value) |
Generates a packed representation of an integer. | |
template<> | |
string | pack_uint< bool > (bool value) |
Generates a packed representation of a bool. | |
template<class T> | |
bool | unpack_uint_last (const char **src, const char *src_end, T *resultptr) |
Reads an unsigned integer from a string starting at a given position. | |
template<class T> | |
string | pack_uint_last (T value) |
Generates a packed representation of an integer. | |
template<class T> | |
string | pack_uint_preserving_sort (T value) |
Generate a packed representation of an integer, preserving sort order. | |
template<class T> | |
bool | unpack_uint_preserving_sort (const char **src, const char *src_end, T *resultptr) |
Unpack a unsigned integer, store in sort preserving order. | |
bool | unpack_string (const char **src, const char *src_end, string &result) |
string | pack_string (string value) |
string | pack_string_preserving_sort (string value) |
Pack a string into a representation which preserves sort order. | |
bool | unpack_string_preserving_sort (const char **src, const char *src_end, string &result) |
bool | unpack_bool (const char **src, const char *src_end, bool *resultptr) |
string | pack_bool (bool value) |
string | quartz_docid_to_key (Xapian::docid did) |
Convert a document id to a key (suitable when the docid is the only component of the key). |
#define CASSERT | ( | a | ) | {char assert[(a) ? 1 : -1];(void)assert;} |
#define CASSERT_TYPE_UNSIGNED | ( | T | ) | CASSERT(static_cast<T>(-1) > 0) |
typedef unsigned char om_byte |
Definition at line 38 of file quartz_utils.h.
typedef unsigned int om_uint32 |
Definition at line 39 of file quartz_utils.h.
typedef int om_int32 |
Definition at line 40 of file quartz_utils.h.
bool unpack_uint | ( | const char ** | src, | |
const char * | src_end, | |||
T * | resultptr | |||
) | [inline] |
Reads an unsigned integer from a string starting at a given position.
src | A pointer to a pointer to the data to read. The character pointer will be updated to point to the next character to read, or 0 if the method ran out of data. (It is only set to 0 in case of an error). | |
src_end | A pointer to the byte after the end of the data to read the integer from. | |
resultptr | A pointer to a place to store the result. If an error occurs, the value stored in this location is undefined. If this pointer is 0, the result is not stored, and the method simply skips over the result. |
Definition at line 68 of file quartz_utils.h.
References CASSERT, and CASSERT_TYPE_UNSIGNED.
string pack_uint | ( | T | value | ) | [inline] |
Generates a packed representation of an integer.
value | The integer to represent. |
Definition at line 125 of file quartz_utils.h.
References CASSERT_TYPE_UNSIGNED.
string pack_uint< bool > | ( | bool | value | ) | [inline] |
Generates a packed representation of a bool.
This is a specialisation of the template above.
value | The bool to represent. |
bool unpack_uint_last | ( | const char ** | src, | |
const char * | src_end, | |||
T * | resultptr | |||
) | [inline] |
Reads an unsigned integer from a string starting at a given position.
This encoding requires that we know the encoded length from out-of-band information (so is suitable when only one integer is encoded, or for the last integer encoded).
src | A pointer to a pointer to the data to read. | |
src_end | A pointer to the byte after the end of the data to read the integer from. | |
resultptr | A pointer to a place to store the result. If an error occurs, the value stored in this location is undefined. If this pointer is 0, the result is not stored, and the method simply skips over the result. |
Definition at line 177 of file quartz_utils.h.
References CASSERT, and CASSERT_TYPE_UNSIGNED.
string pack_uint_last | ( | T | value | ) | [inline] |
Generates a packed representation of an integer.
This encoding requires that we know the encoded length from out-of-band information (so is suitable when only one integer is encoded, or for the last integer encoded).
value | The integer to represent. |
Definition at line 212 of file quartz_utils.h.
References CASSERT_TYPE_UNSIGNED.
string pack_uint_preserving_sort | ( | T | value | ) | [inline] |
Generate a packed representation of an integer, preserving sort order.
This representation is less compact than the usual one, and has a limit of 256 bytes on the length of the integer. However, this is unlikely to ever be a problem.
value | The integer to represent. |
Definition at line 237 of file quartz_utils.h.
References CASSERT_TYPE_UNSIGNED.
bool unpack_uint_preserving_sort | ( | const char ** | src, | |
const char * | src_end, | |||
T * | resultptr | |||
) | [inline] |
Unpack a unsigned integer, store in sort preserving order.
src | A pointer to a pointer to the data to read. The character pointer will be updated to point to the next character to read, or 0 if the method ran out of data. (It is only set to 0 in case of an error). | |
src_end | A pointer to the byte after the end of the data to read the integer from. | |
resultptr | A pointer to a place to store the result. If an error occurs, the value stored in this location is undefined. If this pointer is 0, the result is not stored, and the method simply skips over the result. |
Definition at line 273 of file quartz_utils.h.
bool unpack_string | ( | const char ** | src, | |
const char * | src_end, | |||
string & | result | |||
) | [inline] |
string pack_string | ( | string | value | ) | [inline] |
string pack_string_preserving_sort | ( | string | value | ) | [inline] |
Pack a string into a representation which preserves sort order.
We do this by replacing zero bytes in the string with a zero byte followed by byte value 0xff, and then appending two zero bytes to the end.
Definition at line 339 of file quartz_utils.h.
bool unpack_string_preserving_sort | ( | const char ** | src, | |
const char * | src_end, | |||
string & | result | |||
) | [inline] |
Definition at line 351 of file quartz_utils.h.
bool unpack_bool | ( | const char ** | src, | |
const char * | src_end, | |||
bool * | resultptr | |||
) | [inline] |
Definition at line 376 of file quartz_utils.h.
string pack_bool | ( | bool | value | ) | [inline] |
Definition at line 397 of file quartz_utils.h.
string quartz_docid_to_key | ( | Xapian::docid | did | ) | [inline] |
Convert a document id to a key (suitable when the docid is the only component of the key).
Definition at line 406 of file quartz_utils.h.
References pack_uint_last().
Referenced by QuartzRecordTable::delete_record(), QuartzTermListTable::delete_termlist(), QuartzRecordTable::get_record(), make_key(), QuartzTermList::QuartzTermList(), QuartzRecordTable::replace_record(), and QuartzTermListTable::set_entries().