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
Loading...
Searching...
No Matches
Classes | Namespaces | Functions
size_3d.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_3d.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  scifir::size_3d< T >
 Class that allows to store and calculate size in 3D, with width, height and depth. The template parameter T allows to select any scalar_unit or numeric type to be the type of the width, the height and the depth (they always have the same type in the same instance). The width, height and depth can be any scalar_unit, usually length, but imaginary spaces with custom dimensions are also allowed. Initialization string example: "1 m * 2 m * 4 m". More...
 
class  scifir::size_3d< float >
 Specialization class of size_3d<T> that allows to store and calculate size in 3D, with width, height and depth as float types. Initialization string example: "1 * 2 * 4". 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_3d< T > &x)
 Returns a string representation of size_3d<T>.
 
string scifir::to_string (const size_3d< float > &x)
 Returns a string representation of size_3d<float>.
 
template<typename T >
bool operator== (const scifir::size_3d< T > &x, const scifir::size_3d< T > &y)
 Returns true if the width, height and depth of x and y are both equal.
 
template<typename T >
bool operator!= (const scifir::size_3d< T > &x, const scifir::size_3d< T > &y)
 Returns true if the width, height and depth of x and y are any of them different.
 
template<typename T >
bool operator== (const scifir::size_3d< T > &x, const string &init_size_3d)
 Compares size_3d<T> x with the size_3d<T> initialized with the initialization string of size_3d<T> init_size_3d, returns true if they are equal.
 
template<typename T >
bool operator!= (const scifir::size_3d< T > &x, const string &init_size_3d)
 Compares size_3d<T> x with the size_3d<T> initialized with the initialization string of size_3d<T> init_size_3d, returns true if they are different.
 
template<typename T >
bool operator== (const string &init_size_3d, const scifir::size_3d< T > &x)
 Compares size_3d<T> x with the size_3d<T> initialized with the initialization string of size_3d<T> init_size_3d, returns true if they are equal.
 
template<typename T >
bool operator!= (const string &init_size_3d, const scifir::size_3d< T > &x)
 Compares size_3d<T> x with the size_3d<T> initialized with the initialization string of size_3d<T> init_size_3d, returns true if they are different.
 
template<typename T >
void operator+= (string &x, const scifir::size_3d< T > &y)
 Concatenates the string x with the string representation of size_3d<T> y.
 
template<typename T >
string operator+ (const string &x, const scifir::size_3d< T > &y)
 Creates a new string as the concatenation of the string x with the string representation of size_3d<T> y.
 
template<typename T >
string operator+ (const scifir::size_3d< T > &x, const string &y)
 Creates a new string as the concatenation of the string x with the string representation of size_3d<T> y.
 
template<typename T >
ostream & operator<< (ostream &os, const scifir::size_3d< T > &x)
 Adds the string representation of the size_3d<T> x to an output stream os.
 
template<typename T >
istream & operator>> (istream &is, scifir::size_3d< T > &x)
 Allows that an istream initializes by string a size_3d<T> x.
 

Function Documentation

◆ operator!=() [1/3]

template<typename T >
bool operator!= ( const scifir::size_3d< T > &  x,
const scifir::size_3d< T > &  y 
)

Returns true if the width, height and depth of x and y are any of them different.

Definition at line 248 of file size_3d.hpp.

249{
250 return !(x == y);
251}

◆ operator!=() [2/3]

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

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

Definition at line 261 of file size_3d.hpp.

262{
263 return !(x == init_size_3d);
264}

◆ operator!=() [3/3]

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

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

Definition at line 274 of file size_3d.hpp.

275{
276 return !(init_size_3d == x);
277}

◆ operator+() [1/2]

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

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

Definition at line 292 of file size_3d.hpp.

293{
294 return to_string(x) + y;
295}
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_3d< T > &  y 
)

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

Definition at line 286 of file size_3d.hpp.

287{
288 return x + to_string(y);
289}

◆ operator+=()

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

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

Definition at line 280 of file size_3d.hpp.

281{
282 x += to_string(y);
283}

◆ operator<<()

template<typename T >
ostream & operator<< ( ostream &  os,
const scifir::size_3d< T > &  x 
)

Adds the string representation of the size_3d<T> x to an output stream os.

Definition at line 298 of file size_3d.hpp.

299{
300 return os << to_string(x);
301}

◆ operator==() [1/3]

template<typename T >
bool operator== ( const scifir::size_3d< T > &  x,
const scifir::size_3d< T > &  y 
)

Returns true if the width, height and depth of x and y are both equal.

Definition at line 235 of file size_3d.hpp.

236{
237 if (x.width == y.width and x.height == y.height and x.depth == y.depth)
238 {
239 return true;
240 }
241 else
242 {
243 return false;
244 }
245}

◆ operator==() [2/3]

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

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

Definition at line 254 of file size_3d.hpp.

255{
256 scifir::size_3d<T> y(init_size_3d);
257 return (x == y);
258}

◆ operator==() [3/3]

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

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

Definition at line 267 of file size_3d.hpp.

268{
269 scifir::size_3d<T> y(init_size_3d);
270 return (x == y);
271}

◆ operator>>()

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

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

Definition at line 304 of file size_3d.hpp.

305{
306 char a[256];
307 is.getline(a, 256);
308 string b(a);
309 x = scifir::size_3d<T>(b);
310 return is;
311}