InspIRCd  3.0
Public Member Functions | List of all members
ClientProtocol::Serializer Class Referenceabstract

#include <clientprotocol.h>

Inheritance diagram for ClientProtocol::Serializer:
DataProvider ServiceProvider classbase

Public Member Functions

 Serializer (Module *mod, const char *Name)
 
bool HandleTag (LocalUser *user, const std::string &tagname, std::string &tagvalue, TagMap &tags) const
 
const SerializedMessage & SerializeForUser (LocalUser *user, Message &msg)
 
virtual std::string Serialize (const Message &msg, const TagSelection &tagwl) const =0
 
virtual bool Parse (LocalUser *user, const std::string &line, ParseOutput &parseoutput)=0
 
- Public Member Functions inherited from DataProvider
 DataProvider (Module *Creator, const std::string &Name)
 
- Public Member Functions inherited from ServiceProvider
 ServiceProvider (Module *Creator, const std::string &Name, ServiceType Type)
 
virtual void RegisterService ()
 
void DisableAutoRegister ()
 
- Public Member Functions inherited from classbase
virtual CullResult cull ()
 

Additional Inherited Members

- Public Attributes inherited from ServiceProvider
ModuleRef creator
 
const std::string name
 
const ServiceType service
 

Detailed Description

Base class for client protocol serializers. A serializer has to implement serialization and parsing of protocol messages to/from wire format.

Constructor & Destructor Documentation

◆ Serializer()

ClientProtocol::Serializer::Serializer ( Module mod,
const char *  Name 
)

Constructor.

Parameters
modModule owning the serializer.
NameName of the serializer, e.g. "rfc".

Member Function Documentation

◆ HandleTag()

bool ClientProtocol::Serializer::HandleTag ( LocalUser user,
const std::string &  tagname,
std::string &  tagvalue,
TagMap tags 
) const

Handle a tag in a message being parsed. Call this method for each parsed tag.

Parameters
userUser sending the tag.
tagnameName of the tag.
tagvalueTag value, may be empty.
tagsTagMap to place the tag into, if it gets accepted.
Returns
True if no error occured, false if the tag name is invalid or if this tag already exists.

◆ Parse()

virtual bool ClientProtocol::Serializer::Parse ( LocalUser user,
const std::string &  line,
ParseOutput parseoutput 
)
pure virtual

Parse a protocol message from wire format.

Parameters
userSource of the message.
lineRaw protocol message.
parseoutputOutput of the parser.
Returns
True if the message was parsed successfully into parseoutput and should be processed, false to drop the message.

◆ Serialize()

virtual std::string ClientProtocol::Serializer::Serialize ( const Message msg,
const TagSelection tagwl 
) const
pure virtual

Serialize a high level protocol message into wire format.

Parameters
msgHigh level message to serialize. Contains all necessary information about the message, including all possible tags.
tagwlMessage tags to include in the serialized message. Tags attached to the message but not included in the whitelist must not appear in the output. This is because each user may get a different set of tags for the same message.
Returns
Protocol message in wire format. Must contain message delimiter as well, if any (e.g. CRLF for RFC1459).

◆ SerializeForUser()

const ClientProtocol::SerializedMessage & ClientProtocol::Serializer::SerializeForUser ( LocalUser user,
Message msg 
)

Serialize a message for a user.

Parameters
userUser to serialize the message for.
msgMessage to serialize.
Returns
Raw serialized message, only containing the appropriate tags for the user. The reference is guaranteed to be valid as long as the Message object is alive and until the same Message is serialized for another user.

The documentation for this class was generated from the following files: