common/serialise.h File Reference

#include <string>
#include "noreturn.h"
#include "xapian/visibility.h"
#include "xapian/weight.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
 The Xapian namespace contains public interfaces for the Xapian library.

Functions

template<class T >
std::string encode_length (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 Xapian::Weight::Internal &stats)
 Serialise a stats object.
Xapian::Weight::Internal unserialise_stats (const std::string &s)
 Unserialise a serialised stats object.
std::string serialise_mset (const Xapian::MSet &mset)
 Serialise a Xapian::MSet object.
Xapian::MSet unserialise_mset (const char *p, const char *p_end)
 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

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 42 of file serialise.cc.

Referenced by RemoteDatabase::add_document(), Xapian::DatabaseReplica::Internal::apply_db_copy(), RemoteDatabase::apply_stats_update(), RemoteDatabase::get_collection_freq(), RemoteDatabase::get_doclength(), RemoteDatabase::get_mset(), RemoteDatabase::get_termfreq(), Xapian::ValueCountMatchSpy::merge_results(), RemoteServer::msg_addspelling(), RemoteServer::msg_deletedocument(), RemoteServer::msg_doclength(), RemoteServer::msg_document(), RemoteServer::msg_positionlist(), RemoteServer::msg_query(), RemoteServer::msg_removespelling(), RemoteServer::msg_replacedocument(), RemoteServer::msg_replacedocumentterm(), RemoteServer::msg_setmetadata(), RemoteServer::msg_termlist(), RemoteServer::msg_valuestats(), NetworkPostList::next(), RemoteDatabase::open_allterms(), RemoteDatabase::open_document(), RemoteDatabase::open_position_list(), RemoteDatabase::open_term_list(), RemoteDatabase::read_post_list(), RemoteDatabase::read_value_stats(), QUnserial::readcompound(), QUnserial::readexternal(), QUnserial::readquery(), RemoteDatabase::replace_document(), test_serialiselength1(), test_serialiselength2(), Xapian::ValueMapPostingSource::unserialise(), Xapian::ValueWeightPostingSource::unserialise(), Xapian::ValueCountMatchSpy::unserialise(), Xapian::DecreasingValueWeightPostingSource::unserialise(), unserialise_document(), unserialise_error(), unserialise_mset(), unserialise_rset(), unserialise_stats(), and Xapian::DatabaseMaster::write_changesets_to_fd().

template<class T >
std::string encode_length ( len  )  [inline]

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 48 of file serialise.h.

Referenced by RemoteDatabase::add_spelling(), RemoteDatabase::delete_document(), RemoteDatabase::get_doclength(), Xapian::DatabaseReplica::Internal::get_revision_info(), RemoteServer::msg_adddocument(), RemoteServer::msg_allterms(), RemoteServer::msg_collfreq(), RemoteServer::msg_doclength(), RemoteServer::msg_document(), RemoteServer::msg_positionlist(), RemoteServer::msg_postlist(), RemoteServer::msg_query(), RemoteServer::msg_replacedocumentterm(), RemoteServer::msg_termfreq(), RemoteServer::msg_termlist(), RemoteServer::msg_update(), RemoteServer::msg_valuestats(), RemoteDatabase::open_document(), RemoteDatabase::open_position_list(), RemoteDatabase::open_term_list(), RemoteDatabase::read_value_stats(), RemoteServer::RemoteServer(), RemoteDatabase::remove_spelling(), RemoteDatabase::replace_document(), RemoteConnection::send_file(), RemoteDatabase::send_global_stats(), RemoteConnection::send_message(), FlintDatabase::send_whole_database(), ChertDatabase::send_whole_database(), BrassDatabase::send_whole_database(), Xapian::ValueMapPostingSource::serialise(), Xapian::ValueWeightPostingSource::serialise(), Xapian::Query::Internal::serialise(), Xapian::ValueCountMatchSpy::serialise(), Xapian::DecreasingValueWeightPostingSource::serialise(), serialise_document(), serialise_error(), serialise_mset(), Xapian::ValueCountMatchSpy::serialise_results(), serialise_rset(), serialise_stats(), RemoteDatabase::set_metadata(), RemoteDatabase::set_query(), test_serialiselength1(), and test_serialiselength2().

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

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

std::string serialise_mset ( const Xapian::MSet 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 268 of file serialise.cc.

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

Referenced by RemoteDatabase::set_query().

std::string serialise_stats ( const Xapian::Weight::Internal stats  ) 

Serialise a stats object.

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

Definition at line 126 of file serialise.cc.

References Xapian::Weight::Internal::collection_size, encode_length(), Xapian::Weight::Internal::rset_size, Xapian::Weight::Internal::termfreqs, and Xapian::Weight::Internal::total_length.

Referenced by RemoteServer::msg_query(), and RemoteDatabase::send_global_stats().

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

Xapian::MSet unserialise_mset ( const char *  p,
const char *  p_end 
)

Unserialise a serialised Xapian::MSet object.

Parameters:
p Pointer to the start of the string to unserialise.
p_end Pointer to the end of the string to unserialise.
Returns:
The unserialised Xapian::MSet object.

Definition at line 218 of file serialise.cc.

References decode_length(), Xapian::MSet::Internal::TermFreqAndWeight::termfreq, Xapian::MSet::Internal::TermFreqAndWeight::termweight, and unserialise_double().

Referenced by RemoteDatabase::get_mset().

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.

Definition at line 283 of file serialise.cc.

References Xapian::RSet::add_document(), decode_length(), and Xapian::RSet::size().

Referenced by RemoteServer::msg_query().

Xapian::Weight::Internal unserialise_stats ( const std::string &  s  ) 

Unserialise a serialised stats object.

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

Definition at line 148 of file serialise.cc.

References Xapian::Weight::Internal::collection_size, decode_length(), Xapian::Weight::Internal::rset_size, stat(), Xapian::Weight::Internal::termfreqs, and Xapian::Weight::Internal::total_length.

Referenced by RemoteDatabase::get_remote_stats(), and RemoteServer::msg_query().

XAPIAN_NORETURN ( void   unserialise_errorconst 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.


Documentation for Xapian (version 1.2.8).
Generated on 14 Dec 2011 by Doxygen 1.5.9.