common/serialise.h File Reference

#include <xapian/visibility.h>
#include <string>
#include "noreturn.h"

Include dependency graph for serialise.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  Xapian

Functions

std::string encode_length (size_t len)
 Encode a length as a variable-length string.
size_t decode_length (const char **p, const char *end, bool check_remaining)
 Decode a length encoded by encode_length.
std::string serialise_error (const Xapian::Error &e)
 Serialise a Xapian::Error object to a string.
 XAPIAN_NORETURN (void unserialise_error(const std::string &error_string, const std::string &prefix, const std::string &new_context))
 Unserialise a Xapian::Error object and throw it.
std::string serialise_stats (const Stats &stats)
 Serialise a Stats object.
Stats unserialise_stats (const std::string &s)
 Unserialise a serialised Stats object.
std::string serialise_mset_pre_30_5 (const Xapian::MSet &mset)
 Serialise a Xapian::MSet object for remote protocol < 30.5.
std::string serialise_mset (const Xapian::MSet &mset)
 Serialise a Xapian::MSet object.
Xapian::MSet unserialise_mset (const std::string &s)
 Unserialise a serialised Xapian::MSet object.
std::string serialise_rset (const Xapian::RSet &omrset)
 Serialise a Xapian::RSet object.
Xapian::RSet unserialise_rset (const std::string &s)
 Unserialise a serialised Xapian::RSet object.
std::string serialise_document (const Xapian::Document &doc)
 Serialise a Xapian::Document object.
Xapian::Document unserialise_document (const std::string &s)
 Unserialise a serialised Xapian::Document object.


Function Documentation

std::string encode_length ( size_t  len  ) 

Encode a length as a variable-length string.

The encoding specifies its own length.

Parameters:
len The length to encode.
Returns:
The encoded length.

Definition at line 42 of file serialise.cc.

Referenced by RemoteDatabase::delete_document(), RemoteDatabase::get_doclength(), RemoteDatabase::open_document(), RemoteDatabase::open_position_list(), RemoteDatabase::open_term_list(), RemoteServer::RemoteServer(), RemoteDatabase::replace_document(), RemoteDatabase::send_global_stats(), Xapian::Query::Internal::serialise(), serialise_document(), serialise_error(), serialise_mset(), serialise_mset_pre_30_5(), serialise_rset(), serialise_stats(), RemoteDatabase::set_query(), test_serialiselength1(), and test_serialiselength2().

size_t decode_length ( const char **  p,
const char *  end,
bool  check_remaining 
)

Decode a length encoded by encode_length.

Parameters:
p Pointer to a pointer to the string, which will be advanced past the encoded length.
end Pointer to the end of the string.
check_remaining Check the result against the amount of data remaining after the length has been decoded.
Returns:
The decoded length.

Definition at line 64 of file serialise.cc.

Referenced by RemoteDatabase::add_document(), RemoteDatabase::get_collection_freq(), RemoteDatabase::get_termfreq(), NetworkPostList::next(), RemoteDatabase::open_allterms(), RemoteDatabase::open_document(), RemoteDatabase::open_position_list(), RemoteDatabase::open_term_list(), RemoteDatabase::read_post_list(), QUnserial::readcompound(), QUnserial::readquery(), RemoteDatabase::RemoteDatabase(), RemoteDatabase::replace_document(), test_serialiselength1(), test_serialiselength2(), unserialise_document(), unserialise_error(), unserialise_mset(), unserialise_rset(), unserialise_stats(), and RemoteDatabase::update_stats().

std::string serialise_error ( const Xapian::Error e  ) 

Serialise a Xapian::Error object to a string.

Parameters:
e The Xapian::Error object to serialise.
Returns:
Serialisation of e.

Definition at line 91 of file serialise.cc.

References encode_length(), Xapian::Error::get_context(), Xapian::Error::get_error_string(), Xapian::Error::get_msg(), and Xapian::Error::get_type().

Referenced by RemoteServer::RemoteServer(), RemoteServer::run(), and test_serialiseerror1().

XAPIAN_NORETURN ( void   unserialise_error(const std::string &error_string, const std::string &prefix, const std::string &new_context)  ) 

Unserialise a Xapian::Error object and throw it.

Note: does not return!

Parameters:
error_string The string to unserialise.
prefix Optional prefix to prepend to the unserialised Error's msg field.
new_context Optional context to replace the context in the error. If this is specified, any existing context will be noted in the Error's msg field.

std::string serialise_stats ( const Stats stats  ) 

Serialise a Stats object.

Parameters:
stats The Stats object to serialise.
Returns:
Serialisation of stats.

Definition at line 144 of file serialise.cc.

References Stats::average_length, Stats::collection_size, encode_length(), Stats::reltermfreq, Stats::rset_size, serialise_double(), and Stats::termfreq.

Referenced by RemoteDatabase::send_global_stats().

Stats unserialise_stats ( const std::string &  s  ) 

Unserialise a serialised Stats object.

Parameters:
s The string to unserialise.
Returns:
The unserialised Stats object.

Referenced by RemoteDatabase::get_remote_stats().

std::string serialise_mset_pre_30_5 ( const Xapian::MSet mset  ) 

Serialise a Xapian::MSet object for remote protocol < 30.5.

Parameters:
mset The object to serialise.
Returns:
The serialisation of the Xapian::MSet object.

Definition at line 201 of file serialise.cc.

References Xapian::MSet::begin(), encode_length(), Xapian::MSet::end(), Xapian::MSet::get_firstitem(), Xapian::MSet::get_matches_estimated(), Xapian::MSet::get_matches_lower_bound(), Xapian::MSet::get_matches_upper_bound(), Xapian::MSet::get_max_attained(), Xapian::MSet::get_max_possible(), Xapian::MSet::internal, serialise_double(), and Xapian::MSet::size().

std::string serialise_mset ( const Xapian::MSet mset  ) 

Serialise a Xapian::MSet object.

Parameters:
mset The object to serialise.
Returns:
The serialisation of the Xapian::MSet object.

Definition at line 235 of file serialise.cc.

References Xapian::MSet::begin(), encode_length(), Xapian::MSet::end(), Xapian::MSet::get_firstitem(), Xapian::MSet::get_matches_estimated(), Xapian::MSet::get_matches_lower_bound(), Xapian::MSet::get_matches_upper_bound(), Xapian::MSet::get_max_attained(), Xapian::MSet::get_max_possible(), Xapian::MSet::internal, serialise_double(), and Xapian::MSet::size().

Xapian::MSet unserialise_mset ( const std::string &  s  ) 

Unserialise a serialised Xapian::MSet object.

Parameters:
s The string to unserialise.
Returns:
The unserialised Xapian::MSet object.

Referenced by RemoteDatabase::get_mset().

std::string serialise_rset ( const Xapian::RSet omrset  ) 

Serialise a Xapian::RSet object.

Parameters:
rset The object to serialise.
Returns:
The serialisation of the Xapian::RSet object.

Definition at line 319 of file serialise.cc.

References encode_length(), and Xapian::RSet::internal.

Referenced by RemoteDatabase::set_query().

Xapian::RSet unserialise_rset ( const std::string &  s  ) 

Unserialise a serialised Xapian::RSet object.

Parameters:
s The serialised object as a string.
Returns:
The unserialised Xapian::RSet object.

std::string serialise_document ( const Xapian::Document doc  ) 

Serialise a Xapian::Document object.

Parameters:
doc The object to serialise.
Returns:
The serialisation of the Xapian::Document object.

Definition at line 351 of file serialise.cc.

References Assert, encode_length(), Xapian::Document::get_data(), Xapian::Document::termlist_begin(), Xapian::Document::termlist_count(), Xapian::Document::termlist_end(), Xapian::Document::values_begin(), Xapian::Document::values_count(), and Xapian::Document::values_end().

Referenced by RemoteDatabase::add_document(), RemoteDatabase::replace_document(), and test_serialisedoc1().

Xapian::Document unserialise_document ( const std::string &  s  ) 

Unserialise a serialised Xapian::Document object.

Parameters:
s The serialised object as a string.
Returns:
The unserialised Xapian::Document object.

Referenced by test_serialisedoc1().


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