1#ifndef SCIFIR_UNITS_SPECIAL_UNITS_SIZE_2D_HPP_INCLUDED
2#define SCIFIR_UNITS_SPECIAL_UNITS_SIZE_2D_HPP_INCLUDED
4#include "../derived_units/space_units.hpp"
5#include "../util/types.hpp"
7#include "boost/algorithm/string.hpp"
15 template<
typename T = length>
48 width = std::move(x.width);
49 height = std::move(x.height);
104 boost::split(widths,
init_size_2d,boost::is_any_of(
"*"));
105 if (widths.size() == 2)
107 boost::trim(widths[0]);
108 boost::trim(widths[1]);
148 width = std::move(x.width);
149 height = std::move(x.height);
200 boost::split(widths,
init_size_2d,boost::is_any_of(
"*"));
201 if (widths.size() == 2)
203 boost::trim(widths[0]);
204 boost::trim(widths[1]);
217 string to_string(
const size_2d<float>& x);
223 if (x.width == y.width and x.height == y.height)
249 return !(x == init_size_2d);
262 return !(init_size_2d == x);
274 return x + to_string(y);
280 return to_string(x) + y;
286 return os << to_string(x);
Class that allows to create scalar units, which are composed of a value (as a float) and dimensions....
void initialize_from_string(const string &init_size_2d)
Internal function. Initializes the member-variables with an initialization string of size_2d<float>.
size_2d(const float &new_width, const float &new_height)
Constructor. width is new_width and height is new_height.
string display() const
Returns a string representation of size_2d<float>, with his width and height.
float width
Width, stored as a float. The advantage related to size_2d<float> over size_2d<T> is that it sizes le...
size_2d(const size_2d< float > &x)
Copy constructor. The width and height are copied from the size_2d<float> x.
size_2d()
Default constructor. Initializes width and height to 0.
size_2d(const string &new_width, const string &new_height)
Constructor. width is new_width and height is new_height, they are initialized by string.
float get_area() const
Calculates the area as the multiplication of the width and height.
float height
Height, stored as a float. The advantage related to size_2d<float> over size_2d<T> is that it sizes l...
size_2d(const string &init_size_2d)
Constructor. The member-variables are initialized by the initialization string init_size_2d specializ...
size_2d(size_2d< float > &&x)
Move constructor. The width and height are moved from the size_2d<float> x.
Class that allows to store and calculate size in 2D, with width and height. The template parameter T ...
size_2d()
Default constructor. Both width and height are initialized to 0, with the dimensions to the default o...
size_2d< T > operator+(const size_2d< U > &x) const
Creates a new size_2d<T> by the addition of two size_2d<T> classes. The width is the result of the ad...
size_2d< T > operator-(const size_2d< U > &x) const
Creates a new size_2d<T> by the difference of two size_2d<T> classes. The width is the result of the ...
size_2d(size_2d< T > &&x)
Move constructor. The width and height are moved from the size_2d<T> x.
size_2d(const size_2d< T > &x)
Copy constructor. The width and height are copied from the size_2d<T> x.
size_2d(const string &new_width, const string &new_height)
Constructor. width is new_width and height is new_height, they are initialized by string.
T height
Height, usually stored as length.
size_2d(const string &init_size_2d)
Constructor. The member-variables are initialized by the initialization string init_size_2d.
scalar_unit get_area() const
Calculates the area as the multiplication of the width and height.
size_2d(const scalar_unit &new_width, const scalar_unit &new_height)
void operator+=(const size_2d< U > &x)
Sums the width of size_2d<T> x to the width and sums the height of size_2d<T> x to the height.
void initialize_from_string(const string &init_size_2d)
Internal function. Initializes the member-variables with an initialization string of size_2d<T>.
void operator-=(const size_2d< U > &x)
Substracts the width of size_2d<T> x to the width and substracts the height of size_2d<T> x to the he...
string display() const
Returns a string representation of size_2d<T>, with his width and height.
size_2d< T > & operator=(const size_2d< T > &x)
Copy assignment. The width and height are copied from the size_2d<T> x.
T width
Width, usually stored as length.
The namespace scifir contains all scifir-units, excepting the string literals, which are outside.
string to_string(const aid &x)
Creates a string representation of aid, it's for aid equivalent to the display() function of aid.
string display_float(const float &value, int number_of_decimals)
bool operator==(const scifir::size_2d< T > &x, const scifir::size_2d< T > &y)
Returns true if the width and height of x and y are both equal.
void operator+=(string &x, const scifir::size_2d< T > &y)
Concatenates the string x with the string representation of size_2d<T> y.
string operator+(const string &x, const scifir::size_2d< T > &y)
Creates a new string as the concatenation of the string x with the string representation of size_2d<T...
ostream & operator<<(ostream &os, const scifir::size_2d< T > &x)
Adds the string representation of the size_2d<T> x to an output stream os.
istream & operator>>(istream &is, scifir::size_2d< T > &x)
Allows that an istream initializes by string a size_2d<T> x.
bool operator!=(const scifir::size_2d< T > &x, const scifir::size_2d< T > &y)
Returns true if the width and height of x and y are any of them different.