CASM  1.1.0
A Clusters Approach to Statistical Mechanics
SupercellTraits.cc
Go to the documentation of this file.
2 
3 #include <boost/algorithm/string/classification.hpp>
4 #include <boost/algorithm/string/split.hpp>
5 #include <boost/lexical_cast.hpp>
6 #include <string>
7 #include <vector>
8 
9 #include "casm/casm_io/Log.hh"
11 
12 namespace CASM {
13 
14 const std::string traits<Supercell>::name = "Supercell";
15 
16 const std::string traits<Supercell>::short_name = "scel";
17 
20 bool traits<Supercell>::name_compare(std::string A, std::string B) {
21  try {
22  std::vector<std::string> splt_vec_A;
23  boost::split(splt_vec_A, A, boost::is_any_of("L_"),
24  boost::token_compress_on);
25  std::vector<std::string> splt_vec_B;
26  boost::split(splt_vec_B, B, boost::is_any_of("L_"),
27  boost::token_compress_on);
28  for (int i = 1; i < splt_vec_A.size(); ++i) {
29  Index i_A = boost::lexical_cast<Index>(splt_vec_A[i]);
30  Index i_B = boost::lexical_cast<Index>(splt_vec_B[i]);
31  if (i_A != i_B) {
32  return i_A < i_B;
33  }
34  }
35  return false;
36  } catch (std::exception &e) {
37  err_log().error("In traits<Supercell>::name_compare");
38  err_log() << "A: " << A << std::endl;
39  err_log() << "B: " << B << std::endl;
40  err_log() << e.what() << std::endl;
41  throw e;
42  }
43 };
44 
45 } // namespace CASM
void error(const std::string &what)
Definition: Log.hh:129
Main CASM namespace.
Definition: APICommand.hh:8
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
Log & err_log()
Definition: Log.hh:426
static const std::string short_name
static const std::string name