Gorgon Game Engine
basic_Size< T_ > Class Template Reference

This class represents a 2D geometric size. More...

Inheritance diagram for basic_Size< T_ >:
[legend]

Public Types

typedef T_ BaseType
 Base type of the size elements. More...
 

Public Member Functions

 basic_Size ()
 Default constructor. More...
 
 basic_Size (const basic_Point< T_ > &point)
 Converts a point to size object. More...
 
template<class O_ >
 basic_Size (const basic_Size< O_ > &size)
 Converting constructor. More...
 
 basic_Size (const std::string &str)
 Conversion from string. More...
 
 basic_Size (const T_ &s)
 Filling constructor. More...
 
 basic_Size (const T_ &w, const T_ &h)
 Filling constructor. More...
 
T_ Area () const
 Returns the exact area of the rectangle has the size of this object. More...
 
T_ Cells () const
 Returns the number of fully encompassed cells. More...
 
bool IsValid () const
 Returns whether the size is valid, i.e. both dimensions are positive. More...
 
 operator basic_Point< T_ > () const
 Converts this size object to a point. More...
 
 operator std::string () const
 Converts this object to string. More...
 
bool operator!= (const basic_Size &size) const
 Compares two size objects. More...
 
template<class _S >
basic_Size operator*= (_S size)
 Multiplies this size object with the given factor. More...
 
template<class O_ >
basic_Size operator+ (const basic_Size< O_ > &size) const
 Adds two size objects. More...
 
template<class O_ >
basic_Sizeoperator+= (const basic_Size< O_ > &size)
 Adds the given size object to this size. More...
 
basic_Size operator- () const
 Negation operator. More...
 
template<class O_ >
basic_Size operator- (const basic_Size< O_ > &size) const
 Subtracts two size objects. More...
 
template<class O_ >
basic_Sizeoperator-= (const basic_Size< O_ > &size)
 Subtracts the given size object from this size. More...
 
template<class _S >
basic_Size operator/= (_S size)
 Divides this size object to the given factor. More...
 
template<class O_ >
basic_Sizeoperator= (const basic_Point< O_ > &point)
 Converting assignment operator. More...
 
template<class O_ >
basic_Sizeoperator= (const basic_Size< O_ > &size)
 Converting assignment operator. More...
 
bool operator== (const basic_Size &size) const
 Compares two size objects. More...
 

Static Public Member Functions

static basic_Size Max ()
 Returns the maximum representable size. More...
 
static basic_Size Parse (const std::string &str)
 Properly parses given string into a size. More...
 

Public Attributes

T_ Height
 Height of this size object. More...
 
T_ Width
 Width of this size object. More...
 

Detailed Description

template<class T_>
class Gorgon::Geometry::basic_Size< T_ >

This class represents a 2D geometric size.

Although negative size is meaningless, this class allows all operations over negative sizes.

Member Typedef Documentation

◆ BaseType

typedef T_ BaseType

Base type of the size elements.

Constructor & Destructor Documentation

◆ basic_Size() [1/6]

Default constructor.

This constructor does not zero initialize the object.

◆ basic_Size() [2/6]

basic_Size ( const T_ &  s)
explicit

Filling constructor.

This variant assigns the given value to both dimensions, effectively creating a square.

◆ basic_Size() [3/6]

basic_Size ( const T_ &  w,
const T_ &  h 
)

Filling constructor.

◆ basic_Size() [4/6]

basic_Size ( const basic_Size< O_ > &  size)

Converting constructor.

Converts a different typed size object to this type.

◆ basic_Size() [5/6]

basic_Size ( const basic_Point< T_ > &  point)
explicit

Converts a point to size object.

The size a point represents is the size of the rectangle that starts from origin to the given point.

◆ basic_Size() [6/6]

basic_Size ( const std::string &  str)
explicit

Conversion from string.

Member Function Documentation

◆ Area()

T_ Area ( ) const

Returns the exact area of the rectangle has the size of this object.

◆ Cells()

T_ Cells ( ) const

Returns the number of fully encompassed cells.

For instance, a 3.2x2.2 size object has 6 cells.

◆ IsValid()

bool IsValid ( ) const

Returns whether the size is valid, i.e. both dimensions are positive.

◆ Max()

static basic_Size Max ( )
static

Returns the maximum representable size.

This function requires T_ to be standard arithmetic type

◆ operator basic_Point< T_ >()

operator basic_Point< T_ > ( ) const
explicit

Converts this size object to a point.

Conversion is performed in a manner that the resultant point is the far corner of a rectangle that is placed at origin and the size of this object.

References basic_Size< T_ >::Height, and basic_Size< T_ >::Width.

◆ operator std::string()

operator std::string ( ) const
explicit

Converts this object to string.

◆ operator!=()

bool operator!= ( const basic_Size< T_ > &  size) const

Compares two size objects.

◆ operator*=()

basic_Size operator*= ( _S  size)

Multiplies this size object with the given factor.

◆ operator+()

basic_Size operator+ ( const basic_Size< O_ > &  size) const

Adds two size objects.

◆ operator+=()

basic_Size& operator+= ( const basic_Size< O_ > &  size)

Adds the given size object to this size.

◆ operator-() [1/2]

basic_Size operator- ( ) const

Negation operator.

◆ operator-() [2/2]

basic_Size operator- ( const basic_Size< O_ > &  size) const

Subtracts two size objects.

◆ operator-=()

basic_Size& operator-= ( const basic_Size< O_ > &  size)

Subtracts the given size object from this size.

◆ operator/=()

basic_Size operator/= ( _S  size)

Divides this size object to the given factor.

◆ operator=() [1/2]

basic_Size& operator= ( const basic_Point< O_ > &  point)

Converting assignment operator.

The size a point represents is the size of the rectangle that starts from origin to the given point.

◆ operator=() [2/2]

basic_Size& operator= ( const basic_Size< O_ > &  size)

Converting assignment operator.

◆ operator==()

bool operator== ( const basic_Size< T_ > &  size) const

Compares two size objects.

◆ Parse()

static basic_Size Parse ( const std::string &  str)
static

Properly parses given string into a size.

Throws errors if the size is not well formed. Works only on types that can be parsed using strtod. Following error codes are reported by this parse function:

  • IllegalTokenError 121001: Illegal token while reading Width
  • IllegalTokenError 121002: Illegal token while looking for width/height separator
  • IllegalTokenError 121003: Illegal token while reading Height
  • IllegalTokenError 121004: Illegal token(s) at the end

Member Data Documentation

◆ Height

T_ Height

Height of this size object.

◆ Width

T_ Width

Width of this size object.


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