-
Notifications
You must be signed in to change notification settings - Fork 1
/
periodic-table-data.h
28 lines (25 loc) · 992 Bytes
/
periodic-table-data.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#pragma once
#include <string>
#include <vector>
#include <map>
// data parsed in from contrib/Periodic-Table-JSON/PeriodicTableJSON.json
class PeriodicTableData {
public: // data
struct ElementData { // field names are the same as json keys in contrib/Periodic-Table-JSON/PeriodicTableJSON.json
std::string name;
std::string appearance;
double atomic_mass;
double boil;
std::string category;
std::string symbol;
}; // ElementData
std::map<std::string, unsigned> symToElt;
private: // data
std::vector<ElementData> data; // by element, this array contains them in sequential order beginning with H at index 0
static PeriodicTableData singleInstance; // statically initialized instance
public: // iface
PeriodicTableData();
static const PeriodicTableData& get() {return singleInstance;}
const ElementData& operator()(unsigned elt) const;
unsigned elementFromSymbol(const std::string &sym) const;
}; // PeriodicTableData