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
Public Types | Public Member Functions | Public Attributes | Private Member Functions | List of all members
scifir::zid Class Reference

Class that allows to store information about a zone, including the astronomical object inside which the zone is. The zone can be in any astronomical object, not only the Earth is supported. Initialization string example: "(P) universe:milky-way:solar-system:earth (Z) chile:region-metropolitana:santiago:providencia". More...

#include <zid.hpp>

Collaboration diagram for scifir::zid:
Collaboration graph
[legend]

Public Types

enum  type : int8_t {
  NONE , COUNTRY , REGION , SETTLEMENT ,
  ZONE
}
 Type of zone. More...
 

Public Member Functions

 zid ()
 Default constructor. There's no data about any zone, the aid member-variable is also empty.
 
 zid (const zid &x)
 Copy constructor. The zid is initialized copying the member-variables of the zid x.
 
 zid (zid &&x)
 Move constructor. The zid is initialized moving the member-variables of the zid x.
 
 zid (const scifir::aid &new_aid, const zid::type &new_zid_type, const string &new_country)
 Constructor. It initializes a country as the entire zone of zid.
 
 zid (const scifir::aid &new_aid, const string &new_country, const vector< string > &new_regions)
 Constructor. It initializes a region as the entire zone of zid, which is the last region specified, the one inside the other regions given if there's more than one region initialized.
 
 zid (const scifir::aid &new_aid, const zid::type &new_zid_type, const string &new_country, const vector< string > &new_regions, const string &new_zone)
 Constructor. The aid is new_aid, the country is new_country, the regions are new_regions and zone is new_zone. The zone_type can be ZONE or SETTLEMENT.
 
 zid (const scifir::aid &new_aid, const string &init_zid)
 Constructor. The aid is new_aid, init_zid initializes the other member-variables.
 
 zid (const string &init_zid_full)
 Constructor. Initializes all the member-variables with init_zid_full, which is a union is init_aid and init_zid.
 
zidoperator= (const zid &x)
 Copy assigment. The member-variables are copied from the zid x.
 
zidoperator= (zid &&x)
 Move assigment. The member-variables are moved from the zid x.
 
zidoperator= (const string &init_zid_full)
 Assignment. Initializes all the member-variables with init_zid_full, which is a union is init_aid and init_zid.
 
bool has_no_country () const
 Returns true if the value of country is the predefined value 'no-country'.
 
bool has_unknown_country () const
 Returns true if the value of country is the predefined value 'unknown-country'.
 
string display () const
 Returns a string representation of zid, including the string representation of his aid.
 
string partial_display () const
 Returns a string representation of zid, without the string representation of his aid.
 

Public Attributes

scifir::aid aid
 The aid of the astronomical object where the zone is.
 
vector< stringregions
 The different administrative regions where the zone is. There can be any number of administrative regions, each inside the other. There can't be regions that aren't inside another region here.
 
string country
 The country where the zone is. In extraterrestrial planets, it's considered a country any division of territory ruled with their own laws. The predefined value no-country means that the zone is not inside a country. The predefined value unknown-country means that it's not known the country where the zone is, but that it's known that it's a country.
 
string zone
 The name of the zone. Personal zones with a personal name are allowed, it's not necessary that the zone is registered by a country or another organization.
 
zid::type zone_type
 The type of zone. It can be any value of the enum zid::type. The possible values are COUNTRY, REGION and ZONE. A zone can be any surface inside an astronomical object, of any shape, and it's not necessary to be a zone registered by a country or organization. A personal zone with a personal name is allowed.
 

Private Member Functions

void initialize_from_string (const string &init_zid_full)
 Internal function. It's used by the string constructor and the string assignment of zid to initialize the member-variables using the initialization string init_zid_full.
 

Detailed Description

Class that allows to store information about a zone, including the astronomical object inside which the zone is. The zone can be in any astronomical object, not only the Earth is supported. Initialization string example: "(P) universe:milky-way:solar-system:earth (Z) chile:region-metropolitana:santiago:providencia".

Definition at line 13 of file zid.hpp.

Member Enumeration Documentation

◆ type

Type of zone.

Enumerator
NONE 

No zone.

COUNTRY 

A country.

REGION 

A region.

SETTLEMENT 

A settlement.

ZONE 

A zone. A zone is any surface inside an astronomical object, of any shape. It's not necessary to be a zone registered by a country or organization, personal zones are allowed.

Definition at line 16 of file zid.hpp.

@ REGION
A region.
Definition zid.hpp:16
@ ZONE
A zone. A zone is any surface inside an astronomical object, of any shape. It's not necessary to be a...
Definition zid.hpp:16
@ COUNTRY
A country.
Definition zid.hpp:16
@ SETTLEMENT
A settlement.
Definition zid.hpp:16
@ NONE
No zone.
Definition zid.hpp:16

Constructor & Destructor Documentation

◆ zid() [1/8]

zid::zid ( )

Default constructor. There's no data about any zone, the aid member-variable is also empty.

Definition at line 12 of file zid.cpp.

13 {}
zid::type zone_type
The type of zone. It can be any value of the enum zid::type. The possible values are COUNTRY,...
Definition zid.hpp:41
scifir::aid aid
The aid of the astronomical object where the zone is.
Definition zid.hpp:37
vector< string > regions
The different administrative regions where the zone is. There can be any number of administrative reg...
Definition zid.hpp:38
string zone
The name of the zone. Personal zones with a personal name are allowed, it's not necessary that the zo...
Definition zid.hpp:40
string country
The country where the zone is. In extraterrestrial planets, it's considered a country any division of...
Definition zid.hpp:39

◆ zid() [2/8]

zid::zid ( const zid x)

Copy constructor. The zid is initialized copying the member-variables of the zid x.

Definition at line 15 of file zid.cpp.

15 : aid(x.aid),regions(x.regions),country(x.country),zone(x.zone),zone_type(x.zone_type)
16 {}

◆ zid() [3/8]

zid::zid ( zid &&  x)

Move constructor. The zid is initialized moving the member-variables of the zid x.

Definition at line 18 of file zid.cpp.

18 : aid(std::move(x.aid)),regions(std::move(x.regions)),country(std::move(x.country)),zone(std::move(x.zone)),zone_type(std::move(x.zone_type))
19 {}

◆ zid() [4/8]

zid::zid ( const scifir::aid new_aid,
const zid::type new_zid_type,
const string new_country 
)
explicit

Constructor. It initializes a country as the entire zone of zid.

Definition at line 21 of file zid.cpp.

22 {
23 if (new_zid_type == zid::COUNTRY)
24 {
25 aid = new_aid;
26 country = new_country;
28 }
29 }

◆ zid() [5/8]

zid::zid ( const scifir::aid new_aid,
const string new_country,
const vector< string > &  new_regions 
)
explicit

Constructor. It initializes a region as the entire zone of zid, which is the last region specified, the one inside the other regions given if there's more than one region initialized.

Definition at line 31 of file zid.cpp.

31 : aid(new_aid),country(new_country),regions(new_regions),zone(),zone_type(zid::REGION)
32 {}

◆ zid() [6/8]

zid::zid ( const scifir::aid new_aid,
const zid::type new_zid_type,
const string new_country,
const vector< string > &  new_regions,
const string new_zone 
)
explicit

Constructor. The aid is new_aid, the country is new_country, the regions are new_regions and zone is new_zone. The zone_type can be ZONE or SETTLEMENT.

Definition at line 34 of file zid.cpp.

35 {
36 if (new_zid_type != zid::COUNTRY and new_zid_type != zid::REGION)
37 {
38 aid = new_aid;
39 regions = new_regions;
40 country = new_country;
41 zone = new_zone;
42 zone_type = new_zid_type;
43 }
44 }

◆ zid() [7/8]

zid::zid ( const scifir::aid new_aid,
const string init_zid 
)
explicit

Constructor. The aid is new_aid, init_zid initializes the other member-variables.

Definition at line 46 of file zid.cpp.

46 : aid(new_aid),regions(),country(),zone(),zone_type(zid::NONE)
47 {
48 if (init_zid != "")
49 {
50 vector<string> values;
51 boost::split(values,init_zid,boost::is_any_of(":"));
52 if (values[0].front() == '(' and isalpha(values[0][1]))
53 {
54 zone_type = create_zone_type(values[0].substr(1,1));
55 string new_country;
56 if (values[0][3] != ' ')
57 {
58 new_country = values[0].substr(3);
59 }
60 else
61 {
62 new_country = values[0].substr(4);
63 }
64 if (values.size() == 1 and zone_type == zid::COUNTRY)
65 {
66 country = new_country;
67 }
68 if ((values.size() >= 2 and zone_type == zid::REGION) or (values.size() >= 3 and (zone_type == zid::ZONE or zone_type == zid::SETTLEMENT)))
69 {
70 country = new_country;
71 int total_for_values;
73 {
74 total_for_values = int(values.size());
75 }
77 {
78 total_for_values = int(values.size()) - 1;
79 }
80 for (int i = 1; i < total_for_values; i++)
81 {
82 regions.push_back(values[i]);
83 }
84 }
85 if (values.size() >= 3 and (zone_type == zid::ZONE or zone_type == zid::SETTLEMENT))
86 {
87 country = new_country;
88 zone = values.back();
89 }
90 if (country == "")
91 {
93 }
94 }
95 }
96 }
zid::type create_zone_type(const string &zone_type_abbreviation)
Creates an instance of a zid::type with the given string, which is the reverse as the to_string() fun...
Definition zid.cpp:311

◆ zid() [8/8]

zid::zid ( const string init_zid_full)
explicit

Constructor. Initializes all the member-variables with init_zid_full, which is a union is init_aid and init_zid.

Definition at line 98 of file zid.cpp.

98 : zid()
99 {
100 initialize_from_string(init_zid_full);
101 }
void initialize_from_string(const string &init_zid_full)
Internal function. It's used by the string constructor and the string assignment of zid to initialize...
Definition zid.cpp:181
zid()
Default constructor. There's no data about any zone, the aid member-variable is also empty.
Definition zid.cpp:12

Member Function Documentation

◆ display()

string zid::display ( ) const

Returns a string representation of zid, including the string representation of his aid.

Definition at line 139 of file zid.cpp.

140 {
141 if (country != "")
142 {
143 ostringstream out;
144 out << to_string(aid) << " (" << to_string(zone_type) << ") " << country;
145 if (regions.size() > 0 and zone != "")
146 {
147 out << ":";
148 }
149 for (const string& x_region : regions)
150 {
151 out << x_region << ":";
152 }
153 out << zone;
154 return out.str();
155 }
156 else
157 {
158 return "";
159 }
160 }
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

◆ has_no_country()

bool zid::has_no_country ( ) const

Returns true if the value of country is the predefined value 'no-country'.

Definition at line 129 of file zid.cpp.

130 {
131 return (country == "no-country");
132 }

◆ has_unknown_country()

bool zid::has_unknown_country ( ) const

Returns true if the value of country is the predefined value 'unknown-country'.

Definition at line 134 of file zid.cpp.

135 {
136 return (country == "unknown-country");
137 }

◆ initialize_from_string()

void zid::initialize_from_string ( const string init_zid_full)
private

Internal function. It's used by the string constructor and the string assignment of zid to initialize the member-variables using the initialization string init_zid_full.

Definition at line 181 of file zid.cpp.

182 {
183 if (init_zid_full != "")
184 {
185 if (!(init_zid_full[1] == 'C' or init_zid_full[1] == 'R' or init_zid_full[1] == 'Z'))
186 {
187 std::size_t last_whitespace = init_zid_full.find(" (");
188 string init_aid = init_zid_full.substr(0,last_whitespace);
189 string init_zid = init_zid_full.substr(last_whitespace + 1);
190 aid = scifir::aid(init_aid);
191 vector<string> values;
192 boost::split(values,init_zid,boost::is_any_of(":"));
193 if (values[0].front() == '(' and isalpha(values[0][1]))
194 {
195 zone_type = create_zone_type(values[0].substr(1,1));
196 string new_country;
197 if (values[0][3] != ' ')
198 {
199 new_country = values[0].substr(3);
200 }
201 else
202 {
203 new_country = values[0].substr(4);
204 }
205 if (values.size() == 1 and zone_type == zid::COUNTRY)
206 {
207 country = new_country;
208 }
209 if ((values.size() >= 2 and zone_type == zid::REGION) or (values.size() >= 3 and (zone_type == zid::ZONE or zone_type == zid::SETTLEMENT)))
210 {
211 country = new_country;
212 int total_for_values;
213 if (zone_type == zid::REGION)
214 {
215 total_for_values = int(values.size());
216 }
218 {
219 total_for_values = int(values.size()) - 1;
220 }
221 for (int i = 1; i < total_for_values; i++)
222 {
223 regions.push_back(values[i]);
224 }
225 }
226 if (values.size() >= 3 and (zone_type == zid::ZONE or zone_type == zid::SETTLEMENT))
227 {
228 country = new_country;
229 zone = values.back();
230 }
231 if (country == "")
232 {
234 }
235 }
236 }
237 else
238 {
239 vector<string> values;
240 boost::split(values,init_zid_full,boost::is_any_of(":"));
241 if (values[0].front() == '(' and isalpha(values[0][1]))
242 {
243 zone_type = create_zone_type(values[0].substr(1,1));
244 string new_country;
245 if (values[0][3] != ' ')
246 {
247 new_country = values[0].substr(3);
248 }
249 else
250 {
251 new_country = values[0].substr(4);
252 }
253 if (values.size() == 1 and zone_type == zid::COUNTRY)
254 {
255 country = new_country;
256 }
257 if ((values.size() >= 2 and zone_type == zid::REGION) or (values.size() >= 3 and (zone_type == zid::ZONE or zone_type == zid::SETTLEMENT)))
258 {
259 country = new_country;
260 int total_for_values;
261 if (zone_type == zid::REGION)
262 {
263 total_for_values = int(values.size());
264 }
266 {
267 total_for_values = int(values.size()) - 1;
268 }
269 for (int i = 1; i < total_for_values; i++)
270 {
271 regions.push_back(values[i]);
272 }
273 }
274 if (values.size() >= 3 and (zone_type == zid::ZONE or zone_type == zid::SETTLEMENT))
275 {
276 country = new_country;
277 zone = values.back();
278 }
279 if (country == "")
280 {
282 }
283 }
284 }
285 }
286 }
Class that stores astronomical ids, not as an integer but with an string as identifier....
Definition aid.hpp:14

◆ operator=() [1/3]

zid & zid::operator= ( const string init_zid_full)

Assignment. Initializes all the member-variables with init_zid_full, which is a union is init_aid and init_zid.

Definition at line 123 of file zid.cpp.

124 {
125 initialize_from_string(init_zid_full);
126 return *this;
127 }

◆ operator=() [2/3]

zid & zid::operator= ( const zid x)

Copy assigment. The member-variables are copied from the zid x.

Definition at line 103 of file zid.cpp.

104 {
105 aid = x.aid;
106 regions = x.regions;
107 country = x.country;
108 zone = x.zone;
109 zone_type = x.zone_type;
110 return *this;
111 }
aid()
Default constructor. The astronomical type is NONE, the other member-variables are empty strings.
Definition aid.cpp:13

◆ operator=() [3/3]

zid & zid::operator= ( zid &&  x)

Move assigment. The member-variables are moved from the zid x.

Definition at line 113 of file zid.cpp.

114 {
115 aid = std::move(x.aid);
116 regions = std::move(x.regions);
117 country = std::move(x.country);
118 zone = std::move(x.zone);
119 zone_type = std::move(x.zone_type);
120 return *this;
121 }

◆ partial_display()

string zid::partial_display ( ) const

Returns a string representation of zid, without the string representation of his aid.

Definition at line 162 of file zid.cpp.

163 {
164 if (country != "")
165 {
166 ostringstream out;
167 out << "(" << to_string(zone_type) << ") " << country << ":";
168 for (const string& x_region : regions)
169 {
170 out << x_region << ":";
171 }
172 out << zone;
173 return out.str();
174 }
175 else
176 {
177 return "";
178 }
179 }

Member Data Documentation

◆ aid

scifir::aid zid::aid

The aid of the astronomical object where the zone is.

Definition at line 37 of file zid.hpp.

◆ country

string zid::country

The country where the zone is. In extraterrestrial planets, it's considered a country any division of territory ruled with their own laws. The predefined value no-country means that the zone is not inside a country. The predefined value unknown-country means that it's not known the country where the zone is, but that it's known that it's a country.

Definition at line 39 of file zid.hpp.

◆ regions

vector< string > zid::regions

The different administrative regions where the zone is. There can be any number of administrative regions, each inside the other. There can't be regions that aren't inside another region here.

Definition at line 38 of file zid.hpp.

◆ zone

string zid::zone

The name of the zone. Personal zones with a personal name are allowed, it's not necessary that the zone is registered by a country or another organization.

Definition at line 40 of file zid.hpp.

◆ zone_type

string zid::zone_type

The type of zone. It can be any value of the enum zid::type. The possible values are COUNTRY, REGION and ZONE. A zone can be any surface inside an astronomical object, of any shape, and it's not necessary to be a zone registered by a country or organization. A personal zone with a personal name is allowed.

Definition at line 41 of file zid.hpp.


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