backends/quartz/quartz_utils.h File Reference

#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 Documentation

#define CASSERT (  )     {char assert[(a) ? 1 : -1];(void)assert;}

Compile time assert a condition.

Definition at line 33 of file quartz_utils.h.

#define CASSERT_TYPE_UNSIGNED (  )     CASSERT(static_cast<T>(-1) > 0)

Compile time assert that type T is unsigned.

Definition at line 36 of file quartz_utils.h.


Typedef Documentation

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.


Function Documentation

template<class T>
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.

Parameters:
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.
Returns:
True if an integer was successfully read. False if the read failed. Failure may either be due to the data running out (in which case *src will equal 0), or due to the value read overflowing the size of result (in which case *src will point to wherever the value ends, despite the overflow).

Definition at line 68 of file quartz_utils.h.

References CASSERT, and CASSERT_TYPE_UNSIGNED.

template<class T>
string pack_uint ( value  )  [inline]

Generates a packed representation of an integer.

Parameters:
value The integer to represent.
Returns:
A string containing the representation of the integer.

Definition at line 125 of file quartz_utils.h.

References CASSERT_TYPE_UNSIGNED.

template<>
string pack_uint< bool > ( bool  value  )  [inline]

Generates a packed representation of a bool.

This is a specialisation of the template above.

Parameters:
value The bool to represent.
Returns:
A string containing the representation of the bool.

template<class T>
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).

Parameters:
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.
Returns:
True if an integer was successfully read. False if the read failed. Failure can hapen if the value read overflows the size of result.

Definition at line 177 of file quartz_utils.h.

References CASSERT, and CASSERT_TYPE_UNSIGNED.

template<class T>
string pack_uint_last ( 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).

Parameters:
value The integer to represent.
Returns:
A string containing the representation of the integer.

Definition at line 212 of file quartz_utils.h.

References CASSERT_TYPE_UNSIGNED.

template<class T>
string pack_uint_preserving_sort ( 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.

Parameters:
value The integer to represent.
Returns:
A string containing the representation of the integer.

Definition at line 237 of file quartz_utils.h.

References CASSERT_TYPE_UNSIGNED.

template<class T>
bool unpack_uint_preserving_sort ( const char **  src,
const char *  src_end,
T *  resultptr 
) [inline]

Unpack a unsigned integer, store in sort preserving order.

Parameters:
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.
Returns:
True if an integer was successfully read. False if the read failed. Failure may either be due to the data running out (in which case *src will equal 0), or due to the value read overflowing the size of result (in which case *src will point to wherever the value ends, despite the overflow).

Definition at line 273 of file quartz_utils.h.

bool unpack_string ( const char **  src,
const char *  src_end,
string &  result 
) [inline]

Definition at line 307 of file quartz_utils.h.

References unpack_uint().

string pack_string ( string  value  )  [inline]

Definition at line 328 of file quartz_utils.h.

References pack_uint().

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().


Documentation for Xapian (version 1.0.10).
Generated on 24 Dec 2008 by Doxygen 1.5.2.