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
address.cpp
Go to the documentation of this file.
1#include "./address.hpp"
2
3using namespace std;
4
5namespace scifir
6{
7 address::address() : zid(),location(),inner_location(),postal_code()
8 {}
9
10 address::address(const address& x) : zid(x.zid),location(x.location),inner_location(x.inner_location),postal_code(x.postal_code)
11 {}
12
13 address::address(address&& x) : zid(std::move(x.zid)),location(std::move(x.location)),inner_location(std::move(x.inner_location)),postal_code(std::move(x.postal_code))
14 {}
15
16 address::address(const scifir::zid& new_zid,const string& new_location,const string& new_inner_location,const string& new_postal_code) : zid(new_zid),location(new_location),inner_location(new_inner_location),postal_code(new_postal_code)
17 {}
18
20 {
21 zid = x.zid;
25 return *this;
26 }
27
29 {
30 zid = std::move(x.zid);
31 location = std::move(x.location);
32 inner_location = std::move(x.inner_location);
33 postal_code = std::move(x.postal_code);
34 return *this;
35 }
36
38 {
39 if (inner_location != "")
40 {
41 return address::INTERNAL;
42 }
43 else
44 {
45 return address::EXTERNAL;
46 }
47 }
48
49 string address::display() const
50 {
51 if (inner_location != "")
52 {
53 return zid + ", " + location + " " + inner_location;
54 }
55 else
56 {
57 return partial_display();
58 }
59 }
60
62 {
63 return location + " " + inner_location;
64 }
65
66 string address::text_display() const
67 {
68 ostringstream out;
69 out << zid << "\n";
70 out << location << "\n";
71 out << inner_location << "\n";
72 return out.str();
73 }
74}
75
77{
78 if(x.zid == y.zid and x.location == y.location and x.postal_code == y.postal_code and x.inner_location == y.inner_location)
79 {
80 return true;
81 }
82 else
83 {
84 return false;
85 }
86}
87
89{
90 return !(x == y);
91}
92
93ostream& operator <<(ostream& os, const scifir::address& x)
94{
95 return os << x.display();
96}
bool operator!=(const scifir::address &x, const scifir::address &y)
Definition address.cpp:88
bool operator==(const scifir::address &x, const scifir::address &y)
Definition address.cpp:76
ostream & operator<<(ostream &os, const scifir::address &x)
Definition address.cpp:93
string inner_location
Definition address.hpp:35
string location
Definition address.hpp:34
string postal_code
Definition address.hpp:36
address::type get_type() const
Definition address.cpp:37
string display() const
Definition address.cpp:49
address & operator=(const address &x)
Definition address.cpp:19
string text_display() const
Definition address.cpp:66
string partial_display() const
Definition address.cpp:61
scifir::zid zid
Definition address.hpp:33
Class that allows to store information about a zone, including the astronomical object inside which t...
Definition zid.hpp:14
The namespace scifir contains all scifir-units, excepting the string literals, which are outside.
Definition address.cpp:6