CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
global.cc
Go to the documentation of this file.
3 
4 namespace CASM {
5 
13  void from_json(COORD_TYPE &value, const jsonParser &json) {
14  std::string c_case = from_json<std::string>(json);
15 
16  char c = c_case[0];
17  c = tolower(c);
18 
19  if((c == 'c') || (c == 'k')) {
20  value = CART;
21  }
22  else if((c == 'd') || (c == 'f')) {
23  value = FRAC;
24  }
25  else {
26  value = COORD_DEFAULT;
27  }
28 
29  }
30 
31 
33  jsonParser &to_json(const COORD_TYPE &value, jsonParser &json) {
34  if(value == FRAC) {
35  return to_json("FRAC", json);
36  }
37  else if(value == CART) {
38  return to_json("CART", json);
39  }
40  else {
41  return to_json("COORD_DEFAULT", json);
42  }
43  }
44 
46  void from_json(PERIODICITY_TYPE &value, const jsonParser &json) {
47  std::string periodicity = from_json<std::string>(json);
48 
49  if(periodicity == "PERIODIC") {
50  value = PERIODIC;
51  }
52  else if(periodicity == "LOCAL") {
53  value = LOCAL;
54  }
55  else if(periodicity == "PERIODICITY_DEFAULT") {
56  value = PERIODICITY_DEFAULT;
57  }
58  else {
59  std::stringstream ss;
60  ss << "Could not recognize PERIODICITY_TYPE from json: '" << periodicity << "'";
61  throw std::runtime_error(ss.str());
62  }
63  }
64 
65 
68  if(value == PERIODIC) {
69  return to_json("PERIODIC", json);
70  }
71  else if(value == LOCAL) {
72  return to_json("LOCAL", json);
73  }
74  else {
75  return to_json("PERIODICITY_DEFAULT", json);
76  }
77  }
78 
80  void from_json(CELL_TYPE &value, const jsonParser &json) {
81  std::string type = from_json<std::string>(json);
82 
83  if(type == "PRIM") {
84  value = PRIM;
85  }
86  else if(type == "SCEL") {
87  value = SCEL;
88  }
89  else {
90  std::stringstream ss;
91  ss << "Could not recognize CELL_TYPE from json: '" << type << "'";
92  throw std::runtime_error(ss.str());
93  }
94  }
95 
96 
98  jsonParser &to_json(const CELL_TYPE &value, jsonParser &json) {
99  if(value == PRIM) {
100  return to_json("PRIM", json);
101  }
102  else {
103  return to_json("SCEL", json);
104  }
105 
106  }
107 
108 }
109 
void from_json(ClexDescription &desc, const jsonParser &json)
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
Main CASM namespace.
Definition: complete.cpp:8