libDwmCredence-0.1.32
Dwm::Credence::ShortString Class Reference

Encapsulates a string that is restricted to 255 bytes or less. More...

#include <DwmCredenceShortString.hh>

Public Member Functions

 ShortString ()=default
 Default constructor.
 
 ShortString (const ShortString &)=default
 Copy constructor.
 
ShortStringoperator= (const ShortString &)=default
 Assignment operator.
 
 ShortString (const std::string &s)
 Construct from the given string s.
 
ShortStringoperator= (const std::string &s)
 Assign from the given string s.
 
 ~ShortString ()
 Destructor.
 
const std::string & Value () const
 Returns the contained string value.
 
 operator std::string () const
 Returns a copy of the contained string value.
 
std::istream & Read (std::istream &is)
 Reads the short string from the given istream is.
 
std::ostream & Write (std::ostream &os) const
 Writes the shirt string to the given ostream os.
 
bool operator== (const ShortString &s) const
 operator ==
 
void Clear ()
 Clears the contents of the ShortString.
 

Friends

std::ostream & operator<< (std::ostream &os, const ShortString &shortString)
 ostream operator <<
 
std::istream & operator>> (std::istream &is, ShortString &shortString)
 istream operator >>
 

Detailed Description

Encapsulates a string that is restricted to 255 bytes or less.

We use this to prevent a couple of memory resource DoS attacks on a server during session initialization.

Constructor & Destructor Documentation

◆ ShortString()

Dwm::Credence::ShortString::ShortString ( const std::string & s)

Construct from the given string s.

Throws an exception if s.size() is greater than 255.

Member Function Documentation

◆ operator=()

ShortString & Dwm::Credence::ShortString::operator= ( const std::string & s)

Assign from the given string s.

Throws an exception if s.size() is greater than 255 bytes.

◆ Read()

std::istream & Dwm::Credence::ShortString::Read ( std::istream & is)

Reads the short string from the given istream is.

Returns is.

◆ Write()

std::ostream & Dwm::Credence::ShortString::Write ( std::ostream & os) const

Writes the shirt string to the given ostream os.

Returns os.

Friends And Related Symbol Documentation

◆ operator>>

std::istream & operator>> ( std::istream & is,
ShortString & shortString )
friend

istream operator >>

Throws an exception if the string is longer than 255 characters. Note that the string can not include whitespace.


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