scifir-units 2.0.0
scifir-units is a library of units of measurement, angles, coordinates, fields, and related data, all lightweight, that help in the development of scientific software and scientific machines
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Classes | Namespaces | Functions
size_2d.hpp File Reference
#include "../derived_units/space_units.hpp"
#include "../util/types.hpp"
#include "boost/algorithm/string.hpp"
#include <string>
Include dependency graph for size_2d.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  scifir::size_2d< T >
 Class that allows to store and calculate size in 2D, with width and height. The template parameter T allows to select any scalar_unit or numeric type to be the type of width and height (they always have the same type in the same instance). The width and height can be any scalar_unit, usually length, but imaginary spaces with custom dimensions are also allowed. Initialization string example: "1 m * 2 m". More...
 
class  scifir::size_2d< float >
 Specialization class of size_2d<T> that allows to store and calculate size in 2D, with width and height as float types. Initialization string example: "1 * 2". More...
 

Namespaces

namespace  scifir
 The namespace scifir contains all scifir-units, excepting the string literals, which are outside.
 

Functions

template<typename T >
string scifir::to_string (const size_2d< T > &x)
 Returns a string representation of size_2d<T>.
 
string scifir::to_string (const size_2d< float > &x)
 Returns a string representation of size_2d<float>.
 
template<typename T >
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.
 
template<typename T >
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.
 
template<typename T >
bool operator== (const scifir::size_2d< T > &x, const string &init_size_2d)
 Compares size_2d<T> x with the size_2d<T> initialized with the initialization string of size_2d<T> init_size_2d, returns true if they are equal.
 
template<typename T >
bool operator!= (const scifir::size_2d< T > &x, const string &init_size_2d)
 Compares size_2d<T> x with the size_2d<T> initialized with the initialization string of size_2d<T> init_size_2d, returns true if they are different.
 
template<typename T >
bool operator== (const string &init_size_2d, const scifir::size_2d< T > &x)
 Compares size_2d<T> x with the size_2d<T> initialized with the initialization string of size_2d<T> init_size_2d, returns true if they are equal.
 
template<typename T >
bool operator!= (const string &init_size_2d, const scifir::size_2d< T > &x)
 Compares size_2d<T> x with the size_2d<T> initialized with the initialization string of size_2d<T> init_size_2d, returns true if they are different.
 
template<typename T >
void operator+= (string &x, const scifir::size_2d< T > &y)
 Concatenates the string x with the string representation of size_2d<T> y.
 
template<typename T >
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> y.
 
template<typename T >
string operator+ (const scifir::size_2d< T > &x, const string &y)
 Creates a new string as the concatenation of the string x with the string representation of size_2d<T> y.
 
template<typename 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.
 
template<typename T >
istream & operator>> (istream &is, scifir::size_2d< T > &x)
 Allows that an istream initializes by string a size_2d<T> x.
 

Function Documentation

◆ operator!=() [1/3]

template<typename T >
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.

Definition at line 234 of file size_2d.hpp.

235{
236 return !(x == y);
237}

◆ operator!=() [2/3]

template<typename T >
bool operator!= ( const scifir::size_2d< T > &  x,
const string &  init_size_2d 
)

Compares size_2d<T> x with the size_2d<T> initialized with the initialization string of size_2d<T> init_size_2d, returns true if they are different.

Definition at line 247 of file size_2d.hpp.

248{
249 return !(x == init_size_2d);
250}

◆ operator!=() [3/3]

template<typename T >
bool operator!= ( const string &  init_size_2d,
const scifir::size_2d< T > &  x 
)

Compares size_2d<T> x with the size_2d<T> initialized with the initialization string of size_2d<T> init_size_2d, returns true if they are different.

Definition at line 260 of file size_2d.hpp.

261{
262 return !(init_size_2d == x);
263}

◆ operator+() [1/2]

template<typename T >
string operator+ ( const scifir::size_2d< T > &  x,
const string &  y 
)

Creates a new string as the concatenation of the string x with the string representation of size_2d<T> y.

Definition at line 278 of file size_2d.hpp.

279{
280 return to_string(x) + y;
281}
string to_string(const aid &x)
Creates a string representation of aid, it's for aid equivalent to the display() function of aid.
Definition aid.cpp:582

◆ operator+() [2/2]

template<typename T >
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> y.

Definition at line 272 of file size_2d.hpp.

273{
274 return x + to_string(y);
275}

◆ operator+=()

template<typename T >
void operator+= ( string &  x,
const scifir::size_2d< T > &  y 
)

Concatenates the string x with the string representation of size_2d<T> y.

Definition at line 266 of file size_2d.hpp.

267{
268 x += to_string(y);
269}

◆ operator<<()

template<typename 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.

Definition at line 284 of file size_2d.hpp.

285{
286 return os << to_string(x);
287}

◆ operator==() [1/3]

template<typename T >
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.

Definition at line 221 of file size_2d.hpp.

222{
223 if (x.width == y.width and x.height == y.height)
224 {
225 return true;
226 }
227 else
228 {
229 return false;
230 }
231}

◆ operator==() [2/3]

template<typename T >
bool operator== ( const scifir::size_2d< T > &  x,
const string &  init_size_2d 
)

Compares size_2d<T> x with the size_2d<T> initialized with the initialization string of size_2d<T> init_size_2d, returns true if they are equal.

Definition at line 240 of file size_2d.hpp.

241{
242 scifir::size_2d<T> y(init_size_2d);
243 return (x == y);
244}

◆ operator==() [3/3]

template<typename T >
bool operator== ( const string &  init_size_2d,
const scifir::size_2d< T > &  x 
)

Compares size_2d<T> x with the size_2d<T> initialized with the initialization string of size_2d<T> init_size_2d, returns true if they are equal.

Definition at line 253 of file size_2d.hpp.

254{
255 scifir::size_2d<T> y(init_size_2d);
256 return (x == y);
257}

◆ operator>>()

template<typename T >
istream & operator>> ( istream &  is,
scifir::size_2d< T > &  x 
)

Allows that an istream initializes by string a size_2d<T> x.

Definition at line 290 of file size_2d.hpp.

291{
292 char a[256];
293 is.getline(a, 256);
294 string b(a);
295 x = scifir::size_2d<T>(b);
296 return is;
297}