The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Private Attributes | List of all members
campaignd::control_line Class Reference

Represents a server control line written to a communication socket. More...

#include <control.hpp>

Public Member Functions

 control_line (const std::string &str)
 Parses a control line string. More...
 
bool empty () const
 Whether the control line is empty. More...
 
 operator const std::string & () const
 Returns the control command. More...
 
const std::string & cmd () const
 Returns the control command. More...
 
size_t args_count () const
 Returns the total number of arguments, not including the command itself. More...
 
const std::string & operator[] (size_t n) const
 Returns the nth argument. More...
 
const std::string & arg (size_t n) const
 Returns the nth argument. More...
 
std::string full () const
 Return the full command line string. More...
 

Private Attributes

std::vector< std::string > args_
 

Detailed Description

Represents a server control line written to a communication socket.

Control lines are plain text command lines using the ASCII space character (0x20) as command separator. This type is really only used to keep the code pretty.

Definition at line 32 of file control.hpp.

Constructor & Destructor Documentation

campaignd::control_line::control_line ( const std::string &  str)
inline

Parses a control line string.

Definition at line 38 of file control.hpp.

References args_.

Member Function Documentation

const std::string& campaignd::control_line::arg ( size_t  n) const
inline

Returns the nth argument.

Exceptions
std::out_of_rangen exceeds args_count().

Definition at line 98 of file control.hpp.

References args_, args_count(), and n.

Referenced by operator[]().

size_t campaignd::control_line::args_count ( ) const
inline

Returns the total number of arguments, not including the command itself.

Definition at line 78 of file control.hpp.

References args_.

Referenced by arg(), and campaignd::server::handle_read_from_fifo().

const std::string& campaignd::control_line::cmd ( ) const
inline

Returns the control command.

Equivalent to calling arg(0).

Definition at line 70 of file control.hpp.

References args_.

Referenced by operator const std::string &().

bool campaignd::control_line::empty ( ) const
inline

Whether the control line is empty.

Definition at line 48 of file control.hpp.

References args_.

std::string campaignd::control_line::full ( ) const
inline

Return the full command line string.

Definition at line 110 of file control.hpp.

References args_, and utils::join().

Referenced by campaignd::server::handle_read_from_fifo().

campaignd::control_line::operator const std::string & ( ) const
inline

Returns the control command.

Equivalent to calling arg(0).

Definition at line 60 of file control.hpp.

References cmd().

const std::string& campaignd::control_line::operator[] ( size_t  n) const
inline

Returns the nth argument.

Exceptions
std::out_of_rangen exceeds args_count().

Definition at line 88 of file control.hpp.

References arg().

Member Data Documentation

std::vector<std::string> campaignd::control_line::args_
private

Definition at line 116 of file control.hpp.

Referenced by arg(), args_count(), cmd(), control_line(), empty(), and full().


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